SemaphoreValve (Tomcat API Documentation)
Keywords: org.apache.catalina.valves.SemaphoreValve class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.valves
Class SemaphoreValve

    java.lang.Object
      org.apache.catalina.valves.ValveBase
          org.apache.catalina.valves.SemaphoreValve

All Implemented Interfaces:
  javax.management.MBeanRegistration, Contained, Lifecycle, Valve

    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.

Version:
  $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $
Author:
  Remy Maucherat

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

### semaphore

    protected java.util.concurrent.Semaphore semaphore

  Semaphore.

### lifecycle

    protected LifecycleSupport lifecycle

  The lifecycle event support for this component.

### concurrency

    protected int concurrency

  Concurrency level of the semaphore.

### fairness

    protected boolean fairness

  Fairness of the semaphore.

### block

    protected boolean block

  Block until a permit is available.

### interruptible

    protected boolean interruptible

  Block interruptibly until a permit is available.

Constructor Detail

### SemaphoreValve

    public SemaphoreValve()

Method Detail

### getConcurrency

    public int getConcurrency()

### setConcurrency

    public void setConcurrency(int concurrency)

### getFairness

    public boolean getFairness()

### setFairness

    public void setFairness(boolean fairness)

### getBlock

    public boolean getBlock()

### setBlock

    public void setBlock(boolean block)

### getInterruptible

    public boolean getInterruptible()

### setInterruptible

    public void setInterruptible(boolean interruptible)

### addLifecycleListener

    public void addLifecycleListener(LifecycleListener listener)

  Add a lifecycle event listener to this component.

  Specified by:
    `addLifecycleListener` in interface `Lifecycle`
  Parameters:
    `listener` - The listener to add

### findLifecycleListeners

    public LifecycleListener[] findLifecycleListeners()

  Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

  Specified by:
    `findLifecycleListeners` in interface `Lifecycle`

### removeLifecycleListener

    public void removeLifecycleListener(LifecycleListener listener)

  Remove a lifecycle event listener from this component.

  Specified by:
    `removeLifecycleListener` in interface `Lifecycle`
  Parameters:
    `listener` - The listener to add

### start

    public void start()
               throws LifecycleException

  Prepare for the beginning of active use of the public methods of this component. This method should be called after `configure()`, and before any of the public methods of the component are utilized.

  Specified by:
    `start` in interface `Lifecycle`
  Throws:
    `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### stop

    public void stop()
              throws LifecycleException

  Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.

  Specified by:
    `stop` in interface `Lifecycle`
  Throws:
    `LifecycleException` - if this component detects a fatal error that needs to be reported

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this Valve implementation.

  Specified by:
    `getInfo` in interface `Valve`
  Overrides:
    `getInfo` in class `ValveBase`

### invoke

    public void invoke(Request request,
                       Response response)
                throws java.io.IOException,
                       javax.servlet.ServletException

  Do concurrency control on the request using the semaphore.

  Specified by:
    `invoke` in interface `Valve`
  Specified by:
    `invoke` in class `ValveBase`
  Parameters:
    `request` - The servlet request to be processed
    `response` - The servlet response to be created
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

### controlConcurrency

    public boolean controlConcurrency(Request request,
                                      Response response)

  Subclass friendly method to add conditions.

### permitDenied

    public void permitDenied(Request request,
                             Response response)
                      throws java.io.IOException,
                             javax.servlet.ServletException

  Subclass friendly method to add error handling when a permit isn't granted.

  Throws:
    `java.io.IOException`
    `javax.servlet.ServletException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.