[jboss-cvs] JBossAS SVN: r59561 - in trunk/embedded: src/main/java/org/jboss/embedded and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 11 21:35:05 EST 2007


Author: bill.burke at jboss.com
Date: 2007-01-11 21:35:02 -0500 (Thu, 11 Jan 2007)
New Revision: 59561

Added:
   trunk/embedded/install-tomcat55.xml
   trunk/embedded/src/main/java/org/jboss/embedded/ServletContextResourceScanner.java
   trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java
   trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.jsp
   trunk/embedded/src/test/resources/war-resource/
   trunk/embedded/src/test/resources/war-resource/web.xml
   trunk/embedded/src/test/resources/war-scan/
   trunk/embedded/src/test/resources/war-scan/web.xml
Removed:
   trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java
Modified:
   trunk/embedded/build-test.xml
   trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroupBean.java
   trunk/embedded/src/main/java/org/jboss/embedded/tomcat/jndi/ENCFactory.java
Log:
finalize Tomcat integration

Modified: trunk/embedded/build-test.xml
===================================================================
--- trunk/embedded/build-test.xml	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/build-test.xml	2007-01-12 02:35:02 UTC (rev 59561)
@@ -169,7 +169,26 @@
             <include name="META-INF/persistence.xml"/>
          </fileset>
       </jar>
+      <war warfile="${build.lib}/war-scan.war"
+         webxml="${resources}/war-scan/web.xml">
+         <lib dir="${build.lib}">
+            <include name="ejb-test.jar"/>
+         </lib>
+         <fileset dir="${source.java}/org/jboss/embedded/test/ejb/unit">
+            <include name="EjbTestCase.jsp"/>
+         </fileset>
+      </war>
+      <war warfile="${build.lib}/war-resource.war"
+         webxml="${resources}/war-resource/web.xml">
+         <lib dir="${build.lib}">
+            <include name="ejb-test.jar"/>
+         </lib>
+         <fileset dir="${source.java}/org/jboss/embedded/test/ejb/unit">
+            <include name="EjbTestCase.jsp"/>
+         </fileset>
+      </war>
 
+
    </target>
 
    <target name="main"

Added: trunk/embedded/install-tomcat55.xml
===================================================================
--- trunk/embedded/install-tomcat55.xml	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/install-tomcat55.xml	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="main" name="JBoss/Embedded">
+
+   <property name="jboss.dir" value="."/>
+
+   <target name="main">
+
+      <copy todir="${tomcat.dir}/server/classes">
+         <fileset dir="${jboss.dir}/bootstrap">
+            <include name="**/*"/>
+            <exclude name="jndi.properties"/>
+         </fileset>
+      </copy>
+      <copy todir="${tomcat.dir}/server/lib">
+         <fileset dir="${jboss.dir}/lib">
+            <include name="jboss-embedded-tomcat-bootstrap.jar"/>
+         </fileset>
+      </copy>
+      <copy todir="${tomcat.dir}/common/lib">
+         <fileset dir="${jboss.dir}/lib">
+            <include name="*.jar"/>
+            <exclude name="jboss-embedded-tomcat-bootstrap.jar"/>
+         </fileset>
+      </copy>
+
+   </target>
+
+
+</project>

Modified: trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroupBean.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroupBean.java	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroupBean.java	2007-01-12 02:35:02 UTC (rev 59561)
@@ -22,6 +22,7 @@
 package org.jboss.embedded;
 
 import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.logging.Logger;
 
 import java.io.IOException;
 import java.net.URL;
