Search in sources :

Example 6 with ClusterValve

use of org.apache.catalina.ha.ClusterValve in project tomcat by apache.

the class StandardEngineSF method storeChildren.

/**
 * Store the specified Engine properties.
 *
 * @param aWriter
 *            PrintWriter to which we are storing
 * @param indent
 *            Number of spaces to indent this element
 * @param aEngine
 *            Object whose properties are being stored
 *
 * @exception Exception
 *                if an exception occurs while storing
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) throws Exception {
    if (aEngine instanceof StandardEngine) {
        StandardEngine engine = (StandardEngine) aEngine;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = engine.findLifecycleListeners();
        storeElementArray(aWriter, indent, listeners);
        // Store nested <Realm> element
        Realm realm = engine.getRealm();
        Realm parentRealm = null;
        // TODO is this case possible? (see it a old Server 5.0 impl)
        if (engine.getParent() != null) {
            parentRealm = engine.getParent().getRealm();
        }
        if (realm != parentRealm) {
            storeElement(aWriter, indent, realm);
        }
        // Store nested <Valve> elements
        Valve[] valves = engine.getPipeline().getValves();
        if (valves != null && valves.length > 0) {
            List<Valve> engineValves = new ArrayList<>();
            for (Valve valve : valves) {
                if (!(valve instanceof ClusterValve)) {
                    engineValves.add(valve);
                }
            }
            storeElementArray(aWriter, indent, engineValves.toArray());
        }
        // store all <Cluster> elements
        Cluster cluster = engine.getCluster();
        if (cluster != null) {
            storeElement(aWriter, indent, cluster);
        }
        // store all <Host> elements
        Container[] children = engine.findChildren();
        storeElementArray(aWriter, indent, children);
    }
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) ArrayList(java.util.ArrayList) ClusterValve(org.apache.catalina.ha.ClusterValve) Valve(org.apache.catalina.Valve) Cluster(org.apache.catalina.Cluster) LifecycleListener(org.apache.catalina.LifecycleListener) Realm(org.apache.catalina.Realm) ClusterValve(org.apache.catalina.ha.ClusterValve)

Aggregations

Valve (org.apache.catalina.Valve)6 ClusterValve (org.apache.catalina.ha.ClusterValve)6 JvmRouteBinderValve (org.apache.catalina.ha.session.JvmRouteBinderValve)4 ArrayList (java.util.ArrayList)2 Cluster (org.apache.catalina.Cluster)2 Container (org.apache.catalina.Container)2 LifecycleListener (org.apache.catalina.LifecycleListener)2 Realm (org.apache.catalina.Realm)2 StandardEngine (org.apache.catalina.core.StandardEngine)1 StandardHost (org.apache.catalina.core.StandardHost)1