Package org.apache.catalina.valves
Class ValveBase
- java.lang.Object
-
- org.apache.catalina.valves.ValveBase
-
- All Implemented Interfaces:
Contained
,Lifecycle
,Valve
,GlassFishValve
- Direct Known Subclasses:
AccessLogValve
,AuthenticatorBase
,ErrorReportValve
,ExtendedAccessLogValve
,HASessionStoreValve
,JDBCAccessLogValve
,PEAccessLogValve
,PersistentValve
,RequestDumperValve
,RequestFilterValve
,SingleSignOn
,WebdavFixValve
public abstract class ValveBase extends Object implements Contained, Lifecycle, Valve, GlassFishValve
Convenience base class for implementations of the Valve interface. A subclass MUST implement aninvoke()
method to provide the required functionality, and MAY implement theLifecycle
interface to provide configuration management and lifecycle support.- Version:
- $Revision: 1.7 $ $Date: 2007/05/05 05:32:41 $
- Author:
- Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description protected Container
container
The Container whose pipeline this Valve is a component of.protected ObjectName
controller
protected int
debug
The debugging detail level for this component.protected String
domain
protected static String
info
Descriptive information about this Valve implementation.protected LifecycleSupport
lifecycle
The lifecycle event support for this component.protected static Logger
log
protected Valve
next
The next Valve in the pipeline this Valve is a component of.protected ObjectName
oname
protected static ResourceBundle
rb
protected boolean
started
Has this component been started yet?-
Fields inherited from interface org.glassfish.web.valve.GlassFishValve
END_PIPELINE, INVOKE_NEXT
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description ValveBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.void
backgroundProcess()
Execute a periodic task, such as reloading, etc.ObjectName
createObjectName(String domain, ObjectName parent)
void
event(Request request, Response response, CometEvent event)
Process a Comet event.List<LifecycleListener>
findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this Valve.Container
getContainer()
Return the Container with which this Valve is associated, if any.ObjectName
getController()
int
getDebug()
Return the debugging detail level for this component.String
getDomain()
String
getInfo()
Return descriptive information about this Valve implementation.Valve
getNext()
Return the next Valve in this pipeline, ornull
if this is the last Valve in the pipeline.ObjectName
getObjectName()
ObjectName
getParentName(ObjectName valveName)
From the name, extract the parent object namevoid
invoke(Request request, Response response)
Tomcat-style invocation.abstract int
invoke(Request request, Response response)
The implementation-specific logic represented by this Valve.boolean
isStarted()
void
postInvoke(Request request, Response response)
A post-request processing implementation that does nothing.void
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.void
setContainer(Container container)
Set the Container with which this Valve is associated, if any.void
setController(ObjectName controller)
void
setDebug(int debug)
Set the debugging detail level for this component.void
setNext(Valve valve)
Set the Valve that follows this one in the pipeline it is part of.void
setObjectName(ObjectName oname)
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.
-
-
-
Field Detail
-
log
protected static final Logger log
-
rb
protected static final ResourceBundle rb
-
container
protected Container container
The Container whose pipeline this Valve is a component of.
-
debug
protected int debug
The debugging detail level for this component.
-
started
protected boolean started
Has this component been started yet?
-
lifecycle
protected LifecycleSupport lifecycle
The lifecycle event support for this component.
-
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.
-
domain
protected String domain
-
oname
protected ObjectName oname
-
controller
protected ObjectName controller
-
-
Method Detail
-
getContainer
public Container getContainer()
Return the Container with which this Valve is associated, if any.- Specified by:
getContainer
in interfaceContained
-
setContainer
public void setContainer(Container container)
Set the Container with which this Valve is associated, if any.- Specified by:
setContainer
in interfaceContained
- Parameters:
container
- The new associated container
-
getDebug
public int getDebug()
Return the debugging detail level for this component.
-
setDebug
public void setDebug(int debug)
Set the debugging detail level for this component.- Parameters:
debug
- The new debugging detail level
-
getInfo
public String getInfo()
Return descriptive information about this Valve implementation.- Specified by:
getInfo
in interfaceGlassFishValve
- Specified by:
getInfo
in interfaceValve
-
getNext
public Valve getNext()
Return the next Valve in this pipeline, ornull
if this is the last Valve in the pipeline.
-
setNext
public void setNext(Valve valve)
Set the Valve that follows this one in the pipeline it is part of.
-
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 interfaceValve
-
invoke
public abstract int invoke(Request request, Response response) throws IOException, jakarta.servlet.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 interfaceGlassFishValve
- Parameters:
request
- The servlet request to be processedresponse
- The servlet response to be created- Returns:
INVOKE_NEXT
orEND_PIPELINE
- Throws:
IOException
- if an input/output error occursjakarta.servlet.ServletException
- if a servlet error occurs
-
postInvoke
public void postInvoke(Request request, Response response) throws IOException, jakarta.servlet.ServletException
A post-request processing implementation that does nothing. Very few Valves override this behaviour as most Valve logic is used for request processing.- Specified by:
postInvoke
in interfaceGlassFishValve
- Parameters:
request
- The servlet request to be processedresponse
- The servlet response to be created- Throws:
IOException
- if an input/output error occursjakarta.servlet.ServletException
- if a servlet error occurs
-
invoke
public void invoke(Request request, Response response) throws IOException, jakarta.servlet.ServletException
Tomcat-style invocation.- Specified by:
invoke
in interfaceValve
- Parameters:
request
- The servlet request to be processedresponse
- The servlet response to be created- Throws:
IOException
- if an input/output error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servletjakarta.servlet.ServletException
- if a servlet error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servlet
-
event
public void event(Request request, Response response, CometEvent event) throws IOException, jakarta.servlet.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 interfaceValve
- Parameters:
request
- The servlet request to be processedresponse
- The servlet response to be created- Throws:
IOException
- if an input/output error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servletjakarta.servlet.ServletException
- if a servlet error occurs, or is thrown by a subsequently invoked Valve, Filter, or Servlet
-
isStarted
public boolean isStarted()
- Returns:
- true if this access log valve has been started, false otherwise.
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListener
in interfaceLifecycle
- Parameters:
listener
- The listener to add
-
findLifecycleListeners
public List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this Valve.- Specified by:
findLifecycleListeners
in interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListener
in interfaceLifecycle
- 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 afterconfigure()
, and before any of the public methods of the component are utilized.- Specified by:
start
in interfaceLifecycle
- 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 interfaceLifecycle
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
getObjectName
public ObjectName getObjectName()
-
setObjectName
public void setObjectName(ObjectName oname)
-
getDomain
public String getDomain()
-
getController
public ObjectName getController()
-
setController
public void setController(ObjectName controller)
-
getParentName
public ObjectName getParentName(ObjectName valveName)
From the name, extract the parent object name- Parameters:
valveName
-- Returns:
- parentName
-
createObjectName
public ObjectName createObjectName(String domain, ObjectName parent) throws MalformedObjectNameException
- Throws:
MalformedObjectNameException
-
-