You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/11/15 19:12:15 UTC

svn commit: r717902 - /tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java

Author: markt
Date: Sat Nov 15 10:12:15 2008
New Revision: 717902

URL: http://svn.apache.org/viewvc?rev=717902&view=rev
Log:
Merge r613809 from 6.0.x
FarmWarDeployer can only be configured as host sub-element

Modified:
    tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java

Modified: tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=717902&r1=717901&r2=717902&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Sat Nov 15 10:12:15 2008
@@ -24,6 +24,7 @@
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
@@ -139,38 +140,43 @@
     public void start() throws Exception {
         if (started)
             return;
-        getCluster().addClusterListener(this);
-        if (watchEnabled) {
-            watcher = new WarWatcher(this, new File(getWatchDir()));
-            if (log.isInfoEnabled())
-                log.info("Cluster deployment is watching " + getWatchDir()
-                         + " for changes.");
+        Container hcontainer = getCluster().getContainer();
+        if(!(hcontainer instanceof Host)) {
+            log.error("FarmWarDeployer can only work as host cluster subelement!");
+            return ;
         }
+        host = (Host) hcontainer;
     
         // Check to correct engine and host setup
-        Object parent = getCluster().getContainer();
-        Engine engine = null;
-        String hostname = null;
-        if ( parent instanceof Host ) {
-            host = (Host) parent;
-            engine = (Engine) host.getParent();
-            hostname = host.getName();
-        }else {
-            engine = (Engine)parent;
-            hostname = engine.getDefaultHost();
-            host = (Host) engine.findChild(hostname);
+        Container econtainer = host.getParent();
+        if(econtainer == null && econtainer instanceof Engine) {
+            log.error("FarmWarDeployer can only work if parent of " + host.getName()+ " is an engine!"); 
+            return ;
         }
+        Engine engine = (Engine) econtainer;
+        String hostname = null;
+        hostname = host.getName();
         try {
             oname = new ObjectName(engine.getName() + ":type=Deployer,host="
                     + hostname);
         } catch (Exception e) {
             log.error("Can't construct MBean object name" + e);
+            return;
         }
+        if (watchEnabled) {
+            watcher = new WarWatcher(this, new File(getWatchDir()));
+            if (log.isInfoEnabled()) {
+                log.info("Cluster deployment is watching " + getWatchDir()
+                          + " for changes.");
+            }
+        }
+         
         configBase = new File(System.getProperty("catalina.base"), "conf");
         if (engine != null) {
             configBase = new File(configBase, engine.getName());
-        } else if (host != null) {
-            configBase = new File(configBase, host.getName());
+        } 
+        if (host != null) {
+            configBase = new File(configBase, hostname);
         }
 
         // Retrieve the MBean server
@@ -178,6 +184,9 @@
 
         started = true;
         count = 0;
+
+        getCluster().addClusterListener(this);
+
         if (log.isInfoEnabled())
             log.info("Cluster FarmWarDeployer started.");
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org