geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1148324 - in /geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup: Catalina.java ClusterRuleSetFactory.java
Date Tue, 19 Jul 2011 13:56:54 GMT
Author: xuhaihong
Date: Tue Jul 19 13:56:53 2011
New Revision: 1148324

URL: http://svn.apache.org/viewvc?rev=1148324&view=rev
Log:
Recover the changes of rev.1144690, which brought a cycle dependency issue We might merge
the catalina and catalina-ha in one module in the future

Added:
    geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
  (with props)
Modified:
    geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/Catalina.java

Modified: geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/Catalina.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/Catalina.java?rev=1148324&r1=1148323&r2=1148324&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/Catalina.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/Catalina.java
Tue Jul 19 13:56:53 2011
@@ -36,7 +36,6 @@ import org.apache.catalina.LifecycleExce
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Server;
 import org.apache.catalina.core.StandardServer;
-import org.apache.catalina.ha.ClusterRuleSet;
 import org.apache.catalina.security.SecurityConfig;
 import org.apache.juli.ClassLoaderLogManager;
 import org.apache.tomcat.util.ExceptionUtils;
@@ -374,13 +373,15 @@ public class Catalina {
         digester.addRuleSet(new EngineRuleSet("Server/Service/"));
         digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
         digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
-        digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Host/Cluster/"));
+        //digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Host/Cluster/"));
+        digester.addRuleSet(ClusterRuleSetFactory.getClusterRuleSet("Server/Service/Engine/Host/Cluster/"));
         digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));
 
         // When the 'engine' is found, set the parentClassLoader.
         digester.addRule("Server/Service/Engine",
                          new SetParentClassLoaderRule(parentClassLoader));
-        digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Cluster/"));
+        //digester.addRuleSet(new ClusterRuleSet("Server/Service/Engine/Cluster/"));
+        digester.addRuleSet(ClusterRuleSetFactory.getClusterRuleSet("Server/Service/Engine/Cluster/"));
 
         long t2=System.currentTimeMillis();
         if (log.isDebugEnabled())

