[jboss-cvs] JBossAS SVN: r108645 - in projects/metadata/ejb/trunk/src: main/java/org/jboss/metadata/annotation/creator/ejb/jboss and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 19 06:08:04 EDT 2010


Author: jaikiran
Date: 2010-10-19 06:08:04 -0400 (Tue, 19 Oct 2010)
New Revision: 108645

Added:
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionOne.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionThree.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionTwo.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/unit/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/unit/ApplicationExceptionTestCase.java
   projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/
   projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/exception/
   projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/exception/ejb-jar.xml
Modified:
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ApplicationExceptionProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ApplicationExceptionMetaData.java
Log:
JBMETA-304 Metadata support added for "inherited" attribute of application-exception element and it's corresponding annotation

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java	2010-10-18 22:13:42 UTC (rev 108644)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -62,6 +62,7 @@
       ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
       metaData.setExceptionClass(element.getName());
       metaData.setRollback(annotation.rollback());
+      metaData.setInherited(annotation.inherited());
       
       return metaData;
    }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ApplicationExceptionProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ApplicationExceptionProcessor.java	2010-10-18 22:13:42 UTC (rev 108644)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/ApplicationExceptionProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -62,6 +62,7 @@
       ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
       metaData.setExceptionClass(element.getName());
       metaData.setRollback(annotation.rollback());
+      metaData.setInherited(annotation.inherited());
       
       return metaData;
    }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ApplicationExceptionMetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ApplicationExceptionMetaData.java	2010-10-18 22:13:42 UTC (rev 108644)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ApplicationExceptionMetaData.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -31,7 +31,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
