Top Description Fields Constructors Methods
org.springframework.aop.target.dynamic

public abstract Class AbstractRefreshableTargetSource

extends Object
implements TargetSource, Refreshable
Class Inheritance
All Implemented Interfaces
org.springframework.aop.target.dynamic.Refreshable, org.springframework.aop.TargetSource, org.springframework.aop.TargetClassAware
Known Direct Subclasses
org.springframework.aop.target.dynamic.BeanFactoryRefreshableTargetSource
Imports
org.apache.commons.logging.Log, .LogFactory, org.springframework.aop.TargetSource, org.springframework.lang.Nullable

Abstract org.springframework.aop.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.

Authors
Rod Johnson, Rob Harrop, Juergen Hoeller
Since
2.0
See Also
requiresRefresh(), freshTarget()

Field Summary

Modifier and TypeField and Description
private long
private long
protected final Log
logger

Logger available to subclasses.

private long
private long
protected Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract Object

Returns:

the fresh target object
freshTarget
()

Obtain a fresh target object.

public synchronized long
getLastRefreshTime()

Implements org.springframework.aop.target.dynamic.Refreshable.getLastRefreshTime.

Return the last time an actual refresh happened (as timestamp).
public synchronized long
getRefreshCount()

Implements org.springframework.aop.target.dynamic.Refreshable.getRefreshCount.

Return the number of actual refreshes since startup.
public final synchronized Object
getTarget()

Implements org.springframework.aop.TargetSource.getTarget.

Return a target instance.
public synchronized Class<?>
getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

Return the type of targets returned by this TargetSource.
public final synchronized void
refresh()

Implements org.springframework.aop.target.dynamic.Refreshable.refresh.

Refresh the underlying target object.
private boolean
protected boolean

Returns:

whether a refresh is required
requiresRefresh
()

Determine whether a refresh is required.

public void
setRefreshCheckDelay(long refreshCheckDelay)

Set the delay between refresh checks, in milliseconds.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lastRefreshCheckback to summary
private long lastRefreshCheck
lastRefreshTimeback to summary
private long lastRefreshTime
loggerback to summary
protected final Log logger

Logger available to subclasses.

refreshCheckDelayback to summary
private long refreshCheckDelay
refreshCountback to summary
private long refreshCount
targetObjectback to summary
protected Object targetObject
Annotations
@Nullable

Constructor Detail

AbstractRefreshableTargetSourceback to summary
public AbstractRefreshableTargetSource()

Method Detail

freshTargetback to summary
protected abstract Object freshTarget()

Obtain a fresh target object.

Only invoked if a refresh check has found that a refresh is required (that is, requiresRefresh() has returned true).

Returns:Object

the fresh target object

getLastRefreshTimeback to summary
public synchronized long getLastRefreshTime()

Implements org.springframework.aop.target.dynamic.Refreshable.getLastRefreshTime.

Doc from org.springframework.aop.target.dynamic.Refreshable.getLastRefreshTime.

Return the last time an actual refresh happened (as timestamp).

Annotations
@Override
getRefreshCountback to summary
public synchronized long getRefreshCount()

Implements org.springframework.aop.target.dynamic.Refreshable.getRefreshCount.

Doc from org.springframework.aop.target.dynamic.Refreshable.getRefreshCount.

Return the number of actual refreshes since startup.

Annotations
@Override
getTargetback to summary
public final synchronized Object getTarget()

Implements org.springframework.aop.TargetSource.getTarget.

Doc from org.springframework.aop.TargetSource.getTarget.

Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.

Returns:Object

the target object which contains the joinpoint, or null if there is no actual target instance

Annotations
@Override
@Nullable
getTargetClassback to summary
public synchronized Class<?> getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

Doc from org.springframework.aop.TargetSource.getTargetClass.

Return the type of targets returned by this TargetSource.

Can return null, although certain usages of a TargetSource might just work with a predetermined target class.

Returns:Class<?>

the type of targets returned by this TargetSource

Annotations
@Override
refreshback to summary
public final synchronized void refresh()

Implements org.springframework.aop.target.dynamic.Refreshable.refresh.

Doc from org.springframework.aop.target.dynamic.Refreshable.refresh.

Refresh the underlying target object.

Annotations
@Override
refreshCheckDelayElapsedback to summary
private boolean refreshCheckDelayElapsed()
requiresRefreshback to summary
protected 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:boolean

whether a refresh is required

setRefreshCheckDelayback to summary
public 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() returns true.