[jboss-cvs] JBossAS SVN: r77074 - in projects/microcontainer/trunk/kernel: src/main/org/jboss/beans/metadata/plugins and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 14 09:19:23 EDT 2008


Author: adrian at jboss.org
Date: 2008-08-14 09:19:22 -0400 (Thu, 14 Aug 2008)
New Revision: 77074

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CachingAnnotationMetaData.java
Modified:
   projects/microcontainer/trunk/kernel/pom.xml
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
Log:
[JBMICROCONT-339] - Use the classloader when creating annotations during remove and add CachingAnnotationMetaData optimization so we don't always have to do the annotation construction.

Modified: projects/microcontainer/trunk/kernel/pom.xml
===================================================================
--- projects/microcontainer/trunk/kernel/pom.xml	2008-08-14 12:42:24 UTC (rev 77073)
+++ projects/microcontainer/trunk/kernel/pom.xml	2008-08-14 13:19:22 UTC (rev 77074)
@@ -36,9 +36,9 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
+        <!--configuration>
           <testFailureIgnore>true</testFailureIgnore>
-        </configuration>
+        </configuration-->
       </plugin>   	   
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java	2008-08-14 12:42:24 UTC (rev 77073)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java	2008-08-14 13:19:22 UTC (rev 77074)
@@ -26,13 +26,13 @@
 import java.util.Iterator;
 
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.XmlTransient;
 
 import org.jboss.annotation.factory.AnnotationCreator;
 import org.jboss.annotation.factory.ast.TokenMgrError;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.CachingAnnotationMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.util.JBossObject;
@@ -48,7 +48,7 @@
  */
 @XmlType(name="annotationType", propOrder={"annotation"})
 public class AbstractAnnotationMetaData extends JBossObject
-   implements AnnotationMetaData, Serializable
+   implements CachingAnnotationMetaData, Serializable
 {
    private static final long serialVersionUID = 2L;
 
@@ -100,6 +100,8 @@
    
    public Annotation getAnnotationInstance(ClassLoader cl)
    {
+      if (ann != null)
+         return ann;
       try
       {
          String annString = annotation;
@@ -126,6 +128,14 @@
       return ann;
    }
 
+   public Annotation removeAnnotation()
+   {
+      Annotation result = ann;
+      ann = null;
+      flushJBossObjectCache();
+      return result;
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
       String ann = getAnnotation().trim();

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CachingAnnotationMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CachingAnnotationMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CachingAnnotationMetaData.java	2008-08-14 13:19:22 UTC (rev 77074)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.beans.metadata.spi;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * CachingAnnotationMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CachingAnnotationMetaData extends AnnotationMetaData
+{
+   /**
+    * Retrieve any cached annotation and flush it
+    * 
+    * @return the annotation instance or null if non was constructed
+    */
+   Annotation removeAnnotation();
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java	2008-08-14 12:42:24 UTC (rev 77073)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelScopeInfo.java	2008-08-14 13:19:22 UTC (rev 77074)
@@ -29,6 +29,7 @@
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.beans.metadata.spi.AnnotationMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.CachingAnnotationMetaData;
 import org.jboss.beans.metadata.spi.PropertyMetaData;
 import org.jboss.dependency.plugins.AbstractScopeInfo;
 import org.jboss.dependency.spi.Controller;
@@ -320,7 +321,11 @@
          }
          else
          {
-            Annotation annotationInstance = annotation.getAnnotationInstance();
+            Annotation annotationInstance = null;
+            if (annotation instanceof CachingAnnotationMetaData)
+               annotationInstance = ((CachingAnnotationMetaData) annotation).removeAnnotation();
+            if (annotationInstance == null)
+               annotationInstance = annotation.getAnnotationInstance(classloader);
             // Null means we never constructed it in the first place 
             if (annotationInstance != null)
                mutable.removeAnnotation(annotationInstance.annotationType());

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2008-08-14 12:42:24 UTC (rev 77073)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2008-08-14 13:19:22 UTC (rev 77074)
@@ -66,6 +66,7 @@
       suite.addTest(AnonymousBeansTestCase.suite());
       suite.addTest(AnonymousBeansXMLTestCase.suite());
       suite.addTest(MutableMetaDataTestCase.suite());
+      suite.addTest(AnnotationRedeployTestCase.suite());
       suite.addTest(MockServiceBindingTestCase.suite());
       // bean container tests
       suite.addTest(BeanContainerUsageTestCase.suite());




More information about the jboss-cvs-commits mailing list