The Spring Framework

org.springframework.aop.target.dynamic
Class AbstractRefreshableTargetSource

java.lang.Object
  extended by 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 for explicit control.

Since:
2.0
Author:
Rod Johnson, Rob Harrop, Juergen Hoeller

Field Summary
protected  Log logger
          Logger available to subclasses
protected  Object targetObject
           
 
Constructor Summary
AbstractRefreshableTargetSource()
           
 
Method Summary
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 target class behind the implementing object (typically a proxy configuration or an actual proxy).
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Log logger
Logger available to subclasses


targetObject

protected Object targetObject
Constructor Detail

AbstractRefreshableTargetSource

public AbstractRefreshableTargetSource()
Method Detail

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() returns true.

See Also:
requiresRefresh()

getTargetClass

public Class getTargetClass()
Description copied from interface: TargetClassAware
Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).

Specified by:
getTargetClass in interface TargetClassAware
Specified by:
getTargetClass in interface TargetSource
Returns:
the target Class, or null if not known

isStatic

public boolean isStatic()
Not static.

Specified by:
isStatic in interface TargetSource
Returns:
true if the target is immutable
See Also:
TargetSource.getTarget()

getTarget

public final Object getTarget()
Description copied from interface: TargetSource
Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.

Specified by:
getTarget in interface TargetSource
Returns:
the target object, which contains the joinpoint

releaseTarget

public void releaseTarget(Object object)
No need to release target.

Specified by:
releaseTarget in interface TargetSource
Parameters:
object - object obtained from a call to TargetSource.getTarget()

refresh

public final void refresh()
Description copied from interface: Refreshable
Refresh the underlying target object.

Specified by:
refresh in interface Refreshable

getRefreshCount

public long getRefreshCount()
Description copied from interface: Refreshable
Return the number of actual refreshes since startup.

Specified by:
getRefreshCount in interface Refreshable

getLastRefreshTime

public long getLastRefreshTime()
Description copied from interface: Refreshable
Return the last time an actual refresh happened (as timestamp).

Specified by:
getLastRefreshTime in interface Refreshable

requiresRefresh

protected boolean requiresRefresh()
Determine whether a refresh is required. Invoked for each refresh check, after the refresh check delay has elapsed.

Default implementation always returns true, trigger a refresh every time the delay has elapsed. To be overridden by subclasses with an appropriate check of the underlying target resource.


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 returned true).

See Also:
requiresRefresh()

The Spring Framework

Copyright © 2002-2007 The Spring Framework.