org.springframework.aop.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.
isInitialized(), createObject()
| Modifier and Type | Field and Description |
|---|---|
| private Object | lazyTarget
The lazily initialized target object. |
| protected final Log | logger
Logger available to subclasses. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract Object | Returns: the created objectSubclasses should implement this method to return the lazy initialized object. |
| public synchronized Object | getTarget()
Implements org. |
| public synchronized Class | getTargetClass()
Implements org. null if the
target is null (it is hasn't yet been initialized),
or the target class if the target has already been initialized.
|
| public synchronized boolean |
| lazyTarget | back to summary |
|---|---|
| private Object lazyTarget The lazily initialized target object. | |
| logger | back to summary |
|---|---|
| protected final Log logger Logger available to subclasses. | |
| AbstractLazyCreationTargetSource | back to summary |
|---|---|
| public AbstractLazyCreationTargetSource() | |
| createObject | back to summary |
|---|---|
| protected abstract Object createObject() throws Exception Subclasses should implement this method to return the lazy initialized object. Called the first time the proxy is invoked. | |
| getTarget | back to summary |
|---|---|
| public synchronized Object getTarget() throws Exception Implements org. Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.
| |
| getTargetClass | back to summary |
|---|---|
| public synchronized Class Implements org. This default implementation returns Subclasses may wish to override this method in order to provide
a meaningful value when the target is still
| |
| isInitialized | back to summary |
|---|---|
| public synchronized boolean isInitialized() Return whether the lazy target object of this TargetSource has already been fetched. | |