Added: geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java?rev=1148324&view=auto
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
(added)
+++ geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
Tue Jul 19 13:56:53 2011
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.catalina.startup;
+
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.digester.RuleSetBase;
+public class ClusterRuleSetFactory {
+    
+    public static final Log log = LogFactory.getLog(ClusterRuleSetFactory.class);
+    
+    public static RuleSetBase getClusterRuleSet(String prefix) {
+        
+        //OLD CLUSTER 1
+        //first try the same classloader as this class server/lib
+        try {
+            return loadRuleSet(prefix,"org.apache.catalina.cluster.ClusterRuleSet",ClusterRuleSetFactory.class.getClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isDebugEnabled() ) log.debug("Unable to load ClusterRuleSet (org.apache.catalina.cluster.ClusterRuleSet),
falling back on context classloader");
+        }
+        //try to load it from the context class loader
+        try {
+            return loadRuleSet(prefix,"org.apache.catalina.cluster.ClusterRuleSet",Thread.currentThread().getContextClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isDebugEnabled() ) log.debug("Unable to load ClusterRuleSet (org.apache.catalina.cluster.ClusterRuleSet),
will try to load the HA cluster");
+        }
+        
+        //NEW CLUSTER 2
+        //first try the same classloader as this class server/lib
+        try {
+            return loadRuleSet(prefix,"org.apache.catalina.ha.ClusterRuleSet",ClusterRuleSetFactory.class.getClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isDebugEnabled() ) log.debug("Unable to load HA ClusterRuleSet (org.apache.catalina.ha.ClusterRuleSet),
falling back on context classloader");
+        }
+        //try to load it from the context class loader
+        try {
+            return loadRuleSet(prefix,"org.apache.catalina.ha.ClusterRuleSet",Thread.currentThread().getContextClassLoader());
+        } catch ( Exception x ) {
+            //display warning
+            if ( log.isDebugEnabled() ) log.debug("Unable to load HA ClusterRuleSet (org.apache.catalina.ha.ClusterRuleSet),
falling back on DefaultClusterRuleSet");
+        }
+
+        log.info("Unable to find a cluster rule set in the classpath. Will load the default
rule set.");
+        return new DefaultClusterRuleSet(prefix);
+    }
+    
+    
+    protected static RuleSetBase loadRuleSet(String prefix, String className, ClassLoader
cl) 
+        throws ClassNotFoundException, InstantiationException, 
+               NoSuchMethodException,IllegalAccessException,
+               InvocationTargetException {
+        Class<?> clazz = Class.forName(className,true,cl);
+        Constructor<?> cons = clazz.getConstructor(new Class[] {String.class});
+        return (RuleSetBase)cons.newInstance(prefix);
+    }
+    
+    /**
+     * <p><strong>RuleSet</strong> for processing the contents of a
+     * Cluster definition element.  </p>
+     *
+     * @author Filip Hanik
+     * @author Peter Rossbach
+     * @version $Id: ClusterRuleSetFactory.java 987920 2010-08-22 15:34:34Z markt $
+     */
+
+    public static class DefaultClusterRuleSet extends RuleSetBase {
+
+
+        // ----------------------------------------------------- Instance Variables
+
+
+        /**
+         * The matching pattern prefix to use for recognizing our elements.
+         */
+        protected String prefix = null;
+
+
+        // ------------------------------------------------------------ Constructor
+
+
+        /**
+         * Construct an instance of this <code>RuleSet</code> with the default
+         * matching pattern prefix.
+         */
+        public DefaultClusterRuleSet() {
+
+            this("");
+
+        }
+
+
+        /**
+         * Construct an instance of this <code>RuleSet</code> with the specified
+         * matching pattern prefix.
+         *
+         * @param prefix Prefix for matching pattern rules (including the
+         *  trailing slash character)
+         */
+        public DefaultClusterRuleSet(String prefix) {
+            super();
+            this.namespaceURI = null;
+            this.prefix = prefix;
+        }
+
+
+        // --------------------------------------------------------- Public Methods
+
+
+        /**
+         * <p>Add the set of Rule instances defined in this RuleSet to the
+         * specified <code>Digester</code> instance, associating them with
+         * our namespace URI (if any).  This method should only be called
+         * by a Digester instance.</p>
+         *
+         * @param digester Digester instance to which the new Rule instances
+         *  should be added.
+         */
+        @Override
+        public void addRuleInstances(Digester digester) {
+            //Cluster configuration start
+            digester.addObjectCreate(prefix + "Membership",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Membership");
+            digester.addSetNext(prefix + "Membership",
+                                "setMembershipService",
+                                "org.apache.catalina.cluster.MembershipService");
+
+            digester.addObjectCreate(prefix + "Sender",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Sender");
+            digester.addSetNext(prefix + "Sender",
+                                "setClusterSender",
+                                "org.apache.catalina.cluster.ClusterSender");
+
+            digester.addObjectCreate(prefix + "Receiver",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Receiver");
+            digester.addSetNext(prefix + "Receiver",
+                                "setClusterReceiver",
+                                "org.apache.catalina.cluster.ClusterReceiver");
+
+            digester.addObjectCreate(prefix + "Valve",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Valve");
+            digester.addSetNext(prefix + "Valve",
+                                "addValve",
+                                "org.apache.catalina.Valve");
+
+            digester.addObjectCreate(prefix + "Deployer",
+                                     null, // MUST be specified in the element
+                                     "className");
+            digester.addSetProperties(prefix + "Deployer");
+            digester.addSetNext(prefix + "Deployer",
+                                "setClusterDeployer",
+                                "org.apache.catalina.cluster.ClusterDeployer");
+
+            digester.addObjectCreate(prefix + "Listener",
+                    null, // MUST be specified in the element
+                    "className");
+            digester.addSetProperties(prefix + "Listener");
+            digester.addSetNext(prefix + "Listener",
+                                "addLifecycleListener",
+                                "org.apache.catalina.LifecycleListener");
+
+            digester.addObjectCreate(prefix + "ClusterListener",
+                    null, // MUST be specified in the element
+                    "className");
+            digester.addSetProperties(prefix + "ClusterListener");
+            digester.addSetNext(prefix + "ClusterListener",
+                                "addClusterListener",
+                                "org.apache.catalina.cluster.MessageListener");
+            //Cluster configuration end
+        }
+
+
+    }
+}
\ No newline at end of file

Propchange: geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/external/trunk/tomcat-parent-7.0.19/catalina/src/main/java/org/apache/catalina/startup/ClusterRuleSetFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message