Fields Summary |
---|
private static com.sun.org.apache.commons.logging.Log | log |
protected org.apache.catalina.Valve | basicThe basic Valve (if any) associated with this Pipeline. |
protected org.apache.catalina.Container | containerThe Container with which this Pipeline is associated. |
protected int | debugThe debugging detail level for this component. |
protected String | infoDescriptive information about this implementation. |
protected org.apache.catalina.util.LifecycleSupport | lifecycleThe lifecycle event support for this component. |
protected static final org.apache.catalina.util.StringManager | smThe string manager for this package. |
protected boolean | startedHas this component been started yet? |
protected org.apache.catalina.Valve[] | valvesThe set of Valves (not including the Basic one, if any) associated with
this Pipeline. |
Methods Summary |
---|
public void | addLifecycleListener(org.apache.catalina.LifecycleListener listener)Add a lifecycle event listener to this component.
lifecycle.addLifecycleListener(listener);
|
public void | addValve(org.apache.catalina.Valve 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 implements
Contained , with the owning Container as an argument.
The method may throw an
IllegalArgumentException if this Valve chooses not to
be associated with this Container, or IllegalStateException
if it is already associated with a different Container.
// Validate that we can add this Valve
if (valve instanceof Contained)
((Contained) valve).setContainer(this.container);
// Start the new component if necessary
if (started) {
if (valve instanceof Lifecycle) {
try {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error("StandardPipeline.addValve: start: ", e);
}
}
/** CR 6411114 (MBean registration moved to ValveBase.start())
// Register the newly added valve
registerValve(valve);
*/
}
// Add this Valve to the set associated with this Pipeline
synchronized (valves) {
Valve results[] = new Valve[valves.length +1];
System.arraycopy(valves, 0, results, 0, valves.length);
results[valves.length] = valve;
valves = results;
}
|
protected void | doChainInvoke(org.apache.catalina.Request request, org.apache.catalina.Response response)
doInvoke(request, response, true);
|
protected void | doInvoke(org.apache.catalina.Request request, org.apache.catalina.Response response)
doInvoke(request, response, false);
|
private void | doInvoke(org.apache.catalina.Request request, org.apache.catalina.Response response, boolean chaining)
// END PWC 4665318
// START OF IASRI 4665318
if ((valves.length > 0) || (basic != null)) {
// Set the status so that if there are no valves (other than the
// basic one), the basic valve's request processing logic will
// be invoked
int status = Valve.INVOKE_NEXT;
// Iterate over all the valves in the pipeline and invoke
// each valve's processing logic and then move onto to the
// next valve in the pipeline only if the previous valve indicated
// that the pipeline should proceed.
int i;
for (i = 0; i < valves.length; i++) {
Request req = request;
Response resp = response;
if (chaining) {
req = getRequest(request);
resp = getResponse(request, response);
}
status = valves[i].invoke(req, resp);
if (status != Valve.INVOKE_NEXT)
break;
}
// Save a reference to the valve[], to ensure that postInvoke()
// is invoked on the original valve[], in case a valve gets added
// or removed during the invocation of the basic valve (e.g.,
// in case access logging is enabled or disabled by some kind of
// admin servlet), in which case the indices used for postInvoke
// invocations below would be off
Valve[] savedValves = valves;
// Invoke the basic valve's request processing and post-request
// logic only if the pipeline was not aborted (i.e. no valve
// returned END_PIPELINE)
if ((status == Valve.INVOKE_NEXT) && (basic != null)) {
Request req = request;
Response resp = response;
if (chaining) {
req = getRequest(request);
resp = getResponse(request, response);
}
basic.invoke(req, resp);
basic.postInvoke(req, resp);
}
// Invoke the post-request processing logic only on those valves
// that returned a status of INVOKE_NEXT
for (int j = i - 1; j >= 0; j--) {
Request req = request;
Response resp = response;
if (chaining) {
req = getRequest(request);
resp = getResponse(request, response);
}
savedValves[j].postInvoke(req, resp);
}
savedValves = null;
} else {
throw new ServletException
(sm.getString("standardPipeline.noValve"));
}
// END OF IASRI 4665318
|
public org.apache.catalina.LifecycleListener[] | findLifecycleListeners()Get the lifecycle listeners associated with this lifecycle. If this
Lifecycle has no listeners registered, a zero-length array is returned.
return lifecycle.findLifecycleListeners();
|
public org.apache.catalina.Valve | getBasic()Return the Valve instance that has been distinguished as the basic
Valve for this Pipeline (if any).
return (this.basic);
|
public org.apache.catalina.Container | getContainer()Return the Container with which this Pipeline is associated.
return (this.container);
|
public java.lang.String | getInfo()Return descriptive information about this implementation class.
// --------------------------------------------------------- Public Methods
return (this.info);
|
private org.apache.catalina.Request | getRequest(org.apache.catalina.Request request)
Request r = (Request)
request.getNote(Globals.WRAPPED_REQUEST);
if (r == null) {
r = request;
}
return r;
|
private org.apache.catalina.Response | getResponse(org.apache.catalina.Request request, org.apache.catalina.Response response)
Response r = (Response)
request.getNote(Globals.WRAPPED_RESPONSE);
if (r == null) {
r = response;
}
return r;
|
public javax.management.ObjectName[] | getValveObjectNames()
ObjectName oname[]=new ObjectName[valves.length + 1];
for( int i=0; i<valves.length; i++ ) {
if( valves[i] instanceof ValveBase )
oname[i]=((ValveBase)valves[i]).getObjectName();
}
if( basic instanceof ValveBase )
oname[valves.length]=((ValveBase)basic).getObjectName();
return oname;
|
public org.apache.catalina.Valve[] | 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.
if (basic == null)
return (valves);
synchronized (valves) {
Valve results[] = new Valve[valves.length + 1];
System.arraycopy(valves, 0, results, 0, valves.length);
results[valves.length] = basic;
return (results);
}
|
public void | invoke(org.apache.catalina.Request request, org.apache.catalina.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. 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.
// START PWC 4665318
doInvoke(request, response);
|
protected void | log(java.lang.String message)Log a message on the Logger associated with our Container (if any).
Logger logger = null;
if (container != null)
logger = container.getLogger();
if (logger != null)
logger.log("StandardPipeline[" + container.getName() + "]: " +
message);
else
System.out.println("StandardPipeline[" + container.getName() +
"]: " + message);
|
protected void | log(java.lang.String message, java.lang.Throwable throwable)Log a message on the Logger associated with our Container (if any).
Logger logger = null;
if (container != null)
logger = container.getLogger();
if (logger != null)
logger.log("StandardPipeline[" + container.getName() + "]: " +
message, throwable);
else {
System.out.println("StandardPipeline[" + container.getName() +
"]: " + message);
throwable.printStackTrace(System.out);
}
|
public void | removeLifecycleListener(org.apache.catalina.LifecycleListener listener)Remove a lifecycle event listener from this component.
lifecycle.removeLifecycleListener(listener);
|
public void | removeValve(org.apache.catalina.Valve 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's setContainer(null) method
will be called if it implements Contained .
synchronized (valves) {
// Locate this Valve in our list
int j = -1;
for (int i = 0; i < valves.length; i++) {
if (valve == valves[i]) {
j = i;
break;
}
}
if (j < 0)
return;
// Remove this valve from our list
Valve results[] = new Valve[valves.length - 1];
int n = 0;
for (int i = 0; i < valves.length; i++) {
if (i == j)
continue;
results[n++] = valves[i];
}
valves = results;
try {
if (valve instanceof Contained)
((Contained) valve).setContainer(null);
} catch (Throwable t) {
;
}
}
// Stop this valve if necessary
if (started) {
if (valve instanceof Lifecycle) {
try {
((Lifecycle) valve).stop();
} catch (LifecycleException e) {
log.error("StandardPipeline.removeValve: stop: ", e);
}
}
/** CR 6411114 (MBean deregistration moved to ValveBase.stop())
// Unregister the removed valave
unregisterValve(valve);
*/
}
|
public void | setBasic(org.apache.catalina.Valve valve)Set the Valve instance that has been distinguished as the basic
Valve for this Pipeline (if any). Prioer to setting the basic Valve,
the Valve's setContainer() will be called, if it
implements Contained , with the owning Container as an
argument. The method may throw an IllegalArgumentException
if this Valve chooses not to be associated with this Container, or
IllegalStateException if it is already associated with
a different Container.
// Change components if necessary
Valve oldBasic = this.basic;
if (oldBasic == valve)
return;
// Stop the old component if necessary
if (oldBasic != null) {
if (started && (oldBasic instanceof Lifecycle)) {
try {
((Lifecycle) oldBasic).stop();
} catch (LifecycleException e) {
log.error("StandardPipeline.setBasic: stop", e);
}
}
if (oldBasic instanceof Contained) {
try {
((Contained) oldBasic).setContainer(null);
} catch (Throwable t) {
;
}
}
}
// Start the new component if necessary
if (valve == null)
return;
if (valve instanceof Contained) {
((Contained) valve).setContainer(this.container);
}
/** CR 6411114
if (valve instanceof Lifecycle) {
*/
// START CR 6411114
// Start the valve if the pipeline has already been started
if (started && (valve instanceof Lifecycle)) {
// END CR 6411114
try {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error("StandardPipeline.setBasic: start", e);
return;
}
}
this.basic = valve;
|
public void | setContainer(org.apache.catalina.Container container)Set the Container with which this Pipeline is associated.
this.container = container;
|
public synchronized void | start()Prepare for active use of the public methods of this Component.
// Validate and update our current component state
if (started)
throw new LifecycleException
(sm.getString("standardPipeline.alreadyStarted"));
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
started = true;
// Start the Valves in our pipeline (including the basic), if any
for (int i = 0; i < valves.length; i++) {
if (valves[i] instanceof Lifecycle)
((Lifecycle) valves[i]).start();
/** CR 6411114 (MBean registration moved to ValveBase.start())
registerValve(valves[i]);
*/
}
if ((basic != null) && (basic instanceof Lifecycle))
((Lifecycle) basic).start();
/** CR 6411114 (MBean registration moved to ValveBase.start())
if( basic!=null )
registerValve(basic);
*/
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(START_EVENT, null);
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
|
public synchronized void | stop()Gracefully shut down active use of the public methods of this Component.
// Validate and update our current component state
if (!started)
throw new LifecycleException
(sm.getString("standardPipeline.notStarted"));
started = false;
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(STOP_EVENT, null);
// Stop the Valves in our pipeline (including the basic), if any
if ((basic != null) && (basic instanceof Lifecycle))
((Lifecycle) basic).stop();
/** CR 6411114 (MBean deregistration moved to ValveBase.stop())
if( basic!=null ) {
unregisterValve(basic);
}
*/
for (int i = 0; i < valves.length; i++) {
if (valves[i] instanceof Lifecycle)
((Lifecycle) valves[i]).stop();
/** CR 6411114 (MBean deregistration moved to ValveBase.stop())
unregisterValve(valves[i]);
*/
}
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
|