[jboss-cvs] JBossAS SVN: r61340 - in trunk/ejb3: src/main/org/jboss/ejb3 and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 15 12:59:55 EDT 2007


Author: bdecoste
Date: 2007-03-15 12:59:55 -0400 (Thu, 15 Mar 2007)
New Revision: 61340

Added:
   trunk/ejb3/src/resources/test/descriptortypo/
   trunk/ejb3/src/resources/test/descriptortypo/META-INF/
   trunk/ejb3/src/resources/test/descriptortypo/META-INF/ejb-jar.xml
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/unit/TypoTestCase.java
Modified:
   trunk/ejb3/build-test.xml
   trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
Log:
[EJBTHREE-897] merged from 4.2. Throws RuntimeException that wraps the ClassNotFound/FieldNotFound exception when method/field from descriptor does not exist 

Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml	2007-03-15 16:31:25 UTC (rev 61339)
+++ trunk/ejb3/build-test.xml	2007-03-15 16:59:55 UTC (rev 61340)
@@ -2506,7 +2506,23 @@
          </fileset>
       </jar>
    </target-->
+   
+   <target name="descriptortypo"
+      description="Builds all jar files."
+      depends="compile-classes">
 
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/descriptortypo-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/descriptortypo/**/*.class"/>
+         </fileset>
+         <fileset dir="${resources}/test/descriptortypo">
+            <include name="META-INF/*.xml"/>
+         </fileset>
+      </jar>
+   </target>
+
    <target name="stateful"
       description="Builds all jar files."
       depends="compile-classes">
@@ -3084,7 +3100,7 @@
       </jar>
    </target>
    
-   <target name="jars" depends="libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, 
       securitydomain, enventry, 
