Class StandardPipeline
- java.lang.Object
-
- org.apache.catalina.core.StandardPipeline
-
- Direct Known Subclasses:
VirtualServerPipeline
,WebPipeline
public class StandardPipeline extends Object implements Pipeline, Contained, Lifecycle
Standard implementation of a processing Pipeline that will invoke a series of Valves that have been configured to be called in order. This implementation can be used for any type of Container. IMPLEMENTATION WARNING - This implementation assumes that no calls toaddValve()
orremoveValve
are allowed while a request is currently being processed. Otherwise, the mechanism by which per-thread state is maintained will need to be modified.- Author:
- Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description protected GlassFishValve
basic
The basic Valve (if any) associated with this Pipeline.protected Container
container
The Container with which this Pipeline is associated.protected static String
info
Descriptive information about this implementation.protected LifecycleSupport
lifecycle
The lifecycle event support for this component.protected boolean
started
Has this component been started yet?protected GlassFishValve[]
valves
The set of Valves (not including the Basic one, if any) associated with this Pipeline.-
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 StandardPipeline()
Construct a new StandardPipeline instance with no associated Container.StandardPipeline(Container container)
Construct a new StandardPipeline instance that is associated with the specified Container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.void
addValve(Valve valve)
Add Tomcat-style valve.void
addValve(GlassFishValve valve)
Add a new Valve to the end of the pipeline associated with this Container.void
doChainInvoke(Request request, Response response)
List<LifecycleListener>
findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this Pipeline.GlassFishValve
getBasic()
Return the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any).Container
getContainer()
Return the Container with which this Pipeline is associated.String
getInfo()
Return descriptive information about this implementation class.ObjectName[]
getValveObjectNames()
GlassFishValve[]
getValves()
Return the set of Valves in the pipeline associated with this Container, including the basic Valve (if any).boolean
hasNonBasicValves()
void
invoke(Request request, Response response)
Cause the specified request and response to be processed by the Valves associated with this pipeline, until one of these valves causes the response to be created and returned.protected void
log(String message)
Log a message on the Logger associated with our Container (if any).protected void
log(String message, Throwable t)
Logs the given message to the Logger associated with the Container (if any) of this StandardPipeline.void
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.void
removeValve(GlassFishValve valve)
Remove the specified Valve from the pipeline associated with this Container, if it is found; otherwise, do nothing.void
setBasic(GlassFishValve valve)
Set the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any).void
setContainer(Container container)
Set the Container with which this Pipeline is associated.void
start()
Prepare for active use of the public methods of this Component.void
stop()
Gracefully shut down active use of the public methods of this Component.
-
-
-
Field Detail
-
basic
protected GlassFishValve basic
The basic Valve (if any) associated with this Pipeline.
-
container
protected Container container
The Container with which this Pipeline is associated.
-
info
protected static final String info
Descriptive information about this implementation.- See Also:
- Constant Field Values
-
lifecycle
protected LifecycleSupport lifecycle
The lifecycle event support for this component.
-
started
protected boolean started
Has this component been started yet?
-
valves
protected GlassFishValve[] valves
The set of Valves (not including the Basic one, if any) associated with this Pipeline.
-
-
Constructor Detail
-
StandardPipeline
public StandardPipeline()
Construct a new StandardPipeline instance with no associated Container.
-
StandardPipeline
public StandardPipeline(Container container)
Construct a new StandardPipeline instance that is associated with the specified Container.- Parameters:
container
- The container we should be associated with
-
-
Method Detail
-
getInfo
public String getInfo()
Return descriptive information about this implementation class.
-
getContainer
public Container getContainer()
Return the Container with which this Pipeline is associated.- Specified by:
getContainer
in interfaceContained
-
setContainer
public void setContainer(Container container)
Set the Container with which this Pipeline is associated.- Specified by:
setContainer
in interfaceContained
- Parameters:
container
- The new associated container
-
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 Pipeline.- 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 remove
-
start
public void start() throws LifecycleException
Prepare for active use of the public methods of this Component.- Specified by:
start
in interfaceLifecycle
- Throws:
IllegalStateException
- if this component has already been startedLifecycleException
- if this component detects a fatal error that prevents it from being started
-
stop
public void stop() throws LifecycleException
Gracefully shut down active use of the public methods of this Component.- Specified by:
stop
in interfaceLifecycle
- Throws:
IllegalStateException
- if this component has not been startedLifecycleException
- if this component detects a fatal error that needs to be reported
-
getBasic
public GlassFishValve getBasic()
Return the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any).
-
setBasic
public void setBasic(GlassFishValve valve)
Set the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any). Prior to setting the basic Valve, the Valve's
setContainer()
will be called, if it implementsContained
, with the owning Container as an argument. The method may throw anIllegalArgumentException
if this Valve chooses not to be associated with this Container, orIllegalStateException
if it is already associated with a different Container.
-
addValve
public void addValve(GlassFishValve valve)
Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the Valve, the Valve's
setContainer()
method will be called, if it implementsContained
, with the owning Container as an argument. The method may throw anIllegalArgumentException
if this Valve chooses not to be associated with this Container, orIllegalStateException
if it is already associated with a different Container.- Specified by:
addValve
in interfacePipeline
- Parameters:
valve
- Valve to be added- Throws:
IllegalArgumentException
- if this Container refused to accept the specified ValveIllegalArgumentException
- if the specified Valve refuses to be associated with this ContainerIllegalStateException
- if the specified Valve is already associated with a different Container
-
addValve
public void addValve(Valve valve)
Add Tomcat-style valve.
-
getValves
public GlassFishValve[] getValves()
Return the set of Valves in the pipeline associated with this Container, including the basic Valve (if any). If there are no such Valves, a zero-length array is returned.
-
hasNonBasicValves
public boolean hasNonBasicValves()
- Specified by:
hasNonBasicValves
in interfacePipeline
- Returns:
- true if this pipeline has any non basic valves, false otherwise
-
getValveObjectNames
public ObjectName[] getValveObjectNames()
-
invoke
public void invoke(Request request, Response response) throws IOException, jakarta.servlet.ServletException
Cause the specified request and response to be processed by the Valves associated with this pipeline, until one of these valves causes the response to be created and returned. The implementation must ensure that multiple simultaneous requests (on different threads) can be processed through the same Pipeline without interfering with each other's control flow.- Specified by:
invoke
in interfacePipeline
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating- Throws:
IOException
- if an input/output error occursjakarta.servlet.ServletException
- if a servlet exception is thrown
-
doChainInvoke
public void doChainInvoke(Request request, Response response) throws IOException, jakarta.servlet.ServletException
- Throws:
IOException
jakarta.servlet.ServletException
-
removeValve
public void removeValve(GlassFishValve valve)
Remove the specified Valve from the pipeline associated with this Container, if it is found; otherwise, do nothing. If the Valve is found and removed, the Valve'ssetContainer(null)
method will be called if it implementsContained
.- Specified by:
removeValve
in interfacePipeline
- Parameters:
valve
- Valve to be removed
-
log
protected void log(String message)
Log a message on the Logger associated with our Container (if any).- Parameters:
message
- Message to be logged
-
-