[jboss-cvs] JBossAS SVN: r97694 - in trunk: server/src/main/java/org/jboss/deployment and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 10 08:33:30 EST 2009


Author: wolfc
Date: 2009-12-10 08:33:30 -0500 (Thu, 10 Dec 2009)
New Revision: 97694

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorLocal.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorServlet.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/unit/
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/unit/ServletAndEJBUnitTestCase.java
Modified:
   trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/Ejb3Deployer.java
   trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
   trunk/server/src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
   trunk/testsuite/imports/sections/ejb3.xml
Log:
JBAS-7526: deploy EJB beans from a war

Modified: trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/Ejb3Deployer.java
===================================================================
--- trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/Ejb3Deployer.java	2009-12-10 13:22:40 UTC (rev 97693)
+++ trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/Ejb3Deployer.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -48,7 +48,6 @@
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.metadata.ear.jboss.JBossAppMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -100,20 +99,14 @@
    @Override
    public void deploy(VFSDeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
    {
-      // Pickup any deployment which doesn't have metaData or metaData with ejbVersion unknown or 3
-      if(metaData != null && !metaData.isEJB3x())
+      // Ignore any deployment which doesn't have metaData (should be coming from either parsing or scanning deployer)
+      // or which is a legacy EJB deployment.
+      if(metaData == null || !metaData.isEJB3x())
       {
-         log.debug("Ignoring legacy EJB deployment " + unit);
+         log.debug("Ignoring deployment " + unit);
          return;
       }
 
-      // If this is a war, check scanWars
-      if(unit.getAttachment(JBossWebMetaData.class) != null && scanWars == false)
-      {
-         log.trace("Skipping web deployment: "+unit.getSimpleName());
-         return;            
-      }
-
       try
       {
          VirtualFile jar = unit.getRoot();

Modified: trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	2009-12-10 13:22:40 UTC (rev 97693)
+++ trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -219,6 +219,11 @@
       {
          try
          {
+            // The class path can contain subdirectories of other entries
+            // these must be ignored.
+            if(isChildOf(classPath, root))
+               continue;
+            
             if( root.isLeaf() == false )
                root.visit(visitor);
          }
@@ -230,4 +235,30 @@
       
       return visitor.getMatched();
    }
+   
+   private static boolean isChildOf(VirtualFile other, final VirtualFile file)
+      throws IOException
+   {
+      for(VirtualFile child : other.getChildren())
+      {
+         if(child.equals(file))
+            return true;
+         
+         if(isChildOf(child, file))
+            return true;
+      }
+      
+      return false;
+   }
+   
+   private static boolean isChildOf(List<VirtualFile> others, VirtualFile file)
+      throws IOException
+   {
+      for(VirtualFile other : others)
+      {
+         if(file != other && isChildOf(other, file))
+            return true;
+      }
+      return false;
+   }
 }

Modified: trunk/server/src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java	2009-12-10 13:22:40 UTC (rev 97693)
+++ trunk/server/src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -66,24 +66,13 @@
    protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
    {
       AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
-      if(webMetaData != null)
-      {
-         processJBossWebMetaData(unit, finder);
-      }
-      else if (clientMetaData != null)
-      {
-         String mainClassName = getMainClassName(unit);
-         if(mainClassName != null)
-            processJBossClientMetaData(unit, finder, mainClassName);
-      }
+      // don't do webMetaData anymore (rev 96033)
+      
+      String mainClassName = getMainClassName(unit);
+      if(mainClassName != null)
+         processJBossClientMetaData(unit, finder, mainClassName);
       else
-      {
-         String mainClassName = getMainClassName(unit);
-         if (mainClassName != null)
-            processJBossClientMetaData(unit, finder, mainClassName);
-         else
-            processJBossMetaData(unit, finder);
-      }
+         processJBossMetaData(unit, finder);
    }
 
    /**

Modified: trunk/testsuite/imports/sections/ejb3.xml
===================================================================
--- trunk/testsuite/imports/sections/ejb3.xml	2009-12-10 13:22:40 UTC (rev 97693)
+++ trunk/testsuite/imports/sections/ejb3.xml	2009-12-10 13:33:30 UTC (rev 97694)
@@ -29,6 +29,13 @@
       </jar>
    </target>
    
+   <target name="jbas7526" depends="compile">
+      <mkdir dir="${build.lib}" />
+      <jar destfile="${build.lib}/jbas7526.war">
+         <zipfileset dir="${build.classes}" includes="org/jboss/test/ejb3/jbas7526/*" prefix="WEB-INF/classes"/>
+      </jar>
+   </target>
+   
    <!-- This issue affected the ejb3 AS module -->
    <target name="ejbthree1597" depends="compile">
       <mkdir dir="${build.lib}"/>
@@ -118,7 +125,9 @@
 	   </jar>
    </target>
 
-   <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,ejbthree7376, jboss51xsd">
+   <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,
+      jbas7526,
+      ejbthree1597,ejbthree7376, jboss51xsd">
       <mkdir dir="${build.lib}" />
 
       <!-- A jar with a simple ejb3 session -->

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorBean.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbas7526;
+
+import javax.ejb.Stateless;
+
+/**
+ * Don't ever do a light weight POJO as an EJB. :-)
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+public class CalculatorBean implements CalculatorLocal
+{
+   public int add(int a, int b)
+   {
+      return a + b;
+   }
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorLocal.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorLocal.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorLocal.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbas7526;
+
+import javax.ejb.Local;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface CalculatorLocal
+{
+   int add(int a, int b);
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorServlet.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorServlet.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/CalculatorServlet.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbas7526;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at WebServlet("/calculator")
+public class CalculatorServlet extends HttpServlet
+{
+   private static final long serialVersionUID = 1L;
+   
+   @EJB
+   private CalculatorLocal calculator;
+
+   @Override
+   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+   {
+      int a = Integer.parseInt(req.getParameter("a"));
+      int b = Integer.parseInt(req.getParameter("b"));
+      resp.setContentType("text/plain");
+      PrintWriter out = resp.getWriter();
+      out.println(calculator.add(a, b));
+      out.flush();
+   }
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/unit/ServletAndEJBUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/unit/ServletAndEJBUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7526/unit/ServletAndEJBUnitTestCase.java	2009-12-10 13:33:30 UTC (rev 97694)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbas7526.unit;
+
+import java.net.HttpURLConnection;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Deploy a war with an EJB in it.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServletAndEJBUnitTestCase extends JBossTestCase
+{
+   private String baseURL = "http://" + System.getProperty("jbosstest.server.host", "localhost") + ":" + Integer.getInteger("web.port", 8080) + "/jbas7526/calculator";
+   
+   public ServletAndEJBUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   private String accessURL(String url) throws Exception
+   {
+      HttpClient httpConn = new HttpClient();
+      HttpMethodBase request = new GetMethod(baseURL + url);
+      log.debug("RequestURI: " + request.getURI());
+      int responseCode = httpConn.executeMethod(request);
+      String response = request.getStatusText();
+      log.debug("responseCode="+responseCode+", response="+response);
+      String content = request.getResponseBodyAsString();
+      log.debug(content);
+      assertEquals(HttpURLConnection.HTTP_OK, responseCode);
+      return content;
+   }
+   
+   public void test1() throws Exception
+   {
+      String result = accessURL("?a=1&b=2");
+      assertEquals("3\r\n", result);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ServletAndEJBUnitTestCase.class, "jbas7526.war");
+   }
+}




More information about the jboss-cvs-commits mailing list