org.springframework.util
Class ConcurrencyThrottleSupport

java.lang.Object
  extended by org.springframework.util.ConcurrencyThrottleSupport
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConcurrencyThrottleInterceptor

public abstract class ConcurrencyThrottleSupport
extends Object
implements Serializable

Support class for throttling concurrent access to a specific resource.

Designed for use as a base class, with the subclass invoking the beforeAccess and afterAccess methods at appropriate points of its workflow. Note that afterAccess should usually be called in a finally block!.

This class is designed for serializablility, to allow for serializing interceptors that derive from it. Note that the subclass needs to explicitly implement the Serializable marker interface if it is actually serializable.

Since:
1.2.5
Author:
Juergen Hoeller
See Also:
setConcurrencyLimit(int), beforeAccess(), afterAccess(), ConcurrencyThrottleInterceptor, Serializable, Serialized Form

Field Summary
protected  org.apache.commons.logging.Log logger
          Transient to optimize serialization
 
Constructor Summary
ConcurrencyThrottleSupport()
           
 
Method Summary
protected  void afterAccess()
          To be invoked after the main execution logic of concrete subclasses.
protected  void beforeAccess()
           
 int getConcurrencyLimit()
          Return the maximum number of parallel accesses allowed.
 boolean isThrottleActive()
          Return whether this throttle is currently active.
 void setConcurrencyLimit(int concurrencyLimit)
          Set the maximum number of parallel accesses allowed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected transient org.apache.commons.logging.Log logger
Transient to optimize serialization

Constructor Detail

ConcurrencyThrottleSupport

public ConcurrencyThrottleSupport()
Method Detail

setConcurrencyLimit

public void setConcurrencyLimit(int concurrencyLimit)
Set the maximum number of parallel accesses allowed. -1 indicates no concurrency limit at all. Default is 1.

This limit can in principle be changed at runtime, although it is generally designed as config time setting. NOTE: Do not switch between -1 and any concrete limit at runtime, as this will lead to inconsistent concurrency counts: A limit of -1 effectively turns off concurrency counting completely.


getConcurrencyLimit

public int getConcurrencyLimit()
Return the maximum number of parallel accesses allowed.


isThrottleActive

public boolean isThrottleActive()
Return whether this throttle is currently active.


beforeAccess

protected void beforeAccess()

afterAccess

protected void afterAccess()
To be invoked after the main execution logic of concrete subclasses.

See Also:
beforeAccess()


Copyright (c) 2002-2006 The Spring Framework Project.