@@ -3765,6 +3781,9 @@
       <antcall target="test" inheritRefs="true">
          <param name="test" value="stateful"/>
       </antcall>
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="descriptortypo"/>
+      </antcall>
       <!--antcall target="test" inheritRefs="true">
          <param name="test" value="concurrent"/>
       </antcall-->

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java	2007-03-15 16:31:25 UTC (rev 61339)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -1829,113 +1829,120 @@
    {
       String methodName = method.getMethodName();
 
-      AnnotationRepository annotations = container.getAnnotations();
-      if (methodName.equals("*"))
+      try
       {
-         log.debug("adding " + annotationClass.getName() + " annotation to "
-               + ejbClass.getName() + "." + methodName);
-
-         for (java.lang.reflect.Method declaredMethod : ejbClass
-               .getDeclaredMethods())
+         AnnotationRepository annotations = container.getAnnotations();
+         if (methodName.equals("*"))
          {
-            annotations.addAnnotation(declaredMethod, annotationClass,
-                  annotation);
-            overrideAnnotations(container, declaredMethod, annotationClass
-                  .getName(), annotation);
-         }
-      } else
-      {
-         List params = method.getMethodParams();
-         if (params == null)
-         {
-            java.lang.reflect.Method[] methods = ejbClass.getMethods();
-            boolean foundMethod = false;
-            for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
+            log.debug("adding " + annotationClass.getName() + " annotation to "
+                  + ejbClass.getName() + "." + methodName);
+   
+            for (java.lang.reflect.Method declaredMethod : ejbClass
+                  .getDeclaredMethods())
             {
-               if (methods[methodIndex].getName().equals(methodName))
-               {
-                  log.debug("adding " + annotationClass.getName()
-                        + " method annotation to " + ejbClass.getName() + "."
-                        + methodName);
-                  annotations.addAnnotation(methods[methodIndex],
-                        annotationClass, annotation);
-                  overrideAnnotations(container, methods[methodIndex],
-                        annotationClass.getName(), annotation);
-                  foundMethod = true;
-
-               }
+               annotations.addAnnotation(declaredMethod, annotationClass,
+                     annotation);
+               overrideAnnotations(container, declaredMethod, annotationClass
+                     .getName(), annotation);
             }
-
-            if (!foundMethod)
+         } else
+         {
+            List params = method.getMethodParams();
+            if (params == null)
             {
-               methods = ejbClass.getDeclaredMethods();
+               java.lang.reflect.Method[] methods = ejbClass.getMethods();
+               boolean foundMethod = false;
                for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
                {
                   if (methods[methodIndex].getName().equals(methodName))
                   {
                      log.debug("adding " + annotationClass.getName()
-                           + " method annotation to " + ejbClass.getName()
-                           + "." + methodName);
+                           + " method annotation to " + ejbClass.getName() + "."
+                           + methodName);
                      annotations.addAnnotation(methods[methodIndex],
                            annotationClass, annotation);
                      overrideAnnotations(container, methods[methodIndex],
                            annotationClass.getName(), annotation);
                      foundMethod = true;
-
+   
                   }
                }
-            }
-
-            if (!foundMethod)
+   
+               if (!foundMethod)
+               {
+                  methods = ejbClass.getDeclaredMethods();
+                  for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
+                  {
+                     if (methods[methodIndex].getName().equals(methodName))
+                     {
+                        log.debug("adding " + annotationClass.getName()
+                              + " method annotation to " + ejbClass.getName()
+                              + "." + methodName);
+                        annotations.addAnnotation(methods[methodIndex],
+                              annotationClass, annotation);
+                        overrideAnnotations(container, methods[methodIndex],
+                              annotationClass.getName(), annotation);
+                        foundMethod = true;
+   
+                     }
+                  }
+               }
+   
+               if (!foundMethod)
+               {
+                  java.lang.reflect.Field member = ejbClass
+                        .getDeclaredField(methodName);
+                  if (member != null)
+                  {
+                     log.debug("adding " + annotationClass.getName()
+                           + " field annotation to " + ejbClass.getName() + "."
+                           + methodName);
+                     annotations
+                           .addAnnotation(member, annotationClass, annotation);
+                     overrideAnnotations(container, member, annotationClass
+                           .getName(), annotation);
+                  }
+               }
+            } else
             {
-               java.lang.reflect.Field member = ejbClass
-                     .getDeclaredField(methodName);
-               if (member != null)
+               Class[] methodSignature = new Class[params.size()];
+               Iterator paramIterator = params.iterator();
+               int paramIndex = 0;
+               while (paramIterator.hasNext())
                {
-                  log.debug("adding " + annotationClass.getName()
-                        + " field annotation to " + ejbClass.getName() + "."
-                        + methodName);
-                  annotations
-                        .addAnnotation(member, annotationClass, annotation);
-                  overrideAnnotations(container, member, annotationClass
-                        .getName(), annotation);
+                  String param = (String) paramIterator.next();
+                  Class paramClass = null;
+                  if (param.equals("boolean"))
+                     paramClass = boolean.class;
+                  else if (param.equals("int"))
+                     paramClass = int.class;
+                  else if (param.equals("long"))
+                     paramClass = long.class;
+                  else if (param.equals("short"))
+                     paramClass = short.class;
+                  else if (param.equals("byte"))
+                     paramClass = byte.class;
+                  else if (param.equals("char"))
+                     paramClass = char.class;
+                  else
+                     paramClass = di.getClassLoader().loadClass(param);
+                  methodSignature[paramIndex++] = paramClass;
                }
+               java.lang.reflect.Member member = ejbClass.getMethod(methodName,
+                     methodSignature);
+               log.debug("adding " + annotationClass.getName()
+                     + " method annotation to " + ejbClass.getName() + "."
+                     + methodName);
+               annotations.addAnnotation(member, annotationClass, annotation);
+               overrideAnnotations(container, member, annotationClass.getName(),
+                     annotation);
             }
-         } else
-         {
-            Class[] methodSignature = new Class[params.size()];
-            Iterator paramIterator = params.iterator();
-            int paramIndex = 0;
-            while (paramIterator.hasNext())
-            {
-               String param = (String) paramIterator.next();
-               Class paramClass = null;
-               if (param.equals("boolean"))
-                  paramClass = boolean.class;
-               else if (param.equals("int"))
-                  paramClass = int.class;
-               else if (param.equals("long"))
-                  paramClass = long.class;
-               else if (param.equals("short"))
-                  paramClass = short.class;
-               else if (param.equals("byte"))
-                  paramClass = byte.class;
-               else if (param.equals("char"))
-                  paramClass = char.class;
-               else
-                  paramClass = di.getClassLoader().loadClass(param);
-               methodSignature[paramIndex++] = paramClass;
-            }
-            java.lang.reflect.Member member = ejbClass.getMethod(methodName,
-                  methodSignature);
-            log.debug("adding " + annotationClass.getName()
-                  + " method annotation to " + ejbClass.getName() + "."
-                  + methodName);
-            annotations.addAnnotation(member, annotationClass, annotation);
-            overrideAnnotations(container, member, annotationClass.getName(),
-                  annotation);
          }
       }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Unable to create annotation from method/field " + method.getMethodName() + " for EJB " + container.getEjbName(), e);
