java.lang.Object | |
↳ | org.springframework.aop.target.AbstractLazyCreationTargetSource |
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.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger | Logger available to subclasses |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the lazy-initialized target object,
creating it on-the-fly if it doesn't exist already.
| |||||||||||
This default implementation returns
null if the
target is null (it is hasn't yet been initialized),
or the target class if the target has already been initialized. | |||||||||||
Return whether the lazy target object of this TargetSource
has already been fetched.
| |||||||||||
Will all calls to
getTarget() return the same object?
In that case, there will be no need to invoke
| |||||||||||
Release the given target object obtained from the
getTarget() method. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Subclasses should implement this method to return the lazy initialized object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.aop.TargetClassAware
| |||||||||||
From interface
org.springframework.aop.TargetSource
|
Logger available to subclasses
Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.
Exception |
---|
This default implementation returns null
if the
target is null
(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
.
TargetSource
Return whether the lazy target object of this TargetSource has already been fetched.
Will all calls to getTarget()
return the same object?
In that case, there will be no need to invoke
releaseTarget(Object)
, and the AOP framework can cache
the return value of getTarget()
.
true
if the target is immutableRelease the given target object obtained from the
getTarget()
method.
target | object obtained from a call to getTarget() |
---|
Exception |
---|
Subclasses should implement this method to return the lazy initialized object. Called the first time the proxy is invoked.
Exception | if creation failed |
---|