Search in sources :

Example 41 with Valve

use of org.apache.catalina.Valve in project tomcat70 by apache.

the class StandardPipeline method getValveObjectNames.

public ObjectName[] getValveObjectNames() {
    ArrayList<ObjectName> valveList = new ArrayList<ObjectName>();
    Valve current = first;
    if (current == null) {
        current = basic;
    }
    while (current != null) {
        if (current instanceof ValveBase) {
            valveList.add(((ValveBase) current).getObjectName());
        }
        current = current.getNext();
    }
    return valveList.toArray(new ObjectName[0]);
}
Also used : ArrayList(java.util.ArrayList) Valve(org.apache.catalina.Valve) ValveBase(org.apache.catalina.valves.ValveBase) ObjectName(javax.management.ObjectName)

Example 42 with Valve

use of org.apache.catalina.Valve in project tomcat70 by apache.

the class StandardPipeline method stopInternal.

/**
 * Stop {@link Valve}s) in this pipeline and implement the requirements
 * of {@link LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {
    setState(LifecycleState.STOPPING);
    // Stop the Valves in our pipeline (including the basic), if any
    Valve current = first;
    if (current == null) {
        current = basic;
    }
    while (current != null) {
        if (current instanceof Lifecycle)
            ((Lifecycle) current).stop();
        current = current.getNext();
    }
}
Also used : Lifecycle(org.apache.catalina.Lifecycle) Valve(org.apache.catalina.Valve)

Example 43 with Valve

use of org.apache.catalina.Valve in project tomcat70 by apache.

the class ContainerBase method getAccessLog.

@Override
public AccessLog getAccessLog() {
    if (accessLogScanComplete) {
        return accessLog;
    }
    AccessLogAdapter adapter = null;
    Valve[] valves = getPipeline().getValves();
    for (Valve valve : valves) {
        if (valve instanceof AccessLog) {
            if (adapter == null) {
                adapter = new AccessLogAdapter((AccessLog) valve);
            } else {
                adapter.add((AccessLog) valve);
            }
        }
    }
    if (adapter != null) {
        accessLog = adapter;
    }
    accessLogScanComplete = true;
    return accessLog;
}
Also used : AccessLog(org.apache.catalina.AccessLog) Valve(org.apache.catalina.Valve)

Example 44 with Valve

use of org.apache.catalina.Valve in project tomcat70 by apache.

the class StandardContext method getAuthenticator.

@Override
public Authenticator getAuthenticator() {
    if (this instanceof Authenticator)
        return (Authenticator) this;
    Pipeline pipeline = getPipeline();
    if (pipeline != null) {
        Valve basic = pipeline.getBasic();
        if ((basic != null) && (basic instanceof Authenticator))
            return (Authenticator) basic;
        Valve[] valves = pipeline.getValves();
        for (int i = 0; i < valves.length; i++) {
            if (valves[i] instanceof Authenticator)
                return (Authenticator) valves[i];
        }
    }
    return null;
}
Also used : Valve(org.apache.catalina.Valve) Authenticator(org.apache.catalina.Authenticator) SecurityConstraint(org.apache.catalina.deploy.SecurityConstraint) Pipeline(org.apache.catalina.Pipeline)

Example 45 with Valve

use of org.apache.catalina.Valve in project tomcat70 by apache.

the class StandardHost method startInternal.

/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Set error report valve
    String errorValve = getErrorReportValveClass();
    if ((errorValve != null) && (!errorValve.equals(""))) {
        try {
            boolean found = false;
            Valve[] valves = getPipeline().getValves();
            for (Valve valve : valves) {
                if (errorValve.equals(valve.getClass().getName())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                Valve valve = (Valve) Class.forName(errorValve).getDeclaredConstructor().newInstance();
                getPipeline().addValve(valve);
            }
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            log.error(sm.getString("standardHost.invalidErrorReportValveClass", errorValve), t);
        }
    }
    super.startInternal();
}
Also used : Valve(org.apache.catalina.Valve)

Aggregations

Valve (org.apache.catalina.Valve)72 ArrayList (java.util.ArrayList)15 Lifecycle (org.apache.catalina.Lifecycle)14 Container (org.apache.catalina.Container)13 LifecycleException (org.apache.catalina.LifecycleException)13 Pipeline (org.apache.catalina.Pipeline)11 ObjectName (javax.management.ObjectName)9 Realm (org.apache.catalina.Realm)8 AccessLogValve (org.apache.catalina.valves.AccessLogValve)8 Contained (org.apache.catalina.Contained)7 LifecycleListener (org.apache.catalina.LifecycleListener)7 Request (org.apache.catalina.connector.Request)7 ClusterValve (org.apache.catalina.ha.ClusterValve)7 RemoteIpValve (org.apache.catalina.valves.RemoteIpValve)7 Test (org.junit.Test)7 Context (org.apache.catalina.Context)6 JmxEnabled (org.apache.catalina.JmxEnabled)6 Response (org.apache.catalina.connector.Response)6 IOException (java.io.IOException)5 ContainerBase (org.apache.catalina.core.ContainerBase)5