public abstract class

AbstractRefreshableTargetSource

extends Object
implements TargetSource Refreshable
java.lang.Object
   ↳ org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Summary

Fields
protected Log logger Logger available to subclasses
protected Object targetObject
Public Constructors
AbstractRefreshableTargetSource()
Public Methods
synchronized long getLastRefreshTime()
Return the last time an actual refresh happened (as timestamp).
synchronized long getRefreshCount()
Return the number of actual refreshes since startup.
synchronized final Object getTarget()
Return a target instance.
synchronized Class<?> getTargetClass()
Return the type of targets returned by this TargetSource.
boolean isStatic()
Not static.
synchronized final void refresh()
Refresh the underlying target object.
void releaseTarget(Object object)
No need to release target.
void setRefreshCheckDelay(long refreshCheckDelay)
Set the delay between refresh checks, in milliseconds.
Protected Methods
abstract Object freshTarget()
Obtain a fresh target object.
boolean requiresRefresh()
Determine whether a refresh is required.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.aop.TargetClassAware
From interface org.springframework.aop.TargetSource
From interface org.springframework.aop.target.dynamic.Refreshable

Fields

protected Log logger

Logger available to subclasses

protected Object targetObject

Public Constructors

public AbstractRefreshableTargetSource ()

Public Methods

public synchronized long getLastRefreshTime ()

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

public synchronized long getRefreshCount ()

Return the number of actual refreshes since startup.

public final synchronized Object getTarget ()

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

Returns
  • the target object, which contains the joinpoint

public synchronized Class<?> 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

public boolean isStatic ()

Not static.

Returns
  • true if the target is immutable

public final synchronized void refresh ()

Refresh the underlying target object.

public void releaseTarget (Object object)

No need to release target.

Parameters
object object obtained from a call to getTarget()

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.

Protected Methods

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
  • the fresh target object

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
  • whether a refresh is required