|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.catalina.valves.ValveBase org.apache.catalina.valves.SemaphoreValve
public class SemaphoreValve
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.
Field Summary | |
---|---|
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. |
Fields inherited from class org.apache.catalina.valves.ValveBase |
---|
container, containerLog, controller, domain, mserver, next, oname |
Fields inherited from interface org.apache.catalina.Lifecycle |
---|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT |
Constructor Summary | |
---|---|
SemaphoreValve()
|
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.catalina.valves.ValveBase |
---|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.concurrent.Semaphore semaphore
protected LifecycleSupport lifecycle
protected int concurrency
protected boolean fairness
protected boolean block
protected boolean interruptible
Constructor Detail |
---|
public SemaphoreValve()
Method Detail |
---|
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()
getInfo
in interface Valve
getInfo
in class ValveBase
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 created
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet error occurspublic boolean controlConcurrency(Request request, Response response)
public void permitDenied(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |