public abstract class

ConcurrencyThrottleSupport

extends Object
implements Serializable
java.lang.Object
   ↳ org.springframework.util.ConcurrencyThrottleSupport
Known Direct Subclasses

Class Overview

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!

The default concurrency limit of this support class is -1 ("unbounded concurrency"). Subclasses may override this default; check the javadoc of the concrete class that you're using.

Summary

Constants
int NO_CONCURRENCY Switch concurrency 'off': that is, don't allow any concurrent invocations.
int UNBOUNDED_CONCURRENCY Permit any number of concurrent invocations: that is, don't throttle concurrency.
Fields
protected Log logger Transient to optimize serialization
Public Constructors
ConcurrencyThrottleSupport()
Public Methods
int getConcurrencyLimit()
Return the maximum number of concurrent access attempts allowed.
boolean isThrottleActive()
Return whether this throttle is currently active.
void setConcurrencyLimit(int concurrencyLimit)
Set the maximum number of concurrent access attempts allowed.
Protected Methods
void afterAccess()
To be invoked after the main execution logic of concrete subclasses.
void beforeAccess()
To be invoked before the main execution logic of concrete subclasses.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int NO_CONCURRENCY

Also: SpringCore

Switch concurrency 'off': that is, don't allow any concurrent invocations.

Constant Value: 0 (0x00000000)

public static final int UNBOUNDED_CONCURRENCY

Also: SpringCore

Permit any number of concurrent invocations: that is, don't throttle concurrency.

Constant Value: -1 (0xffffffff)

Fields

protected Log logger

Also: SpringCore

Transient to optimize serialization

Public Constructors

public ConcurrencyThrottleSupport ()

Also: SpringCore

Public Methods

public int getConcurrencyLimit ()

Also: SpringCore

Return the maximum number of concurrent access attempts allowed.

public boolean isThrottleActive ()

Also: SpringCore

Return whether this throttle is currently active.

Returns
  • true if the concurrency limit for this instance is active

public void setConcurrencyLimit (int concurrencyLimit)

Also: SpringCore

Set the maximum number of concurrent access attempts allowed. -1 indicates unbounded concurrency.

In principle, this limit can be changed at runtime, although it is generally designed as a 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.

Protected Methods

protected void afterAccess ()

Also: SpringCore

To be invoked after the main execution logic of concrete subclasses.

See Also

protected void beforeAccess ()

Also: SpringCore

To be invoked before the main execution logic of concrete subclasses.

This implementation applies the concurrency throttle.

See Also