[jboss-cvs] JBossAS SVN: r75446 - in projects/jboss-deployers/trunk: deployers-impl/src/tests/org/jboss/test/deployers/annotations/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 7 11:00:51 EDT 2008
Author: alesj
Date: 2008-07-07 11:00:51 -0400 (Mon, 07 Jul 2008)
New Revision: 75446
Added:
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ClassElement.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ParametersElement.java
projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationEnvTestCase.java
projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationsTest.java
projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/AnnotationEnvironment.java
projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/Element.java
projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractAnnotationDeployer.java
Log:
[JBDEPLOY-57]; make lookup for annotated classes lazy.
Added: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/AbstractElement.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.AnnotatedElement;
+
+import org.jboss.deployers.spi.annotations.Element;
+
+/**
+ * Abstract annotations element.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractElement<A extends Annotation, M extends AnnotatedElement> extends WeakClassLoaderHolder implements Element<A, M>
+{
+ protected String className;
+ protected Class<A> annClass;
+
+ private SoftReference<Class<?>> classRef;
+
+ public AbstractElement(ClassLoader classLoader, String className, Class<A> annClass)
+ {
+ super(classLoader);
+
+ if (className == null)
+ throw new IllegalArgumentException("Null className");
+ if (annClass == null)
+ throw new IllegalArgumentException("Null annotation class");
+
+ this.className = className;
+ this.annClass = annClass;
+ }
+
+ public String getOwnerClassName()
+ {
+ return className;
+ }
+
+ public Class<?> getOwner()
+ {
+ if (classRef != null)
+ {
+ Class<?> clazz = classRef.get();
+ if (clazz != null)
+ return clazz;
+ }
+
+ Class<?> clazz = loadClass(className);
+ classRef = new SoftReference<Class<?>>(clazz);
+ return clazz;
+ }
+
+ public A getAnnotation()
+ {
+ AnnotatedElement annotatedElement = getAnnotatedElement();
+ return annotatedElement.getAnnotation(annClass);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ClassElement.java (from rev 75153, projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ClassElement.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ClassElement.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.deployers.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * Class annotations element.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ClassElement<A extends Annotation, M extends AnnotatedElement> extends AbstractElement<A, M>
+{
+ public ClassElement(ClassLoader classLoader, String className, Class<A> annClass)
+ {
+ super(classLoader, className, annClass);
+ }
+
+ @SuppressWarnings("unchecked")
+ public M getAnnotatedElement()
+ {
+ AnnotatedElement em = getOwner();
+ return (M)em;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -24,7 +24,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -123,29 +123,12 @@
/**
* Transform class names into classes.
*
- * @param pairs the cs pairs
- * @return classes
- */
- protected Set<Class<?>> transformToClasses(Set<ClassSignaturePair> pairs)
- {
- if (pairs.isEmpty())
- return Collections.emptySet();
-
- Set<Class<?>> classes = new HashSet<Class<?>>(pairs.size());
- for (ClassSignaturePair pair : pairs)
- classes.add(loadClass(pair.getClassName()));
- return classes;
- }
-
- /**
- * Transform class names into classes.
- *
* @param type the annotation type
* @param annClass the annotation class
* @param aoClass the ao class
* @return classes
*/
- protected <A extends Annotation, M extends AccessibleObject> Set<Element<A, M>> transformToElements(
+ protected <A extends Annotation, M extends AnnotatedElement> Set<Element<A, M>> transformToElements(
ElementType type,
Class<A> annClass,
Class<M> aoClass
@@ -160,7 +143,9 @@
for (ClassSignaturePair pair : pairs)
{
Element<A, M> element;
- if (type == ElementType.PARAMETER)
+ if (type == ElementType.TYPE)
+ element = new ClassElement<A, M>(classLoader, pair.getClassName(), annClass);
+ else if (type == ElementType.PARAMETER)
element = new ParametersElement<A,M>(classLoader, pair.getClassName(), pair.getSignature(), annClass, aoClass);
else
element = new DefaultElement<A,M>(classLoader, pair.getClassName(), pair.getSignature(), annClass, aoClass);
@@ -174,9 +159,9 @@
return getCSPairs(annotation, ElementType.TYPE).isEmpty() == false;
}
- public Set<Class<?>> classIsAnnotatedWith(Class<? extends Annotation> annotation)
+ public <A extends Annotation> Set<Element<A, Class>> classIsAnnotatedWith(Class<A> annotation)
{
- return transformToClasses(getCSPairs(annotation, ElementType.TYPE));
+ return transformToElements(ElementType.TYPE, annotation, Class.class);
}
public <A extends Annotation> Set<Element<A, Constructor>> classHasConstructorAnnotatedWith(Class<A> annotation)
@@ -194,9 +179,9 @@
return transformToElements(ElementType.METHOD, annotation, Method.class);
}
- public <A extends Annotation> Set<Element<A, AccessibleObject>> classHasParameterAnnotatedWith(Class<A> annotation)
+ public <A extends Annotation> Set<Element<A, AnnotatedElement>> classHasParameterAnnotatedWith(Class<A> annotation)
{
- return transformToElements(ElementType.PARAMETER, annotation, AccessibleObject.class);
+ return transformToElements(ElementType.PARAMETER, annotation, AnnotatedElement.class);
}
/**
@@ -219,7 +204,7 @@
return hasClassAnnotatedWith(getAnnotationClass(annotationName));
}
- public Set<Class<?>> classIsAnnotatedWith(String annotationName)
+ public Set<Element<Annotation, Class>> classIsAnnotatedWith(String annotationName)
{
return classIsAnnotatedWith(getAnnotationClass(annotationName));
}
@@ -239,7 +224,7 @@
return classHasMethodAnnotatedWith(getAnnotationClass(annotationName));
}
- public Set<Element<Annotation, AccessibleObject>> classHasParameterAnnotatedWith(String annotationName)
+ public Set<Element<Annotation, AnnotatedElement>> classHasParameterAnnotatedWith(String annotationName)
{
return classHasParameterAnnotatedWith(getAnnotationClass(annotationName));
}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultElement.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,16 +22,14 @@
package org.jboss.deployers.plugins.annotations;
import java.lang.annotation.Annotation;
-import java.lang.ref.SoftReference;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
-import org.jboss.deployers.spi.annotations.Element;
import org.jboss.metadata.spi.signature.ConstructorParametersSignature;
import org.jboss.metadata.spi.signature.ConstructorSignature;
import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
import org.jboss.metadata.spi.signature.MethodSignature;
import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.metadata.spi.signature.MethodParametersSignature;
import org.jboss.reflect.plugins.introspection.ReflectionUtils;
/**
@@ -39,58 +37,28 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class DefaultElement<A extends Annotation, M extends AccessibleObject> extends WeakClassLoaderHolder implements Element<A, M>
+public class DefaultElement<A extends Annotation, M extends AnnotatedElement> extends AbstractElement<A, M>
{
- protected String className;
protected Signature signature;
- protected Class<A> annClass;
protected Class<M> aoClass;
- private SoftReference<Class<?>> classRef;
-
public DefaultElement(ClassLoader classLoader, String className, Signature signature, Class<A> annClass, Class<M> aoClass)
{
- super(classLoader);
+ super(classLoader, className, annClass);
- if (className == null)
- throw new IllegalArgumentException("Null className");
if (signature == null)
throw new IllegalArgumentException("Null signature");
- if (annClass == null)
- throw new IllegalArgumentException("Null annotation class");
if (aoClass == null)
throw new IllegalArgumentException("Null ao class");
- this.className = className;
this.signature = signature;
- this.annClass = annClass;
this.aoClass = aoClass;
}
- public Class<?> getOwner()
+ public M getAnnotatedElement()
{
- if (classRef != null)
- {
- Class<?> clazz = classRef.get();
- if (clazz != null)
- return clazz;
- }
+ AnnotatedElement result = null;
- Class<?> clazz = loadClass(className);
- classRef = new SoftReference<Class<?>>(clazz);
- return clazz;
- }
-
- public A getAnnotation()
- {
- AccessibleObject accessibleObject = getAccessibleObject();
- return accessibleObject.getAnnotation(annClass);
- }
-
- public M getAccessibleObject()
- {
- AccessibleObject result = null;
-
Class<?> clazz = getOwner();
if (signature instanceof ConstructorSignature || signature instanceof ConstructorParametersSignature)
{
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ParametersElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ParametersElement.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/ParametersElement.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,7 +22,7 @@
package org.jboss.deployers.plugins.annotations;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -36,7 +36,7 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class ParametersElement<A extends Annotation, M extends AccessibleObject> extends DefaultElement<A, M>
+public class ParametersElement<A extends Annotation, M extends AnnotatedElement> extends DefaultElement<A, M>
{
public ParametersElement(ClassLoader classLoader, String className, Signature signature, Class<A> annClass, Class<M> aoClass)
{
Modified: projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationEnvTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationEnvTestCase.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationEnvTestCase.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,7 +22,7 @@
package org.jboss.test.deployers.annotations.test;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -80,40 +80,44 @@
assertLoaded(unit, "org.jboss.test.deployers.annotations.support.TestAnnotation");
AnnotationEnvironment env = getAnnotationEnvironment(unit);
- Set<Class<?>> classes = env.classIsAnnotatedWith(taClass);
+ Set<Element<TestAnnotation, Class>> classes = env.classIsAnnotatedWith(taClass);
assertNotNull(classes);
assertEquals(1, classes.size());
- assertEquals(AnnotationsHolder.class.getName(), classes.iterator().next().getName());
+ assertEquals(AnnotationsHolder.class.getName(), classes.iterator().next().getOwnerClassName());
+ assertNotLoaded(unit, "org.jboss.test.deployers.annotations.support.AnnotationsHolder");
- assertLoaded(unit, "org.jboss.test.deployers.annotations.support.AnnotationsHolder");
+ Element<TestAnnotation, Class> ecl = getSingleton(env.classIsAnnotatedWith(taClass));
+ Annotation tacl = ecl.getAnnotation();
+ assertNotNull(tacl);
+ assertEquals("class", getValue(tacl));
Element<TestAnnotation, Constructor> ec = getSingleton(env.classHasConstructorAnnotatedWith(taClass));
Annotation ta = ec.getAnnotation();
assertNotNull(ta);
assertEquals("constructor", getValue(ta));
- assertInstanceOf(ec.getAccessibleObject(), Constructor.class, false);
+ assertInstanceOf(ec.getAnnotatedElement(), Constructor.class, false);
Element<TestAnnotation, Field> ef = getSingleton(env.classHasFieldAnnotatedWith(taClass));
ta = ef.getAnnotation();
assertNotNull(ta);
assertEquals("field", getValue(ta));
- assertInstanceOf(ef.getAccessibleObject(), Field.class, false);
+ assertInstanceOf(ef.getAnnotatedElement(), Field.class, false);
Element<TestAnnotation, Method> em = getSingleton(env.classHasMethodAnnotatedWith(taClass));
ta = em.getAnnotation();
assertNotNull(ta);
assertEquals("method", getValue(ta));
- assertInstanceOf(em.getAccessibleObject(), Method.class, false);
+ assertInstanceOf(em.getAnnotatedElement(), Method.class, false);
- Set<Element<TestAnnotation, AccessibleObject>> eps = env.classHasParameterAnnotatedWith(taClass);
+ Set<Element<TestAnnotation, AnnotatedElement>> eps = env.classHasParameterAnnotatedWith(taClass);
assertNotNull(eps);
assertEquals(2, eps.size());
- for (Element<TestAnnotation, AccessibleObject> ep : eps)
+ for (Element<TestAnnotation, AnnotatedElement> ep : eps)
{
ta = ep.getAnnotation();
assertNotNull(ta);
Object value = getValue(ta);
- AccessibleObject ao = ep.getAccessibleObject();
+ AnnotatedElement ao = ep.getAnnotatedElement();
if ("cparameter".equals(value))
assertInstanceOf(ao, Constructor.class, false);
else if ("mparameter".equals(value))
@@ -152,40 +156,44 @@
assertLoaded(unit, "org.jboss.test.deployers.annotations.support.TestAnnotation");
AnnotationEnvironment env = getAnnotationEnvironment(unit);
- Set<Class<?>> classes = env.classIsAnnotatedWith(annotationName);
+ Set<Element<Annotation, Class>> classes = env.classIsAnnotatedWith(annotationName);
assertNotNull(classes);
assertEquals(1, classes.size());
- assertEquals(AnnotationsHolder.class.getName(), classes.iterator().next().getName());
+ assertEquals(AnnotationsHolder.class.getName(), classes.iterator().next().getOwnerClassName());
+ assertNotLoaded(unit, "org.jboss.test.deployers.annotations.support.AnnotationsHolder");
- assertLoaded(unit, "org.jboss.test.deployers.annotations.support.AnnotationsHolder");
+ Element<Annotation, Class> ecl = getSingleton(env.classIsAnnotatedWith(annotationName));
+ Annotation tacl = ecl.getAnnotation();
+ assertNotNull(tacl);
+ assertEquals("class", getValue(tacl));
Element<Annotation, Constructor> ec = getSingleton(env.classHasConstructorAnnotatedWith(annotationName));
Annotation ta = ec.getAnnotation();
assertNotNull(ta);
assertEquals("constructor", getValue(ta));
- assertInstanceOf(ec.getAccessibleObject(), Constructor.class, false);
+ assertInstanceOf(ec.getAnnotatedElement(), Constructor.class, false);
Element<Annotation, Field> ef = getSingleton(env.classHasFieldAnnotatedWith(annotationName));
ta = ef.getAnnotation();
assertNotNull(ta);
assertEquals("field", getValue(ta));
- assertInstanceOf(ef.getAccessibleObject(), Field.class, false);
+ assertInstanceOf(ef.getAnnotatedElement(), Field.class, false);
Element<Annotation, Method> em = getSingleton(env.classHasMethodAnnotatedWith(annotationName));
ta = em.getAnnotation();
assertNotNull(ta);
assertEquals("method", getValue(ta));
- assertInstanceOf(em.getAccessibleObject(), Method.class, false);
+ assertInstanceOf(em.getAnnotatedElement(), Method.class, false);
- Set<Element<Annotation, AccessibleObject>> eps = env.classHasParameterAnnotatedWith(annotationName);
+ Set<Element<Annotation, AnnotatedElement>> eps = env.classHasParameterAnnotatedWith(annotationName);
assertNotNull(eps);
assertEquals(2, eps.size());
- for (Element<Annotation, AccessibleObject> ep : eps)
+ for (Element<Annotation, AnnotatedElement> ep : eps)
{
ta = ep.getAnnotation();
assertNotNull(ta);
Object value = getValue(ta);
- AccessibleObject ao = ep.getAccessibleObject();
+ AnnotatedElement ao = ep.getAnnotatedElement();
if ("cparameter".equals(value))
assertInstanceOf(ao, Constructor.class, false);
else if ("mparameter".equals(value))
Modified: projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationsTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationsTest.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-impl/src/tests/org/jboss/test/deployers/annotations/test/AnnotationsTest.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,7 +22,7 @@
package org.jboss.test.deployers.annotations.test;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
import java.util.Set;
import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
@@ -121,7 +121,7 @@
return env;
}
- protected <A extends Annotation, M extends AccessibleObject> Element<A,M> getSingleton(Set<Element<A,M>> elements)
+ protected <A extends Annotation, M extends AnnotatedElement> Element<A,M> getSingleton(Set<Element<A,M>> elements)
{
assertNotNull(elements);
assertEquals(1, elements.size());
Modified: projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/AnnotationEnvironment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/AnnotationEnvironment.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/AnnotationEnvironment.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,7 +22,7 @@
package org.jboss.deployers.spi.annotations;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -79,7 +79,7 @@
* @param annotation the annotation we're querying for
* @return set of matching classes
*/
- Set<Class<?>> classIsAnnotatedWith(Class<? extends Annotation> annotation);
+ <A extends Annotation> Set<Element<A, Class>> classIsAnnotatedWith(Class<A> annotation);
/**
* Get all classes annotated with annotation param.
@@ -87,7 +87,7 @@
* @param annotationName the annotation name we're querying for
* @return set of matching classes
*/
- Set<Class<?>> classIsAnnotatedWith(String annotationName);
+ Set<Element<Annotation, Class>> classIsAnnotatedWith(String annotationName);
/**
* Get all classes who have some constructor annotated with annotation param.
@@ -143,7 +143,7 @@
* @param annotation the annotation we're querying for
* @return set of matching classes
*/
- <A extends Annotation> Set<Element<A, AccessibleObject>> classHasParameterAnnotatedWith(Class<A> annotation);
+ <A extends Annotation> Set<Element<A, AnnotatedElement>> classHasParameterAnnotatedWith(Class<A> annotation);
/**
* Get all classes who have some method's/constructor's parameter annotated with annotation param.
@@ -151,5 +151,5 @@
* @param annotationName the annotation name we're querying for
* @return set of matching classes
*/
- Set<Element<Annotation, AccessibleObject>> classHasParameterAnnotatedWith(String annotationName);
+ Set<Element<Annotation, AnnotatedElement>> classHasParameterAnnotatedWith(String annotationName);
}
Modified: projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/Element.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/Element.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/annotations/Element.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -22,18 +22,27 @@
package org.jboss.deployers.spi.annotations;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
/**
* Annotation holder element.
*
* @param <A> exact annotation type
- * @param <M> exact accessible object type
+ * @param <M> exact annotated element type
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public interface Element<A extends Annotation, M extends AccessibleObject>
+public interface Element<A extends Annotation, M extends AnnotatedElement>
{
/**
+ * Get the owner class name.
+ *
+ * Until we hit getOwner method the class should not be loaded.
+ *
+ * @return the owner classname
+ */
+ String getOwnerClassName();
+
+ /**
* Get the annotation owner class.
*
* @return the annotation owner class
@@ -48,9 +57,9 @@
A getAnnotation();
/**
- * Get the accessible object that holds the annotation.
+ * Get the annotated element that holds the annotation.
*
- * @return the accessible objetc instance
+ * @return the annotated element instance
*/
- M getAccessibleObject();
+ M getAnnotatedElement();
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractAnnotationDeployer.java 2008-07-07 13:44:12 UTC (rev 75445)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractAnnotationDeployer.java 2008-07-07 15:00:51 UTC (rev 75446)
@@ -21,10 +21,12 @@
*/
package org.jboss.deployers.spi.deployer.helpers;
+import java.lang.annotation.Annotation;
import java.util.Set;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
+import org.jboss.deployers.spi.annotations.Element;
import org.jboss.deployers.structure.spi.DeploymentUnit;
/**
@@ -64,9 +66,10 @@
if (metadata != null)
unit.addAttachment(attachmentName, metadata);
- Set<Class<?>> classes = deployment.classIsAnnotatedWith(processor.getAnnotation());
- for (Class<?> clazz : classes)
+ Set<Element<Annotation, Class>> elements = deployment.classIsAnnotatedWith(processor.getAnnotation());
+ for (Element<Annotation, Class> elt : elements)
{
+ Class<?> clazz = elt.getOwner();
metadata = processor.createMetaDataFromClass(clazz);
if (metadata != null)
unit.addAttachment(attachmentName + "#" + clazz.getName(), metadata);
More information about the jboss-cvs-commits
mailing list