[jboss-cvs] JBossAS SVN: r82182 - in projects/metadata/trunk/src: test/java/org/jboss/test/metadata and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 10 02:25:21 EST 2008


Author: wolfc
Date: 2008-12-10 02:25:21 -0500 (Wed, 10 Dec 2008)
New Revision: 82182

Added:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeout.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeoutBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/unit/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/unit/MergeBeanDefinitionsTestCase.java
   projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/
   projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/unit/
   projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/unit/ejb-jar.xml
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossEnterpriseBeansMetaData.java
Log:
JBMETA-154: merging based on ejb-name (ignoring ejb-class)

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossEnterpriseBeansMetaData.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossEnterpriseBeansMetaData.java	2008-12-10 06:41:49 UTC (rev 82181)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossEnterpriseBeansMetaData.java	2008-12-10 07:25:21 UTC (rev 82182)
@@ -21,10 +21,7 @@
 */
 package org.jboss.metadata.ejb.jboss;
 
-import java.util.HashMap;
-
 import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.spec.EnterpriseBeansMap;
@@ -198,24 +195,7 @@
    
    public void merge(JBossEnterpriseBeansMetaData override, JBossEnterpriseBeansMetaData original)
    {
-      HashMap<String, String> ejbClassToName = new HashMap<String, String>();
-      if(override != null)
-      {
-         if(override.getId() != null)
-            setId(override.getId());
-         for(JBossEnterpriseBeanMetaData bean : override)
-         {
-            String className = bean.getEjbClass();
-            if(className != null)
-            {
-               // Use the unqualified name
-               int dot = className.lastIndexOf('.');
-               if(dot >= 0)
-                  className = className.substring(dot+1);
-               ejbClassToName.put(className, bean.getEjbName());
-            }
-         }         
-      }
+      super.merge(override, original);
       
       // first get the original beans without the corresponding override entry
       if(original != null)
@@ -229,10 +209,7 @@
                JBossEnterpriseBeanMetaData match = override.get(ejbName);
                if(match == null)
                {
-                  // Lookup by the unqualified ejb class
-                  String xmlEjbName = ejbClassToName.get(ejbName);
-                  if(xmlEjbName == null)
-                     add(bean);
+                  add(bean);
                }
             }
             else
@@ -252,19 +229,6 @@
             {
                String name = bean.getEjbName();
                annBean = original.get(name);
-               if(annBean == null)
-               {
-                  // Lookup by the unqualified ejb class
-                  String className = bean.getEjbClass();
-                  if(className != null)
-                  {
-                     // Use the unqualified name
-                     int dot = className.lastIndexOf('.');
-                     if(dot >= 0)
-                        className = className.substring(dot+1);
-                     annBean = original.get(className);
-                  }
-               }
             }
 
             // Merge

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeout.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeout.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeout.java	2008-12-10 07:25:21 UTC (rev 82182)
@@ -0,0 +1,31 @@
+/*
+ * 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.metadata.jbmeta154;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface StatefulTimeout
+{
+
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeoutBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeoutBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/StatefulTimeoutBean.java	2008-12-10 07:25:21 UTC (rev 82182)
@@ -0,0 +1,35 @@
+/*
+ * 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.metadata.jbmeta154;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote(StatefulTimeout.class)
+public class StatefulTimeoutBean implements StatefulTimeout
+{
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/unit/MergeBeanDefinitionsTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/unit/MergeBeanDefinitionsTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta154/unit/MergeBeanDefinitionsTestCase.java	2008-12-10 07:25:21 UTC (rev 82182)
@@ -0,0 +1,97 @@
+/*
+ * 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.metadata.jbmeta154.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.jboss.test.metadata.ejb.AbstractEJBEverythingTest;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MergeBeanDefinitionsTestCase extends AbstractEJBEverythingTest
+{
+   public MergeBeanDefinitionsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static SchemaBindingResolver initResolver()
+   {
+      DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+//      resolver.addClassBindingForLocation("ejb-jar_2_0.dtd", EjbJar20MetaData.class);
+//      resolver.addClassBindingForLocation("ejb-jar_2_1.xsd", EjbJar21MetaData.class);
+      resolver.addClassBindingForLocation("ejb-jar_3_0.xsd", EjbJar30MetaData.class);
+//      resolver.addClassBindingForLocation("jboss_3_0.dtd", JBoss50DTDMetaData.class);
+//      resolver.addClassBindingForLocation("jboss_3_2.dtd", JBoss50DTDMetaData.class);
+//      resolver.addClassBindingForLocation("jboss_4_0.dtd", JBoss50DTDMetaData.class);
+//      resolver.addClassBindingForLocation("jboss_4_2.dtd", JBoss50DTDMetaData.class);
+//      resolver.addClassBindingForLocation("jboss_5_0.dtd", JBoss50DTDMetaData.class);
+      resolver.addClassBindingForLocation("jboss_5_0.xsd", JBoss50MetaData.class);
+      // Set the JBoss50DTDMetaData class as the default for the jboss root element
+//      resolver.addClassBindingForLocation("jboss", JBoss50DTDMetaData.class);
+      // Workaround wildard resolution slowness
+      resolver.addClassBinding("http://www.jboss.com/xml/ns/javaee", JBoss50MetaData.class);
+      return resolver;
+   }
+
+   @ScanPackage("org.jboss.test.metadata.jbmeta154")
+   public void test1() throws Exception
+   {
+      EjbJarMetaData ejbJarMetaData = unmarshal("ejb-jar.xml", EjbJarMetaData.class);
+
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      
+      JBoss50MetaData annotatedMetaData = creator.create(classes);
+      
+      JBossMetaData specMetaData = new JBoss50MetaData();
+      specMetaData.merge(null, ejbJarMetaData);
+      
+      JBoss50MetaData mergedMetaData = new JBoss50MetaData();
+      mergedMetaData.merge(specMetaData, annotatedMetaData);
+      
+      assertEquals("Both the annotated and the described bean should be here", 2, mergedMetaData.getEnterpriseBeans().size());
+      
+      JBossSessionBeanMetaData annotatedBean = (JBossSessionBeanMetaData) mergedMetaData.getEnterpriseBean("StatefulTimeoutBean");
+      assertNotNull(annotatedBean);
+      
+      JBossSessionBeanMetaData describedBean = (JBossSessionBeanMetaData) mergedMetaData.getEnterpriseBean("StatefulTimeoutBean2");
+      assertNotNull(describedBean);
+   }
+}

Added: projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/unit/ejb-jar.xml
===================================================================
--- projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/unit/ejb-jar.xml	                        (rev 0)
+++ projects/metadata/trunk/src/test/resources/org/jboss/test/metadata/jbmeta154/unit/ejb-jar.xml	2008-12-10 07:25:21 UTC (rev 82182)
@@ -0,0 +1,13 @@
+<?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">
+    <enterprise-beans>
+      <session>
+         <ejb-name>StatefulTimeoutBean2</ejb-name>
+         <ejb-class>org.jboss.test.metadata.jbmeta154.StatefulTimeoutBean</ejb-class>
+         <session-type>Stateful</session-type>
+      </session>
+    </enterprise-beans>
+</ejb-jar>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list