Class AbstractLazyCreationTargetSource
java.lang.Object
org.springframework.aop.target.AbstractLazyCreationTargetSource
- All Implemented Interfaces:
- TargetClassAware,- TargetSource
TargetSource implementation that will
 lazily create a user-managed object.
 Creation of the lazy target object is controlled by the user by implementing
 the createObject() method. This TargetSource will invoke
 this method the first time the proxy is accessed.
 
Useful when you need to pass a reference to some dependency to an object but you don't actually want the dependency to be created until it is first used. A typical scenario for this is a connection to a remote resource.
- Since:
- 1.2.4
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger available to subclasses.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract ObjectSubclasses should implement this method to return the lazy initialized object.Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.This default implementation returnsnullif the target isnull(it is hasn't yet been initialized), or the target class if the target has already been initialized.booleanReturn whether the lazy target object of this TargetSource has already been fetched.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.aop.TargetSourceisStatic, releaseTarget
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log loggerLogger available to subclasses.
 
- 
- 
Constructor Details- 
AbstractLazyCreationTargetSourcepublic AbstractLazyCreationTargetSource()
 
- 
- 
Method Details- 
isInitializedpublic boolean isInitialized()Return whether the lazy target object of this TargetSource has already been fetched.
- 
getTargetClassThis default implementation returnsnullif the target isnull(it is hasn't yet been initialized), or the target class if the target has already been initialized.Subclasses may wish to override this method in order to provide a meaningful value when the target is still null.- Specified by:
- getTargetClassin interface- TargetClassAware
- Specified by:
- getTargetClassin interface- TargetSource
- Returns:
- the type of targets returned by this TargetSource
- See Also:
 
- 
getTargetReturns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.- Specified by:
- getTargetin interface- TargetSource
- Returns:
- the target object which contains the joinpoint,
 or nullif there is no actual target instance
- Throws:
- Exception- if the target object can't be resolved
- See Also:
 
- 
createObject
 
-