spring-framework / org.springframework.aop.target / AbstractLazyCreationTargetSource

AbstractLazyCreationTargetSource

abstract class AbstractLazyCreationTargetSource : TargetSource

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.

Author
Rob Harrop

Author
Juergen Hoeller

Since
1.2.4

See Also
#isInitialized()#createObject()

Constructors

<init>

AbstractLazyCreationTargetSource()

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.

Functions

getTarget

open fun getTarget(): Any

Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.

getTargetClass

open fun getTargetClass(): Class<*>

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.

isInitialized

open fun isInitialized(): Boolean

Return whether the lazy target object of this TargetSource has already been fetched.

isStatic

open fun isStatic(): Boolean

releaseTarget

open fun releaseTarget(target: Any): Unit