[jboss-cvs] JBossAS SVN: r60425 - trunk/embedded/src/main/java/org/jboss/embedded/tomcat.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 8 11:03:28 EST 2007


Author: bill.burke at jboss.com
Date: 2007-02-08 11:03:28 -0500 (Thu, 08 Feb 2007)
New Revision: 60425

Added:
   trunk/embedded/src/main/java/org/jboss/embedded/tomcat/WebinfScanner.java
Removed:
   trunk/embedded/src/main/java/org/jboss/embedded/tomcat/TomcatWebinfScanner.java
Log:
finally make i work.

Deleted: trunk/embedded/src/main/java/org/jboss/embedded/tomcat/TomcatWebinfScanner.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/tomcat/TomcatWebinfScanner.java	2007-02-08 14:20:20 UTC (rev 60424)
+++ trunk/embedded/src/main/java/org/jboss/embedded/tomcat/TomcatWebinfScanner.java	2007-02-08 16:03:28 UTC (rev 60425)
@@ -1,118 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.embedded.tomcat;
-
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.Container;
-import org.apache.catalina.Pipeline;
-import org.apache.catalina.core.StandardContext;
-import org.jboss.embedded.tomcat.security.SecurityAssociationValve;
-import org.jboss.embedded.Bootstrap;
-import org.jboss.embedded.DeploymentGroup;
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-
-import javax.naming.directory.DirContext;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.io.File;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Searches for WAR's WEB-INF directory and deploys that directory.
- * A JBoss DeploymentContext is created and the StandardContext is added as an attachment 
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public class TomcatWebinfScanner implements LifecycleListener
-{
-   private DeploymentGroup group;
-
-   public void lifecycleEvent(LifecycleEvent event)
-   {
-      if (event.getType().equals(Lifecycle.BEFORE_START_EVENT))
-      {
-         if (!(event.getSource() instanceof Container)) return;
-
-         StandardContext container = (StandardContext)event.getSource();
-         Method getBasePath = getBasePathMethod();
-         String basePath;
-         try
-         {
-            basePath = (String)getBasePath.invoke(container);
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-
-         File baseDir = new File(basePath, "WEB-INF");
-         DeploymentContext deployment;
-         group = Bootstrap.getInstance().createDeploymentGroup();
-         try
-         {
-            group.add(baseDir.toURL());
-            deployment = group.getDeployments().get(0);
-            deployment.getTransientAttachments().addAttachment(StandardContext.class, container);
-            group.process();
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-      else if (event.getType().equals(Lifecycle.AFTER_STOP_EVENT))
-      {
-         try
-         {
-            group.undeploy();
-         }
-         catch (DeploymentException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-
-   }
-
-   private static Method basePathMethod;
-
-   private static synchronized Method getBasePathMethod()
-   {
-      if (basePathMethod != null) return basePathMethod;
-      try
-      {
-         basePathMethod = StandardContext.class.getDeclaredMethod("getBasePath");
-      }
-      catch (NoSuchMethodException e)
-      {
-         throw new RuntimeException(e);
-      }
-      basePathMethod.setAccessible(true);
-      return basePathMethod;
-   }
-}

Copied: trunk/embedded/src/main/java/org/jboss/embedded/tomcat/WebinfScanner.java (from rev 60407, trunk/embedded/src/main/java/org/jboss/embedded/tomcat/TomcatWebinfScanner.java)
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/tomcat/WebinfScanner.java	                        (rev 0)
+++ trunk/embedded/src/main/java/org/jboss/embedded/tomcat/WebinfScanner.java	2007-02-08 16:03:28 UTC (rev 60425)
@@ -0,0 +1,133 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.tomcat;
+
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.Container;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.core.StandardContext;
+import org.jboss.embedded.tomcat.security.SecurityAssociationValve;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.embedded.DeploymentGroup;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+import javax.naming.directory.DirContext;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Searches for WAR's WEB-INF directory and deploys that directory.
+ * A JBoss DeploymentContext is created and the StandardContext is added as an attachment
+ *
+ * This listener assumes an exploded deployment, in other words, that WEB-INF/ is
+ * a directory in a file system.
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebinfScanner implements LifecycleListener
+{
+   private DeploymentGroup group;
+
+   public void lifecycleEvent(LifecycleEvent event)
+   {
+      if (event.getType().equals(Lifecycle.START_EVENT))
+      {
+         if (!(event.getSource() instanceof StandardContext)) return;
+
+         StandardContext container = (StandardContext)event.getSource();
+         container.getLoader().getClassLoader();
+         Method getBasePath = getBasePathMethod();
+         String basePath;
+         try
+         {
+            basePath = (String)getBasePath.invoke(container);
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+
+         File webInf = new File(basePath, "WEB-INF");
+         File webInfLib = new File(webInf, "lib");
+         File webInfClasses = new File(webInf, "classes");
+
+         group = Bootstrap.getInstance().createDeploymentGroup();
+         try
+         {
+            if (webInfLib.exists())
+            {
+               group.add(webInfLib.toURL());
+            }
+            if (webInfClasses.exists())
+            {
+               group.add(webInfClasses.toURL());
+            }
+            for (DeploymentContext deployment : group.getDeployments())
+            {
+               deployment.getTransientAttachments().addAttachment(StandardContext.class, container);
+            }
+            group.process();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      else if (event.getType().equals(Lifecycle.STOP_EVENT))
+      {
+         try
+         {
+            group.undeploy();
+         }
+         catch (DeploymentException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+   }
+
+   private static Method basePathMethod;
+
+   private static synchronized Method getBasePathMethod()
+   {
+      if (basePathMethod != null) return basePathMethod;
+      try
+      {
+         basePathMethod = StandardContext.class.getDeclaredMethod("getBasePath");
+      }
+      catch (NoSuchMethodException e)
+      {
+         throw new RuntimeException(e);
+      }
+      basePathMethod.setAccessible(true);
+      return basePathMethod;
+   }
+}




More information about the jboss-cvs-commits mailing list