+      }
    }
 
    private static String getParameters(java.lang.reflect.Method m)

Added: trunk/ejb3/src/resources/test/descriptortypo/META-INF/ejb-jar.xml
===================================================================
--- trunk/ejb3/src/resources/test/descriptortypo/META-INF/ejb-jar.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/descriptortypo/META-INF/ejb-jar.xml	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+        version="3.0">
+   <description>JBoss test application </description>
+   <display-name>Test</display-name>
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatelessBean</ejb-name>
+         <remote>org.jboss.ejb3.test.descriptortypo.StatelessRemote</remote>
+         <ejb-class>org.jboss.ejb3.test.descriptortypo.StatelessBean</ejb-class>
+         <session-type>Stateless</session-type>
+         <remove-method>
+            <bean-method>
+               <method-name>remove</method-name>
+            </bean-method>
+         </remove-method>
+      </session>
+      <session>
+         <ejb-name>StatefulBean</ejb-name>
+         <remove-method>
+            <bean-method>
+               <method-name>remove</method-name>
+               <method-params>
+                  <method-param>int</method-param>
+               </method-params>
+            </bean-method>
+         </remove-method>
+      </session>
+   </enterprise-beans>
+</ejb-jar>
+

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulBean.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.descriptortypo;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulRemote.class)
+public class StatefulBean implements StatefulRemote
+{
+   private static final Logger log = Logger.getLogger(StatefulBean.class);
+   
+   public void test() throws Exception
+   {
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatefulRemote.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.descriptortypo;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulRemote
+{
+   void test() throws Exception;
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessBean.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,36 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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.ejb3.test.descriptortypo;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class StatelessBean implements StatelessRemote
+{
+	private static final Logger log = Logger.getLogger(StatelessBean.class);
+	   
+	public void test() throws Exception
+	{
+	}
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/StatelessRemote.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,30 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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.ejb3.test.descriptortypo;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+   void test() throws Exception;
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/unit/TypoTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/unit/TypoTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/descriptortypo/unit/TypoTestCase.java	2007-03-15 16:59:55 UTC (rev 61340)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.descriptortypo.unit;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.descriptortypo.StatefulRemote;
+import org.jboss.ejb3.test.descriptortypo.StatelessRemote;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+
+public class TypoTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(TypoTestCase.class);
+
+   public TypoTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testTypos() throws Exception
+   {
+      InitialContext jndiContext = new InitialContext();
+      
+      try
+      {
+         StatefulRemote sfsb = (StatefulRemote)jndiContext.lookup("StatefulBean/remote");
+         fail("StatefulBean should not have deployed");
+      }
+      catch (Exception e)
+      {
+      }
+      
+      try
+      {
+         StatelessRemote slsb = (StatelessRemote)jndiContext.lookup("StatelessBean/remote");
+         fail("StatelessBean should not have deployed");
+      }
+      catch (Exception e)
+      {
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(TypoTestCase.class, "descriptortypo-test.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list