Apache Tomcat 7.0.37

org.apache.catalina.valves
Class ValveBase

java.lang.Object
  extended by org.apache.catalina.util.LifecycleBase
      extended by org.apache.catalina.util.LifecycleMBeanBase
          extended by org.apache.catalina.valves.ValveBase
All Implemented Interfaces:
MBeanRegistration, Contained, Lifecycle, Valve
Direct Known Subclasses:
AccessLogValve, AuthenticatorBase, CometConnectionManagerValve, CrawlerSessionManagerValve, ErrorReportValve, JDBCAccessLogValve, JvmRouteBinderValve, PersistentValve, RemoteIpValve, ReplicationValve, RequestFilterValve, SemaphoreValve, SingleSignOn, SSLValve, StuckThreadDetectionValve

public abstract class ValveBase
extends LifecycleMBeanBase
implements Contained, Valve

Convenience base class for implementations of the Valve interface. A subclass MUST implement an invoke() method to provide the required functionality, and MAY implement the Lifecycle interface to provide configuration management and lifecycle support.

Version:
$Id: ValveBase.java 1187022 2011-10-20 19:55:37Z markt $
Author:
Craig R. McClanahan

Field Summary
protected  boolean asyncSupported
          Does this valve support Servlet 3+ async requests?
protected  Container container
          The Container whose pipeline this Valve is a component of.
protected  Log containerLog
          Container log
protected static String info
          Descriptive information about this Valve implementation.
protected  Valve next
          The next Valve in the pipeline this Valve is a component of.
protected static StringManager sm
          The string manager for this package.
 
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
ValveBase()
           
ValveBase(boolean asyncSupported)
           
 
Method Summary
 void backgroundProcess()
          Execute a periodic task, such as reloading, etc.
 void event(Request request, Response response, CometEvent event)
          Process a Comet event.
 Container getContainer()
          Return the Container with which this Valve is associated, if any.
 String getDomainInternal()
          Method implemented by sub-classes to identify the domain in which MBeans should be registered.
 String getInfo()
          Return descriptive information about this Valve implementation.
 Valve getNext()
          Return the next Valve in this pipeline, or null if this is the last Valve in the pipeline.
 String getObjectNameKeyProperties()
          Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.
protected  void initInternal()
          Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.
abstract  void invoke(Request request, Response response)
          The implementation-specific logic represented by this Valve.
 boolean isAsyncSupported()
           
 void setAsyncSupported(boolean asyncSupported)
           
 void setContainer(Container container)
          Set the Container with which this Valve is associated, if any.
 void setNext(Valve valve)
          Set the Valve that follows this one in the pipeline it is part of.
protected  void startInternal()
          Start this component and implement the requirements of LifecycleBase.startInternal().
protected  void stopInternal()
          Stop this component and implement the requirements of LifecycleBase.stopInternal().
 String toString()
          Return a String rendering of this object.
 
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
 
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

asyncSupported

protected boolean asyncSupported
Does this valve support Servlet 3+ async requests?


container

protected Container container
The Container whose pipeline this Valve is a component of.


containerLog

protected Log containerLog
Container log


info

protected static final String info
Descriptive information about this Valve implementation. This value should be overridden by subclasses.

See Also:
Constant Field Values

next

protected Valve next
The next Valve in the pipeline this Valve is a component of.


sm

protected static final StringManager sm
The string manager for this package.

Constructor Detail

ValveBase

public ValveBase()

ValveBase

public ValveBase(boolean asyncSupported)
Method Detail

getContainer

public Container getContainer()
Return the Container with which this Valve is associated, if any.

Specified by:
getContainer in interface Contained

isAsyncSupported

public boolean isAsyncSupported()
Specified by:
isAsyncSupported in interface Valve

setAsyncSupported

public void setAsyncSupported(boolean asyncSupported)

setContainer

public void setContainer(Container container)
Set the Container with which this Valve is associated, if any.

Specified by:
setContainer in interface Contained
Parameters:
container - The new associated container

getInfo

public String getInfo()
Return descriptive information about this Valve implementation.

Specified by:
getInfo in interface Valve

getNext

public Valve getNext()
Return the next Valve in this pipeline, or null if this is the last Valve in the pipeline.

Specified by:
getNext in interface Valve

setNext

public void setNext(Valve valve)
Set the Valve that follows this one in the pipeline it is part of.

Specified by:
setNext in interface Valve
Parameters:
valve - The new next valve

backgroundProcess

public void backgroundProcess()
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.

Specified by:
backgroundProcess in interface Valve

invoke

public abstract void invoke(Request request,
                            Response response)
                     throws IOException,
                            ServletException
The implementation-specific logic represented by this Valve. See the Valve description for the normal design patterns for this method.

This method MUST be provided by a subclass.

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

event

public void event(Request request,
                  Response response,
                  CometEvent event)
           throws IOException,
                  ServletException
Process a Comet event. This method will rarely need to be provided by a subclass, unless it needs to reassociate a particular object with the thread that is processing the request.

Specified by:
event in interface Valve
Parameters:
request - The servlet request to be processed
response - The servlet response to be created
Throws:
IOException - if an input/output error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servlet
ServletException - if a servlet error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servlet

initInternal

protected void initInternal()
                     throws LifecycleException
Description copied from class: LifecycleMBeanBase
Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.

Overrides:
initInternal in class LifecycleMBeanBase
Throws:
LifecycleException

startInternal

protected void startInternal()
                      throws LifecycleException
Start this component and implement the requirements of LifecycleBase.startInternal().

Specified by:
startInternal in class LifecycleBase
Throws:
LifecycleException - if this component detects a fatal error that prevents this component from being used

stopInternal

protected void stopInternal()
                     throws LifecycleException
Stop this component and implement the requirements of LifecycleBase.stopInternal().

Specified by:
stopInternal in class LifecycleBase
Throws:
LifecycleException - if this component detects a fatal error that prevents this component from being used

toString

public String toString()
Return a String rendering of this object.

Overrides:
toString in class Object

getObjectNameKeyProperties

public String getObjectNameKeyProperties()
Description copied from class: LifecycleMBeanBase
Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

Specified by:
getObjectNameKeyProperties in class LifecycleMBeanBase
Returns:
The string representation of the key properties component of the desired ObjectName

getDomainInternal

public String getDomainInternal()
Description copied from class: LifecycleMBeanBase
Method implemented by sub-classes to identify the domain in which MBeans should be registered.

Specified by:
getDomainInternal in class LifecycleMBeanBase
Returns:
The name of the domain to use to register MBeans.

Apache Tomcat 7.0.37

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