org.apache.catalina.valves
public class SemaphoreValve extends ValveBase implements Lifecycle
Implementation of a Valve that limits concurrency.
This Valve may be attached to any Container, depending on the granularity of the concurrency control you wish to perform.
Modifier and Type | Field and Description |
---|---|
protected boolean |
block
Block until a permit is available.
|
protected int |
concurrency
Concurrency level of the semaphore.
|
protected boolean |
fairness
Fairness of the semaphore.
|
protected boolean |
interruptible
Block interruptibly until a permit is available.
|
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component.
|
protected java.util.concurrent.Semaphore |
semaphore
Semaphore.
|
container, containerLog, controller, domain, mserver, next, oname
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
SemaphoreValve() |
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
|
boolean |
controlConcurrency(Request request,
Response response)
Subclass friendly method to add conditions.
|
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
|
boolean |
getBlock() |
int |
getConcurrency() |
boolean |
getFairness() |
java.lang.String |
getInfo()
Return descriptive information about this Valve implementation.
|
boolean |
getInterruptible() |
void |
invoke(Request request,
Response response)
Do concurrency control on the request using the semaphore.
|
void |
permitDenied(Request request,
Response response)
Subclass friendly method to add error handling when a permit isn't granted.
|
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
|
void |
setBlock(boolean block) |
void |
setConcurrency(int concurrency) |
void |
setFairness(boolean fairness) |
void |
setInterruptible(boolean interruptible) |
void |
start()
Prepare for the beginning of active use of the public methods of this
component.
|
void |
stop()
Gracefully terminate the active use of the public methods of this
component.
|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString
protected java.util.concurrent.Semaphore semaphore
protected LifecycleSupport lifecycle
protected int concurrency
protected boolean fairness
protected boolean block
protected boolean interruptible
public int getConcurrency()
public void setConcurrency(int concurrency)
public boolean getFairness()
public void setFairness(boolean fairness)
public boolean getBlock()
public void setBlock(boolean block)
public boolean getInterruptible()
public void setInterruptible(boolean interruptible)
public void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic void start() throws LifecycleException
configure()
,
and before any of the public methods of the component are utilized.start
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that needs to be reportedpublic java.lang.String getInfo()
public void invoke(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
invoke
in interface Valve
invoke
in class ValveBase
request
- The servlet request to be processedresponse
- The servlet response to be createdjava.io.IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet error occurspublic boolean controlConcurrency(Request request, Response response)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.