tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject svn commit: r719990 - /openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java
Date Sun, 23 Nov 2008 13:59:44 GMT
Author: jgallimore
Date: Sun Nov 23 05:59:44 2008
New Revision: 719990

URL: http://svn.apache.org/viewvc?rev=719990&view=rev
Log:
OPENEJB-961 - allow openejb.war to be defined in a tomcat context. Thanks to Jean-Sébastien
Scrève for the patch.

Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java?rev=719990&r1=719989&r2=719990&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/OpenEJBListener.java
Sun Nov 23 05:59:44 2008
@@ -20,11 +20,14 @@
 import java.io.File;
 import java.util.Properties;
 
+import javax.management.ObjectName;
+
 import org.apache.catalina.Container;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.ServerFactory;
 import org.apache.catalina.Service;
+import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.core.StandardServer;
@@ -78,6 +81,8 @@
                         openEjbWar = findOpenEjbWar(hostDir);
                         if (openEjbWar != null) {
                             return openEjbWar;
+                        } else {
+                        	return findOpenEjbWar(host);
                         }
                     }
                 }
@@ -87,6 +92,23 @@
 
         return null;
     }
+    
+    private static File findOpenEjbWar(StandardHost standardHost) {
+    	//look for openejb war in a Tomcat context
+    	for(Container container : standardHost.findChildren()) {
+    		if(container instanceof StandardContext) {
+    			StandardContext standardContext = (StandardContext)container;
+    			File contextDocBase = new File(standardContext.getDocBase());
+    			if(contextDocBase.isDirectory()) {
+	    			File openEjbWar = findOpenEjbWarInContext(contextDocBase);
+	    	        if (openEjbWar != null) {
+	    	            return openEjbWar;
+	    	        }
+    			}
+    		}
+    	}
+    	return null;
+    }
 
     private static File findOpenEjbWar(File hostDir) {
         if (!hostDir.isDirectory()) {
@@ -95,19 +117,27 @@
 
         // iterate over the contexts
         for (File contextDir : hostDir.listFiles()) {
-            // does this war have a web-inf lib dir
-            File webInfLib = new File(new File(contextDir, "WEB-INF"), "lib");
-            if (!webInfLib.isDirectory()) {
-                continue;
-            }
-            // iterate over the libs looking for the openejb-loader-*.jar
-            for (File file : webInfLib.listFiles()) {
-                if (file.getName().startsWith("openejb-tomcat-loader-") && file.getName().endsWith(".jar"))
{
-                    // this should be the openejb war...
-                    // make sure it has a lib directory
-                    if (new File(contextDir, "lib").isDirectory()) {
-                        return contextDir;
-                    }
+        	File foundContextDir = findOpenEjbWarInContext(contextDir);
+        	if(foundContextDir != null) {
+        		return foundContextDir;
+        	}
+        }
+        return null;
+    }
+     
+    private static File findOpenEjbWarInContext(File contextDir) {
+        // does this war have a web-inf lib dir
+        File webInfLib = new File(new File(contextDir, "WEB-INF"), "lib");
+        if (!webInfLib.isDirectory()) {
+             return null;
+        }
+        // iterate over the libs looking for the openejb-loader-*.jar
+        for (File file : webInfLib.listFiles()) {
+            if (file.getName().startsWith("openejb-tomcat-loader-") && file.getName().endsWith(".jar"))
{
+                // this should be the openejb war...
+                // make sure it has a lib directory
+                if (new File(contextDir, "lib").isDirectory()) {
+                    return contextDir;
                 }
             }
         }



Mime
View raw message