public abstract class AbstractRefreshableTargetSource extends Object implements TargetSource, Refreshable
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.
requiresRefresh(),
freshTarget()| 限定符和类型 | 字段和说明 |
|---|---|
protected Log |
logger
Logger available to subclasses
|
protected Object |
targetObject |
| 构造器和说明 |
|---|
AbstractRefreshableTargetSource() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract Object |
freshTarget()
Obtain a fresh target object.
|
long |
getLastRefreshTime()
Return the last time an actual refresh happened (as timestamp).
|
long |
getRefreshCount()
Return the number of actual refreshes since startup.
|
Object |
getTarget()
Return a target instance.
|
Class<?> |
getTargetClass()
Return the type of targets returned by this
TargetSource. |
boolean |
isStatic()
Not static.
|
void |
refresh()
Refresh the underlying target object.
|
void |
releaseTarget(Object object)
No need to release target.
|
protected boolean |
requiresRefresh()
Determine whether a refresh is required.
|
void |
setRefreshCheckDelay(long refreshCheckDelay)
Set the delay between refresh checks, in milliseconds.
|
protected final Log logger
@Nullable protected Object targetObject
public void setRefreshCheckDelay(long refreshCheckDelay)
Note that an actual refresh will only happen when
requiresRefresh() returns true.
public Class<?> getTargetClass()
TargetSourceTargetSource.
Can return null, although certain usages of a TargetSource
might just work with a predetermined target class.
getTargetClass 在接口中 TargetClassAwaregetTargetClass 在接口中 TargetSourceTargetSourcepublic boolean isStatic()
isStatic 在接口中 TargetSourcetrue if the target is immutableTargetSource.getTarget()@Nullable public final Object getTarget()
TargetSourcegetTarget 在接口中 TargetSourcenull if there is no actual target instancepublic void releaseTarget(Object object)
releaseTarget 在接口中 TargetSourceobject - object obtained from a call to TargetSource.getTarget()public final void refresh()
Refreshablerefresh 在接口中 Refreshablepublic long getRefreshCount()
RefreshablegetRefreshCount 在接口中 Refreshablepublic long getLastRefreshTime()
RefreshablegetLastRefreshTime 在接口中 Refreshableprotected boolean requiresRefresh()
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.
protected abstract Object freshTarget()
Only invoked if a refresh check has found that a refresh is required
(that is, requiresRefresh() has returned true).