- at XmlType(name="application-exceptionType", propOrder={"exceptionClass", "rollback"})
+ at XmlType(name="application-exceptionType", propOrder={"exceptionClass", "rollback", "inherited"})
 public class ApplicationExceptionMetaData extends NamedMetaData
 {
    /** The serialVersionUID */
@@ -40,6 +40,8 @@
    /** Whether to rollback */
    private boolean rollback = false;
    
+   private Boolean inherited;
+   
    /**
     * Create a new ApplicationExceptionMetaData.
     */
@@ -88,4 +90,24 @@
    {
       this.rollback = rollback;
    }
+   
+   /**
+    * Returns true if the application-exception is marked as "inherited". Returns false if 
+    * "inherited" is explicitly marked as false. In case the application-exception doesn't
+    * explicitly specify the "inherited" attribute, then this method returns null.
+    * @return
+    */
+   public Boolean isInherited()
+   {
+      return this.inherited;
+   }
+   
+   /**
+    * Sets the "inherited" attribute of application-exception
+    * @param inherited True if the application-exception is to be marked as "inherited". False otherwise
+    */
+   public void setInherited(Boolean inherited)
+   {
+      this.inherited = inherited;
+   }
 }

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionOne.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionOne.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionOne.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metadata.ejb.test.application.exception;
+
+/**
+ * AppExceptionOne
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AppExceptionOne extends Exception
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionThree.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionThree.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionThree.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metadata.ejb.test.application.exception;
+
+/**
+ * AppExceptionThree
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AppExceptionThree extends NumberFormatException
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionTwo.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionTwo.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/AppExceptionTwo.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metadata.ejb.test.application.exception;
+
+/**
+ * AppExceptionTwo
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AppExceptionTwo extends RuntimeException
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/unit/ApplicationExceptionTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/unit/ApplicationExceptionTestCase.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/application/exception/unit/ApplicationExceptionTestCase.java	2010-10-19 10:08:04 UTC (rev 108645)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metadata.ejb.test.application.exception.unit;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URL;
+
+import javax.ejb.ApplicationException;
+
+import junit.framework.Assert;
+
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.test.application.exception.AppExceptionOne;
+import org.jboss.metadata.ejb.test.application.exception.AppExceptionThree;
+import org.jboss.metadata.ejb.test.application.exception.AppExceptionTwo;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests the metadata processing of application-exception xml element and it's corresponding
+ * {@link ApplicationException} annotation
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ApplicationExceptionTestCase
+{
+
+   private static UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+
+   private static MutableSchemaResolver schemaBindingResolver;
+
+   @BeforeClass
+   public static void beforeClass()
+   {
+      schemaBindingResolver = new MultiClassSchemaResolver();
+      schemaBindingResolver.mapLocationToClass("ejb-jar_3_1.xsd", EjbJar31MetaData.class);
+   }
+
+   /**
+    * Test that the "inherited" attribute of the application-exception element in
+    * ejb-jar.xml is processed correctly during metadata creation.
+    * 
+    * @throws Exception
+    */
+   @Test
+   public void testInheritedApplicationException() throws Exception
+   {
+      EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class,
+            "/org/jboss/metadata/ejb/test/application/exception/ejb-jar.xml");
+      assertNotNull(jarMetaData);
+
+      ApplicationExceptionsMetaData appExceptions = jarMetaData.getAssemblyDescriptor().getApplicationExceptions();
+      Assert.assertNotNull("No application exceptions found in metadata", appExceptions);
+      
+      ApplicationExceptionMetaData appExceptionOne = appExceptions.get(AppExceptionOne.class.getName());
+      Assert.assertNotNull("inherited attribute was *not* expected to be null on Application exception " + AppExceptionOne.class.getName(), appExceptionOne.isInherited());
+      Assert.assertTrue("Application exception " + AppExceptionOne.class.getName() + " was expected to be inherited", appExceptionOne.isInherited());
+      
+      ApplicationExceptionMetaData appExceptionTwo = appExceptions.get(AppExceptionTwo.class.getName());
+      Assert.assertNotNull("inherited attribute was *not* expected to be null on Application exception " + AppExceptionTwo.class.getName(), appExceptionTwo.isInherited());
+      Assert.assertFalse("Application exception " + AppExceptionTwo.class.getName() + " was *not* expected to be inherited", appExceptionTwo.isInherited());
+
+      ApplicationExceptionMetaData appExceptionThree = appExceptions.get(AppExceptionThree.class.getName());
+      Assert.assertNull("inherited attribute was expected to be null on Application exception " + AppExceptionThree.class.getName(), appExceptionThree.isInherited());
+
+   }
+   
+   /**
+    * Utility method
+    * @param <T>
+    * @param type
+    * @param resource
+    * @return
+    * @throws JBossXBException
+    */
+   private static <T> T unmarshal(Class<T> type, String resource) throws JBossXBException
+   {
+      Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+      unmarshaller.setValidation(false);
+      URL url = type.getResource(resource);
+      if (url == null)
+         throw new IllegalArgumentException("Failed to find resource " + resource);
+      return type.cast(unmarshaller.unmarshal(url.toString(), schemaBindingResolver));
+   }
+}

Added: projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/exception/ejb-jar.xml
===================================================================
--- projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/exception/ejb-jar.xml	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/application/exception/ejb-jar.xml	2010-10-19 10:08:04 UTC (rev 108645)
@@ -0,0 +1,24 @@
+<?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_1.xsd"
+    version="3.1">
+    <enterprise-beans>
+        <session>
+            <ejb-name>InheritedAppExceptionBean</ejb-name>
+        </session>
+    </enterprise-beans>
+    <assembly-descriptor>
+        <application-exception>
+            <exception-class>org.jboss.metadata.ejb.test.application.exception.AppExceptionOne</exception-class>
+            <inherited>true</inherited>
+        </application-exception>
+        <application-exception>
+            <exception-class>org.jboss.metadata.ejb.test.application.exception.AppExceptionTwo</exception-class>
+            <inherited>false</inherited>
+        </application-exception>
+        <application-exception>
+            <exception-class>org.jboss.metadata.ejb.test.application.exception.AppExceptionThree</exception-class>
+        </application-exception>
+
+    </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file



More information about the jboss-cvs-commits mailing list