@@ -35,6 +36,8 @@
  */
 public class DeploymentGroupBean extends DeploymentGroup
 {
+   private static final Logger log = Logger.getLogger(DeploymentGroupBean.class);
+
    private List<URL> urls;
    private List<String> resources;
    private List<String> multiple;
@@ -65,29 +68,37 @@
 
    public void start() throws Exception
    {
-      if (urls != null) addUrls(urls);
-      if (resources != null)
+      try
       {
-         for (String resource : resources)
+         if (urls != null) addUrls(urls);
+         if (resources != null)
          {
-            addResource(resource);
+            for (String resource : resources)
+            {
+               addResource(resource);
+            }
          }
-      }
-      if (multiple != null)
-      {
-         for (String resource : multiple)
+         if (multiple != null)
          {
-            addMultipleResources(resource);
+            for (String resource : multiple)
+            {
+               addMultipleResources(resource);
+            }
          }
-      }
-      if (dirs != null)
-      {
-         for (String resource : dirs)
+         if (dirs != null)
          {
-            addDirectoryByResource(resource, true);
+            for (String resource : dirs)
+            {
+               addDirectoryByResource(resource, true);
+            }
          }
+         mainDeployer.process();
       }
-      mainDeployer.process();
+      catch (Exception ex)
+      {
+         log.error("Failed to deploy", ex);
+         throw ex;
+      }
    }
 
    public void stop() throws DeploymentException

Added: trunk/embedded/src/main/java/org/jboss/embedded/ServletContextResourceScanner.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/ServletContextResourceScanner.java	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/main/java/org/jboss/embedded/ServletContextResourceScanner.java	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,88 @@
+/*
+* 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;
+
+import org.jboss.logging.Logger;
+import org.jboss.deployers.spi.DeploymentException;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContext;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.net.URL;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 44597 $
+ */
+public class ServletContextResourceScanner implements ServletContextListener
+{
+   private static final Logger log = Logger.getLogger(ServletContextResourceScanner.class);
+
+   private DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+
+   public void contextInitialized(ServletContextEvent servletContextEvent)
+   {
+      ServletContext servletContext = servletContextEvent.getServletContext();
+      String resources = servletContext.getInitParameter("jboss.embedded.resources");
+
+      if (resources == null) throw new RuntimeException("You must specify a resources parameter to the ServletContextResourceScanner");
+
+      StringTokenizer tokenizer = new StringTokenizer(resources, ",");
+      while (tokenizer.hasMoreTokens())
+      {
+         String token = tokenizer.nextToken().trim();
+         try
+         {
+            URL resource = servletContext.getResource(token);
+            group.add(resource);
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Unable to add servlet resource to deloyer: " + token, e);
+         }
+      }
+      try
+      {
+         group.process();
+      }
+      catch (DeploymentException e)
+      {
+         throw new RuntimeException("Failed to deploy servlet resources: " + resources, e);
+      }
+   }
+
+   public void contextDestroyed(ServletContextEvent servletContextEvent)
+   {
+      try
+      {
+         group.undeploy();
+      }
+      catch (DeploymentException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}

Deleted: trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java	2007-01-12 02:35:02 UTC (rev 59561)
@@ -1,67 +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;
-
-import org.jboss.logging.Logger;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 44597 $
- */
-public class WebInfLibScanner implements ServletContextListener
-{
-   private static final Logger log = Logger.getLogger(WebInfLibScanner.class);
-
-   private List<URL> jars = new ArrayList<URL>();
-
-   public void contextInitialized(ServletContextEvent servletContextEvent)
-   {
-      try
-      {
-         ServletContext servletContext = servletContextEvent.getServletContext();
-         Set libJars = servletContext.getResourcePaths("/WEB-INF/lib");
-         for (Object jar : libJars)
-         {
-            URL archive = servletContext.getResource((String)jar);
-         }
-      }
-      catch (Exception e)
-      {
-         log.error("failed to deploy from ServletListenerDeployer", e);
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void contextDestroyed(ServletContextEvent servletContextEvent)
-   {
-   }
-}

Added: trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/main/java/org/jboss/embedded/WebInfLibScanner.java	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,91 @@
+/*
+* 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;
+
+import org.jboss.logging.Logger;
+import org.jboss.deployers.spi.DeploymentException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.net.URL;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 44597 $
+ */
+public class WebInfLibScanner implements ServletContextListener
+{
+   private static final Logger log = Logger.getLogger(WebInfLibScanner.class);
+
+   private DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+
+   public void contextInitialized(ServletContextEvent servletContextEvent)
+   {
+      scan(servletContextEvent, "/WEB-INF/lib");
+   }
+
+   protected void scan(ServletContextEvent servletContextEvent, String path)
+   {
+      try
+      {
+         ServletContext servletContext = servletContextEvent.getServletContext();
+         Set libJars = servletContext.getResourcePaths(path);
+         for (Object jar : libJars)
+         {
+            URL archive = servletContext.getResource((String) jar);
+            group.add(archive);
+         }
+         group.process();
+      }
+      catch (Exception e)
+      {
+         try
+         {
+            group.undeploy();
+         }
+         catch (DeploymentException e1)
+         {
+            log.warn("failed to undeploy on error");
+         }
+         log.error("failed to deploy from ServletListenerDeployer", e);
+         throw new RuntimeException(e);
+      }
+   }
+
+   public void contextDestroyed(ServletContextEvent servletContextEvent)
+   {
+      try
+      {
+         group.undeploy();
+      }
+      catch (DeploymentException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}

Modified: trunk/embedded/src/main/java/org/jboss/embedded/tomcat/jndi/ENCFactory.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/tomcat/jndi/ENCFactory.java	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/main/java/org/jboss/embedded/tomcat/jndi/ENCFactory.java	2007-01-12 02:35:02 UTC (rev 59561)
@@ -22,6 +22,7 @@
 package org.jboss.embedded.tomcat.jndi;
 
 import org.apache.naming.SelectorContext;
+import org.apache.naming.java.javaURLContextFactory;
 
 import javax.naming.Context;
 import javax.naming.Name;
@@ -60,6 +61,7 @@
       ctx.rebind("comp", envRef);
    }
 
+   private javaURLContextFactory apache = new javaURLContextFactory();
 
    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
@@ -68,7 +70,7 @@
       {
          return super.getObjectInstance(obj, name, nameCtx, environment);
       }
-      return new SelectorContext(environment).lookup("comp");
+      return apache.getInitialContext(environment).lookup("java:comp");
    }
 
 }

Added: trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.jsp
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.jsp	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.jsp	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,28 @@
+<%@ page import="javax.naming.InitialContext" %>
+<%@ page import="org.jboss.embedded.test.ejb.DAO" %>
+<%@ page import="org.jboss.embedded.test.ejb.Customer" %>
+<%@ page import="javax.naming.NamingException" %>
+
+<%
+   Customer cust = null;
+   try
+   {
+      InitialContext ctx = new InitialContext();
+      DAO dao = (DAO) ctx.lookup("DAOBean/local");
+      cust = dao.createCustomer("Bill");
+      cust = dao.findCustomer("Bill");
+   }
+   catch (NamingException e)
+   {
+      throw new RuntimeException(e);
+   }
+   assert cust != null;
+   assert cust.getName().equals("Bill");
+
+%>
+
+<html>
+<body>
+<h1>SUCCESS</h1>
+</body>
+</html>

Added: trunk/embedded/src/test/resources/war-resource/web.xml
===================================================================
--- trunk/embedded/src/test/resources/war-resource/web.xml	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/test/resources/war-resource/web.xml	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app>
+   <description>Embedded JBoss</description>
+
+   <context-param>
+      <param-name>jboss.embedded.resources</param-name>
+      <param-value>/WEB-INF/lib/ejb-test.jar</param-value>
+   </context-param>
+
+   <listener>
+      <listener-class>org.jboss.embedded.ServletContextResourceScanner</listener-class>
+   </listener>
+
+</web-app>

Added: trunk/embedded/src/test/resources/war-scan/web.xml
===================================================================
--- trunk/embedded/src/test/resources/war-scan/web.xml	2007-01-12 02:31:07 UTC (rev 59560)
+++ trunk/embedded/src/test/resources/war-scan/web.xml	2007-01-12 02:35:02 UTC (rev 59561)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app>
+   <description>Embedded JBoss</description>
+
+   <context-param>
+      <param-name>jboss-kernel-deployments</param-name>
+      <param-value>embedded-jboss-beans.xml, jboss-jms-beans.xml, testjms.xml</param-value>
+   </context-param>
+
+   <listener>
+      <listener-class>org.jboss.embedded.WebInfLibScanner</listener-class>
+   </listener>
+
+</web-app>




More information about the jboss-cvs-commits mailing list