Class AbstractRefreshableTargetSource
java.lang.Object
org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource
- All Implemented Interfaces:
- Refreshable,- TargetClassAware,- TargetSource
- Direct Known Subclasses:
- BeanFactoryRefreshableTargetSource
public abstract class AbstractRefreshableTargetSource
extends Object
implements TargetSource, Refreshable
Abstract 
TargetSource implementation that
 wraps a refreshable target object. Subclasses can determine whether a
 refresh is required, and need to provide fresh target objects.
 Implements the Refreshable interface in order to allow for
 explicit control over the refresh status.
- Since:
- 2.0
- Author:
- Rod Johnson, Rob Harrop, Juergen Hoeller
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract ObjectObtain a fresh target object.longReturn the last time an actual refresh happened (as timestamp).longReturn the number of actual refreshes since startup.final ObjectReturn a target instance.Class<?>Return the type of targets returned by thisTargetSource.final voidrefresh()Refresh the underlying target object.protected booleanDetermine whether a refresh is required.voidsetRefreshCheckDelay(long refreshCheckDelay) Set the delay between refresh checks, in milliseconds.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- 
loggerLogger available to subclasses.
- 
targetObject
 
- 
- 
Constructor Details- 
AbstractRefreshableTargetSourcepublic AbstractRefreshableTargetSource()
 
- 
- 
Method Details- 
setRefreshCheckDelaypublic void setRefreshCheckDelay(long refreshCheckDelay) Set the delay between refresh checks, in milliseconds. Default is -1, indicating no refresh checks at all.Note that an actual refresh will only happen when requiresRefresh()returnstrue.
- 
getTargetClassDescription copied from interface:TargetSourceReturn the type of targets returned by thisTargetSource.Can return null, although certain usages of aTargetSourcemight just work with a predetermined target class.- Specified by:
- getTargetClassin interface- TargetClassAware
- Specified by:
- getTargetClassin interface- TargetSource
- Returns:
- the type of targets returned by this TargetSource
 
- 
getTargetDescription copied from interface:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- Specified by:
- getTargetin interface- TargetSource
- Returns:
- the target object which contains the joinpoint,
 or nullif there is no actual target instance
 
- 
refreshpublic final void refresh()Description copied from interface:RefreshableRefresh the underlying target object.- Specified by:
- refreshin interface- Refreshable
 
- 
getRefreshCountpublic long getRefreshCount()Description copied from interface:RefreshableReturn the number of actual refreshes since startup.- Specified by:
- getRefreshCountin interface- Refreshable
 
- 
getLastRefreshTimepublic long getLastRefreshTime()Description copied from interface:RefreshableReturn the last time an actual refresh happened (as timestamp).- Specified by:
- getLastRefreshTimein interface- Refreshable
 
- 
requiresRefreshprotected boolean requiresRefresh()Determine whether a refresh is required. Invoked for each refresh check, after the refresh check delay has elapsed.The default implementation always returns true, triggering a refresh every time the delay has elapsed. To be overridden by subclasses with an appropriate check of the underlying target resource.- Returns:
- whether a refresh is required
 
- 
freshTargetObtain a fresh target object.Only invoked if a refresh check has found that a refresh is required (that is, requiresRefresh()has returnedtrue).- Returns:
- the fresh target object
 
 
-