类 AbstractRefreshableTargetSource
- java.lang.Object
- org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource
- 所有已实现的接口:
Refreshable,TargetClassAware,TargetSource
public abstract class AbstractRefreshableTargetSource extends Object implements TargetSource, Refreshable
AbstractTargetSourceimplementation that wraps a refreshable target object. Subclasses can determine whether a refresh is required, and need to provide fresh target objects.Implements the
Refreshableinterface in order to allow for explicit control over the refresh status.- 从以下版本开始:
- 2.0
- 作者:
- Rod Johnson, Rob Harrop, Juergen Hoeller
- 另请参阅:
requiresRefresh(),freshTarget()
字段概要
字段 修饰符和类型 字段 说明 protected LogloggerLogger available to subclasses.protected ObjecttargetObject
构造器概要
构造器 构造器 说明 AbstractRefreshableTargetSource()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract ObjectfreshTarget()Obtain a fresh target object.longgetLastRefreshTime()Return the last time an actual refresh happened (as timestamp).longgetRefreshCount()Return the number of actual refreshes since startup.ObjectgetTarget()Return a target instance.Class<?>getTargetClass()Return the type of targets returned by thisTargetSource.booleanisStatic()Not static.voidrefresh()Refresh the underlying target object.voidreleaseTarget(Object object)No need to release target.protected booleanrequiresRefresh()Determine whether a refresh is required.voidsetRefreshCheckDelay(long refreshCheckDelay)Set the delay between refresh checks, in milliseconds.
字段详细资料
targetObject
@Nullable protected Object targetObject
构造器详细资料
AbstractRefreshableTargetSource
public AbstractRefreshableTargetSource()
方法详细资料
setRefreshCheckDelay
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()returnstrue.
getTargetClass
public Class<?> getTargetClass()
从接口复制的说明:TargetSourceReturn the type of targets returned by thisTargetSource.Can return
null, although certain usages of aTargetSourcemight just work with a predetermined target class.- 指定者:
getTargetClass在接口中TargetClassAware- 指定者:
getTargetClass在接口中TargetSource- 返回:
- the type of targets returned by this
TargetSource
isStatic
public boolean isStatic()
Not static.- 指定者:
isStatic在接口中TargetSource- 返回:
trueif the target is immutable- 另请参阅:
TargetSource.getTarget()
getTarget
@Nullable public final Object getTarget()
从接口复制的说明:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- 指定者:
getTarget在接口中TargetSource- 返回:
- the target object which contains the joinpoint, or
nullif there is no actual target instance
releaseTarget
public void releaseTarget(Object object)
No need to release target.- 指定者:
releaseTarget在接口中TargetSource- 参数:
object- object obtained from a call toTargetSource.getTarget()
refresh
public final void refresh()
从接口复制的说明:RefreshablegetRefreshCount()从接口复制的说明:RefreshableReturn the number of actual refreshes since startup.- 指定者:
getRefreshCount在接口中Refreshable
getLastRefreshTime
public long getLastRefreshTime()
从接口复制的说明:RefreshableReturn the last time an actual refresh happened (as timestamp).- 指定者:
getLastRefreshTime在接口中Refreshable
requiresRefresh
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.- 返回:
- whether a refresh is required
freshTarget
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 returnedtrue).- 返回:
- the fresh target object