[jboss-cvs] JBossAS SVN: r95227 - in projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins: annotations and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 20 19:48:26 EDT 2009
Author: alesj
Date: 2009-10-20 19:48:25 -0400 (Tue, 20 Oct 2009)
New Revision: 95227
Added:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/
Removed:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/AbstractElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassSignaturePair.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/CommitElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/EnvPutList.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationResourceVisitor.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ParametersElement.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ScopedGenericAnnotationDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java
Log:
2nd try at revert.
Copied: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations (from rev 95222, projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations)
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/AbstractElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/AbstractElement.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/AbstractElement.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,123 +0,0 @@
-/*
-* 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.
- *
- * @param <A> the annotation type
- * @param <M> the annotated element type
- * @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 A annotation;
-
- private SoftReference<Class<?>> classRef;
-
- public AbstractElement(ClassLoader classLoader, String className, Class<A> annClass, A annotation)
- {
- 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;
- this.annotation = annotation;
- }
-
- 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()
- {
- if (annotation == null)
- annotation = readAnnotation();
-
- return annotation;
- }
-
- /**
- * Read the annotation.
- *
- * @return the read annotation
- */
- protected A readAnnotation()
- {
- AnnotatedElement annotatedElement = getAnnotatedElement();
- return annotatedElement.getAnnotation(annClass);
- }
-
- public int getHashCode()
- {
- int hash = className.hashCode();
- hash += 7 * annClass.hashCode();
- if (annotation != null)
- hash += 11 * annotation.hashCode();
- return hash;
- }
-
- public boolean equals(Object obj)
- {
- if (obj == null || getClass().equals(obj.getClass()) == false)
- return false;
-
- AbstractElement<?, ?> ae = AbstractElement.class.cast(obj);
- if (className.equals(ae.className) == false)
- return false;
- if (annClass.equals(ae.annClass) == false)
- return false;
-
- // we don't check annotation
- // since I doubt classname + annClass + signature + aoClass is not enough
- // the only way this could happen is probably if class was diff version - diff annotation values
-
- return true;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassElement.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassElement.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,47 +0,0 @@
-/*
-* 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.
- *
- * @param <A> the annotation type
- * @param <M> the annotated element type
- * @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, A annotation)
- {
- super(classLoader, className, annClass, annotation);
- }
-
- @SuppressWarnings("unchecked")
- public M getAnnotatedElement()
- {
- AnnotatedElement em = getOwner();
- return (M)em;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassSignaturePair.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassSignaturePair.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ClassSignaturePair.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,108 +0,0 @@
-/*
-* 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 org.jboss.metadata.spi.signature.Signature;
-import org.jboss.util.JBossObject;
-
-/**
- * Class name and signature pair.
- * With those two we can re-create annotation value.
- *
- * If the keepAnnotations flag is on in DefaultAnnotationEnvironment
- * we cache the annotation value from GenericAnnotationResourceVisitor.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class ClassSignaturePair extends JBossObject
-{
- private String className;
- private Signature signature;
- private Annotation annotation;
-
- public ClassSignaturePair(String className, Signature signature)
- {
- this(className, signature, null);
- }
-
- public ClassSignaturePair(String className, Signature signature, Annotation annotation)
- {
- if (className == null)
- throw new IllegalArgumentException("Null class name");
-
- this.className = className;
- this.signature = signature;
- this.annotation = annotation;
- }
-
- /**
- * Get the classname.
- *
- * @return the classname
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Get the signature.
- *
- * @return the signature
- */
- public Signature getSignature()
- {
- return signature;
- }
-
- /**
- * Get the annotation.
- *
- * @return the annotation
- */
- public Annotation getAnnotation()
- {
- return annotation;
- }
-
- protected int getHashCode()
- {
- int hash = className.hashCode();
- if (signature != null)
- hash += 7 * signature.hashCode();
- return hash;
- }
-
- public boolean equals(Object obj)
- {
- if (obj instanceof ClassSignaturePair == false)
- return false;
-
- ClassSignaturePair csPair = (ClassSignaturePair)obj;
- if (className.equals(csPair.getClassName()))
- return equals(signature, csPair.getSignature());
- else
- return false;
- }
-}
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/CommitElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/CommitElement.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/CommitElement.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,91 +0,0 @@
-/*
-* 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.annotation.ElementType;
-
-import org.jboss.metadata.spi.signature.Signature;
-
-/**
- * Gathering annotation information.
- *
- * Only push all this info into AnnotationEnvironment if
- * complete lookup was successful.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-class CommitElement
-{
- private Annotation annotation;
- private ElementType type;
- private String className;
- private Signature signature;
-
- CommitElement(Annotation annotation, ElementType type, String className, Signature signature)
- {
- this.annotation = annotation;
- this.type = type;
- this.className = className;
- this.signature = signature;
- }
-
- /**
- * Get the annotation.
- *
- * @return the annotation
- */
- public Annotation getAnnotation()
- {
- return annotation;
- }
-
- /**
- * Get element type.
- *
- * @return the element type
- */
- public ElementType getType()
- {
- return type;
- }
-
- /**
- * Get class name.
- *
- * @return the class name
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Get signature.
- *
- * @return the signature
- */
- public Signature getSignature()
- {
- return signature;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,277 +0,0 @@
-/*
-* 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.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
-import org.jboss.deployers.spi.annotations.Element;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.util.collection.CollectionsFactory;
-
-/**
- * DefaultAnnotationEnvironment.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class DefaultAnnotationEnvironment extends WeakClassLoaderHolder implements AnnotationEnvironment, Serializable
-{
- /** The serial version UID */
- private static final long serialVersionUID = 1L;
- /** The log */
- private static final Logger log = Logger.getLogger(DefaultAnnotationEnvironment.class);
- /** The info map */
- private transient Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> env;
- /** The checked class names */
- private transient Set<String> checkedClassNames;
- /** Should we keep the annotation */
- private boolean keepAnnotations;
-
- public DefaultAnnotationEnvironment(ClassLoader classLoader)
- {
- super(classLoader);
- env = new HashMap<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>>();
- checkedClassNames = new HashSet<String>();
- }
-
- /**
- * Set the keep annotations flag.
- *
- * @param keepAnnotations the keep annotations flag
- */
- public void setKeepAnnotations(boolean keepAnnotations)
- {
- this.keepAnnotations = keepAnnotations;
- }
-
- /**
- * Get env map.
- *
- * @return the env map
- */
- protected Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> getEnv()
- {
- if (env == null)
- throw new IllegalArgumentException("Null env, previously serialized?");
-
- return env;
- }
-
- /**
- * Was class name already checked.
- *
- * @param className the class name
- * @return true if already checked, false otherwise
- */
- boolean isAlreadyChecked(String className)
- {
- return checkedClassNames.contains(className);
- }
-
- /**
- * Put the annotation info.
- *
- * @param annotation the annotation
- * @param type the annotation type
- * @param className the class name
- * @param signature the signature
- */
- void putAnnotation(Annotation annotation, ElementType type, String className, Signature signature)
- {
- Class<? extends Annotation> annClass = annotation.annotationType();
-
- if (log.isTraceEnabled())
- log.trace("Adding annotation @" + annClass.getSimpleName() + " for " + className + " at type " + type + ", signature: " + signature);
-
- // add to checked
- checkedClassNames.add(className);
-
- Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> env = getEnv();
-
- Map<ElementType, Set<ClassSignaturePair>> elements = env.get(annClass);
- if (elements == null)
- {
- elements = new HashMap<ElementType, Set<ClassSignaturePair>>();
- env.put(annClass, elements);
- }
-
- Set<ClassSignaturePair> classes = elements.get(type);
- if (classes == null)
- {
- classes = CollectionsFactory.createLazySet();
- elements.put(type, classes);
- }
-
- ClassSignaturePair pair;
- if (keepAnnotations)
- pair = new ClassSignaturePair(className, signature, annotation);
- else
- pair = new ClassSignaturePair(className, signature);
- classes.add(pair);
- }
-
- /**
- * Get matching cs pairs.
- *
- * @param annClass the annotation class
- * @param type the annotation type
- * @return class names
- */
- protected Set<ClassSignaturePair> getCSPairs(Class<? extends Annotation> annClass, ElementType type)
- {
- Set<ClassSignaturePair> pairs = null;
-
- Map<ElementType, Set<ClassSignaturePair>> elements = getEnv().get(annClass);
- if (elements != null)
- pairs = elements.get(type);
-
- return (pairs != null) ? pairs : Collections.<ClassSignaturePair>emptySet();
- }
-
- /**
- * Transform class names into classes.
- *
- * @param <A> the annotation type
- * @param <M> the annotated element type
- * @param type the annotation type
- * @param annClass the annotation class
- * @param aoClass the ao class
- * @return classes
- */
- protected <A extends Annotation, M extends AnnotatedElement> Set<Element<A, M>> transformToElements(
- ElementType type,
- Class<A> annClass,
- Class<M> aoClass
- )
- {
- Set<ClassSignaturePair> pairs = getCSPairs(annClass, type);
- if (pairs.isEmpty())
- return Collections.emptySet();
-
- ClassLoader classLoader = getClassLoader();
- Set<Element<A, M>> elements = new HashSet<Element<A, M>>();
- for (ClassSignaturePair pair : pairs)
- {
- String className = pair.getClassName();
- A annotation = annClass.cast(pair.getAnnotation());
-
- Element<A, M> element;
- if (type == ElementType.TYPE)
- element = new ClassElement<A, M>(classLoader, className, annClass, annotation);
- else if (type == ElementType.PARAMETER)
- element = new ParametersElement<A,M>(classLoader, className, pair.getSignature(), annClass, annotation, aoClass);
- else
- element = new DefaultElement<A,M>(classLoader, className, pair.getSignature(), annClass, annotation, aoClass);
- elements.add(element);
- }
- return elements;
- }
-
- public boolean hasClassAnnotatedWith(Class<? extends Annotation> annotation)
- {
- return getCSPairs(annotation, ElementType.TYPE).isEmpty() == false;
- }
-
- @SuppressWarnings("unchecked")
- public <A extends Annotation> Set<Element<A, Class<?>>> classIsAnnotatedWith(Class<A> annotation)
- {
- return (Set) transformToElements(ElementType.TYPE, annotation, Class.class);
- }
-
- @SuppressWarnings("unchecked")
- public <A extends Annotation> Set<Element<A, Constructor<?>>> classHasConstructorAnnotatedWith(Class<A> annotation)
- {
- return (Set) transformToElements(ElementType.CONSTRUCTOR, annotation, Constructor.class);
- }
-
- public <A extends Annotation> Set<Element<A, Field>> classHasFieldAnnotatedWith(Class<A> annotation)
- {
- return transformToElements(ElementType.FIELD, annotation, Field.class);
- }
-
- public <A extends Annotation> Set<Element<A, Method>> classHasMethodAnnotatedWith(Class<A> annotation)
- {
- return transformToElements(ElementType.METHOD, annotation, Method.class);
- }
-
- public <A extends Annotation> Set<Element<A, AnnotatedElement>> classHasParameterAnnotatedWith(Class<A> annotation)
- {
- return transformToElements(ElementType.PARAMETER, annotation, AnnotatedElement.class);
- }
-
- /**
- * Load the annotation class.
- *
- * @param annotationName the annoation class name
- * @return annotation class
- */
- @SuppressWarnings("unchecked")
- protected Class<Annotation> getAnnotationClass(String annotationName)
- {
- Class<?> clazz = loadClass(annotationName);
- if (Annotation.class.isAssignableFrom(clazz) == false)
- throw new IllegalArgumentException("Annotation name " + annotationName + " doesn't extend Annotation class.");
- return (Class<Annotation>)clazz;
- }
-
- public boolean hasClassAnnotatedWith(String annotationName)
- {
- return hasClassAnnotatedWith(getAnnotationClass(annotationName));
- }
-
- public Set<Element<Annotation, Class<?>>> classIsAnnotatedWith(String annotationName)
- {
- return classIsAnnotatedWith(getAnnotationClass(annotationName));
- }
-
- public Set<Element<Annotation, Constructor<?>>> classHasConstructorAnnotatedWith(String annotationName)
- {
- return classHasConstructorAnnotatedWith(getAnnotationClass(annotationName));
- }
-
- public Set<Element<Annotation, Field>> classHasFieldAnnotatedWith(String annotationName)
- {
- return classHasFieldAnnotatedWith(getAnnotationClass(annotationName));
- }
-
- public Set<Element<Annotation, Method>> classHasMethodAnnotatedWith(String annotationName)
- {
- return classHasMethodAnnotatedWith(getAnnotationClass(annotationName));
- }
-
- public Set<Element<Annotation, AnnotatedElement>> classHasParameterAnnotatedWith(String annotationName)
- {
- return classHasParameterAnnotatedWith(getAnnotationClass(annotationName));
- }
-}
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultElement.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/DefaultElement.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,120 +0,0 @@
-/*
-* 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;
-
-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.reflect.plugins.introspection.ReflectionUtils;
-
-/**
- * Default annotations element.
- *
- * @param <A> the annotation type
- * @param <M> the annotated element type
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class DefaultElement<A extends Annotation, M extends AnnotatedElement> extends AbstractElement<A, M>
-{
- protected Signature signature;
- protected Class<M> aoClass;
-
- public DefaultElement(ClassLoader classLoader, String className, Signature signature, Class<A> annClass, A annotation, Class<M> aoClass)
- {
- super(classLoader, className, annClass, annotation);
-
- if (signature == null)
- throw new IllegalArgumentException("Null signature");
- if (aoClass == null)
- throw new IllegalArgumentException("Null ao class");
-
- this.signature = signature;
- this.aoClass = aoClass;
- }
-
- public M getAnnotatedElement()
- {
- AnnotatedElement result = null;
-
- Class<?> clazz = getOwner();
- if (signature instanceof ConstructorSignature || signature instanceof ConstructorParametersSignature)
- {
- try
- {
- result = clazz.getConstructor(signature.getParametersTypes(clazz));
- }
- catch (NoSuchMethodException ignored)
- {
- }
- }
- else if (signature instanceof MethodSignature || signature instanceof MethodParametersSignature)
- {
- try
- {
- result = clazz.getMethod(signature.getName(), signature.getParametersTypes(clazz));
- }
- catch (NoSuchMethodException ignored)
- {
- }
- }
- else if (signature instanceof FieldSignature)
- {
- result = ReflectionUtils.findField(clazz, signature.getName());
- }
-
- if (result == null)
- throw new IllegalArgumentException("Expected accessible object " + className + "." + signature);
- if (aoClass.isInstance(result) == false)
- throw new IllegalArgumentException("Expected accessible object " + className + "." + signature + " of type " + aoClass);
-
- return aoClass.cast(result);
- }
-
- public int getHashCode()
- {
- int hash = super.getHashCode();
- hash += 19 * signature.hashCode();
- hash += 37 * aoClass.hashCode();
- return hash;
- }
-
- @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
- public boolean equals(Object obj)
- {
- if (super.equals(obj) == false)
- return false;
-
- DefaultElement<?, ?> de = DefaultElement.class.cast(obj);
- if (aoClass.equals(de.aoClass) == false)
- return false;
- if (signature.equals(de.signature) == false)
- return false;
-
- return true;
- }
-}
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/EnvPutList.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/EnvPutList.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/EnvPutList.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,57 +0,0 @@
-/*
-* 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.util.AbstractList;
-
-/**
- * Put elements directly into env
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-class EnvPutList extends AbstractList<CommitElement>
-{
- private DefaultAnnotationEnvironment env;
-
- EnvPutList(DefaultAnnotationEnvironment env)
- {
- if (env == null)
- throw new IllegalArgumentException("Null env.");
- this.env = env;
- }
-
- public boolean add(CommitElement ce)
- {
- env.putAnnotation(ce.getAnnotation(), ce.getType(), ce.getClassName(), ce.getSignature());
- return true;
- }
-
- public CommitElement get(int index)
- {
- throw new UnsupportedOperationException("Should not be invoked.");
- }
-
- public int size()
- {
- return 0;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/FilteredGenericAnnotationDeployer.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,99 +0,0 @@
-/*
-* 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 org.jboss.classloading.spi.visitor.ResourceFilter;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * Filtered generic annotation scanner deployer.
- *
- * It first checks if there are some filters present
- * in deployment unit as attachment,
- * else falls back to deployers filters.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class FilteredGenericAnnotationDeployer extends ScopedGenericAnnotationDeployer
-{
- private ResourceFilter resourceFilter;
- private ResourceFilter recurseFilter;
-
- /**
- * Get filter.
- * Try attachment first, then deployer's filter.
- *
- * @param <T> the expected class type
- * @param unit the deployment unit
- * @param expectedClass the expected class
- * @param suffix the suffix
- * @param defaultValue the default value
- * @return found filter or null
- */
- protected <T> T getFilter(DeploymentUnit unit, Class<T> expectedClass, String suffix, T defaultValue)
- {
- String name = expectedClass.getName() + "." + (suffix != null ? suffix : "");
- T result = unit.getAttachment(name, expectedClass);
- if (result == null)
- result = defaultValue;
- return result;
- }
-
- /**
- * We look for filter attachments:
- * * org.jboss.classloading.spi.visitor.ResourceFilter.resource - plain resource filter
- * * org.jboss.classloading.spi.visitor.ResourceFilter.recurse - recurse resource filter
- *
- * @param unit the deployment unit
- * @param module the underlying module
- * @param visitor the current generic annotation resource visitor
- */
- protected void visitModule(DeploymentUnit unit, Module module, GenericAnnotationResourceVisitor visitor)
- {
- ResourceFilter filter = getFilter(unit, ResourceFilter.class, "resource", resourceFilter);
- if (filter == null)
- filter = visitor.getFilter();
- ResourceFilter recurse = getFilter(unit, ResourceFilter.class, "recurse", recurseFilter);
- module.visit(visitor, filter, recurse, getUrls(unit));
- }
-
- /**
- * Set resource filter.
- *
- * @param resourceFilter the resource filter
- */
- public void setResourceFilter(ResourceFilter resourceFilter)
- {
- this.resourceFilter = resourceFilter;
- }
-
- /**
- * Set recurse filter.
- *
- * @param recurseFilter the recurse filter
- */
- public void setRecurseFilter(ResourceFilter recurseFilter)
- {
- this.recurseFilter = recurseFilter;
- }
-}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationDeployer.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -21,17 +21,14 @@
*/
package org.jboss.deployers.plugins.annotations;
-import java.net.URL;
-
-import javassist.ClassPath;
-import javassist.ClassPool;
-import javassist.LoaderClassPath;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.mcann.AnnotationRepository;
+import org.jboss.mcann.scanner.DefaultAnnotationScanner;
+import org.jboss.mcann.scanner.ModuleAnnotationScanner;
/**
* Generic annotation scanner deployer.
@@ -48,7 +45,7 @@
{
super(Module.class);
setStage(DeploymentStages.POST_CLASSLOADER);
- setOutput(AnnotationEnvironment.class);
+ setOutput(AnnotationRepository.class);
checkInterfaces = true;
}
@@ -82,87 +79,20 @@
this.checkInterfaces = checkInterfaces;
}
- /**
- * Create GenericAnnotationResourceVisitor.
- *
- * Can be used change existing GARV's filter.
- * Or determin if we need to force/keep annotations.
- *
- * @param unit the deployment unit
- * @param pool the class pool
- * @param classLoader the classloader
- * @return new generic annotation visitor
- */
- protected GenericAnnotationResourceVisitor createGenericAnnotationResourceVisitor(DeploymentUnit unit, ClassPool pool, ClassLoader classLoader)
+ public void deploy(DeploymentUnit unit, Module deployment) throws DeploymentException
{
- GenericAnnotationResourceVisitor visitor = new GenericAnnotationResourceVisitor(pool, classLoader);
- visitor.setForceAnnotations(forceAnnotations);
- visitor.setKeepAnnotations(keepAnnotations);
- visitor.setCheckInterfaces(checkInterfaces);
- return visitor;
- }
-
- /**
- * Create class pool.
- *
- * @param classLoader the class loader
- * @return javassist class pool
- */
- protected ClassPool createClassPool(ClassLoader classLoader)
- {
- ClassPool pool = new ClassPool();
- ClassPath classPath = new LoaderClassPath(classLoader);
- pool.insertClassPath(classPath);
- return pool;
- }
-
- /**
- * Visit module.
- *
- * Util method to add some behavior to Module
- * before we visit it.
- *
- * @param unit the deployment unit
- * @param module the module
- * @param visitor the resource visitor
- */
- protected void visitModule(DeploymentUnit unit, Module module, GenericAnnotationResourceVisitor visitor)
- {
- module.visit(visitor, null, null, getUrls(unit));
- }
-
- /**
- * Get the new root urls.
- *
- * @param unit the deployment unit
- * @return the new root urls
- */
- protected URL[] getUrls(DeploymentUnit unit)
- {
- return null;
- }
-
- public void deploy(DeploymentUnit unit, Module module) throws DeploymentException
- {
- if (log.isTraceEnabled())
- log.trace("Creating AnnotationEnvironment for " + unit.getName() + ", module: " + module + ", force annotations: " + forceAnnotations);
-
- ClassLoader classLoader = unit.getClassLoader();
- ClassPool pool = createClassPool(classLoader);
- GenericAnnotationResourceVisitor visitor = createGenericAnnotationResourceVisitor(unit, pool, classLoader);
-
- // something in javassist uses TCL
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
try
{
- visitModule(unit, module, visitor);
+ DefaultAnnotationScanner scanner = new ModuleAnnotationScanner(deployment);
+ scanner.setForceAnnotations(forceAnnotations);
+ scanner.setKeepAnnotations(keepAnnotations);
+ scanner.setCheckInterfaces(checkInterfaces);
+ AnnotationRepository repository = scanner.scan(unit.getClassLoader());
+ unit.addAttachment(AnnotationRepository.class, repository);
}
- finally
+ catch (Exception e)
{
- Thread.currentThread().setContextClassLoader(tcl);
+ throw DeploymentException.rethrowAsDeploymentException("Cannot create AR", e);
}
-
- unit.addAttachment(AnnotationEnvironment.class, visitor.getEnv());
}
}
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationResourceVisitor.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationResourceVisitor.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/GenericAnnotationResourceVisitor.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,369 +0,0 @@
-/*
-* 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.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.util.List;
-import java.util.ArrayList;
-
-import javassist.ClassPool;
-import javassist.CtBehavior;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtMember;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-import org.jboss.classloading.spi.visitor.ClassFilter;
-import org.jboss.classloading.spi.visitor.ResourceContext;
-import org.jboss.classloading.spi.visitor.ResourceFilter;
-import org.jboss.classloading.spi.visitor.ResourceVisitor;
-import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.metadata.spi.signature.javassist.JavassistConstructorParametersSignature;
-import org.jboss.metadata.spi.signature.javassist.JavassistMethodParametersSignature;
-import org.jboss.metadata.spi.signature.javassist.JavassistSignatureFactory;
-
-/**
- * Generic annotation scanner deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class GenericAnnotationResourceVisitor implements ResourceVisitor
-{
- private static final Logger log = Logger.getLogger(GenericAnnotationResourceVisitor.class);
-
- private ResourceFilter resourceFilter = ClassFilter.INSTANCE;
- private ClassPool pool;
- private boolean forceAnnotations;
- private boolean checkSuper;
- private boolean checkInterfaces = true;
- private DefaultAnnotationEnvironment env;
- private CtClass objectCtClass;
-
- public GenericAnnotationResourceVisitor(ClassLoader classLoader)
- {
- this(ClassPool.getDefault(), classLoader);
- }
-
- public GenericAnnotationResourceVisitor(ClassPool pool, ClassLoader classLoader)
- {
- if (pool == null)
- throw new IllegalArgumentException("Null pool");
- if (classLoader == null)
- throw new IllegalArgumentException("Null classloader");
-
- this.pool = pool;
- this.env = new DefaultAnnotationEnvironment(classLoader);
- this.objectCtClass = pool.makeClass(Object.class.getName());
- }
-
- public ResourceFilter getFilter()
- {
- return resourceFilter;
- }
-
- public void visit(ResourceContext resource)
- {
- try
- {
- InputStream stream = resource.getInputStream();
- if (stream == null)
- throw new IllegalArgumentException("Null resource input stream: " + resource);
-
- try
- {
- CtClass ctClass = pool.makeClass(stream);
- try
- {
- List<CommitElement> commit = createCommitList();
- handleCtClass(ctClass, commit);
- if (commit.isEmpty() == false)
- {
- for (CommitElement ce : commit)
- {
- env.putAnnotation(ce.getAnnotation(), ce.getType(), ce.getClassName(), ce.getSignature());
- }
- }
- }
- finally
- {
- ctClass.detach();
- }
- }
- finally
- {
- try
- {
- stream.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- if (forceAnnotations)
- throw new RuntimeException(e);
-
- logThrowable(resource, e);
- }
- catch (Throwable t)
- {
- logThrowable(resource, t);
- }
- }
-
- /**
- * Create commit list.
- *
- * @return the commit list
- */
- protected List<CommitElement> createCommitList()
- {
- return forceAnnotations ? new EnvPutList(env) : new ArrayList<CommitElement>();
- }
-
- /**
- * Log throwable.
- *
- * @param resource the resource we're visiting
- * @param t the throwable
- */
- protected void logThrowable(ResourceContext resource, Throwable t)
- {
- if (log.isTraceEnabled())
- log.trace("Exception reading resource: " + resource.getResourceName(), t);
- }
-
- /**
- * Handle CtClass for annotations.
- *
- * @param ctClass the ct class instance
- * @param commit the commit list
- * @throws ClassNotFoundException for any annotations lookup problems
- * @throws NotFoundException for any annotations lookup problems
- */
- protected void handleCtClass(CtClass ctClass, List<CommitElement> commit) throws ClassNotFoundException, NotFoundException
- {
- if (ctClass == null || objectCtClass.equals(ctClass))
- return;
-
- String className = ctClass.getName();
- if (env.isAlreadyChecked(className))
- {
- if (log.isTraceEnabled())
- log.trace("Skipping already checked class name: " + className);
- return;
- }
-
- if (checkInterfaces == false && ctClass.isInterface())
- {
- if (log.isTraceEnabled())
- log.trace("Skipping interface: " + className);
- return;
- }
-
- if (log.isTraceEnabled())
- log.trace("Scanning class " + className + " for annotations");
-
- Object[] annotations = forceAnnotations ? ctClass.getAnnotations() : ctClass.getAvailableAnnotations();
- handleAnnotations(ElementType.TYPE, (Signature)null, annotations, className, commit);
-
- handleCtMembers(ElementType.CONSTRUCTOR, ctClass.getDeclaredConstructors(), className, commit);
- handleCtMembers(ElementType.METHOD, ctClass.getDeclaredMethods(), className, commit);
- handleCtMembers(ElementType.FIELD, ctClass.getDeclaredFields(), className, commit);
-
- if (checkSuper)
- {
- if (checkInterfaces)
- {
- // interfaces
- CtClass[] interfaces = ctClass.getInterfaces();
- if (interfaces != null && interfaces.length > 0)
- {
- for (CtClass intf : interfaces)
- handleCtClass(intf, commit);
- }
- }
- // super class
- handleCtClass(ctClass.getSuperclass(), commit);
- }
- }
-
- /**
- * Handle CtMembers for annotations.
- *
- * @param type where we found the annotations
- * @param members the ct member instances
- * @param className the className
- * @param commit the commit list
- * @throws ClassNotFoundException for any annotations lookup problems
- */
- protected void handleCtMembers(ElementType type, CtMember[] members, String className, List<CommitElement> commit) throws ClassNotFoundException
- {
- if (members != null && members.length > 0)
- {
- for (CtMember member : members)
- {
- Object[] annotations = forceAnnotations ? member.getAnnotations() : member.getAvailableAnnotations();
- handleAnnotations(type, member, annotations, className, commit);
- if (member instanceof CtBehavior)
- {
- CtBehavior behavior = (CtBehavior)member;
- Object[][] paramAnnotations = forceAnnotations ? behavior.getParameterAnnotations() : behavior.getAvailableParameterAnnotations();
- for (int index = 0; index < paramAnnotations.length; index++)
- {
- handleAnnotations(ElementType.PARAMETER, getBehaviorSignature(behavior, index), paramAnnotations[index], className, commit);
- }
- }
- }
- }
- }
-
- /**
- * Get parameters signature.
- *
- * @param behavior the ct behavior
- * @param index the index
- * @return parameters signature
- * @throws ClassNotFoundException for any error
- */
- protected static Signature getBehaviorSignature(CtBehavior behavior, int index) throws ClassNotFoundException
- {
- try
- {
- if (behavior instanceof CtConstructor)
- return new JavassistConstructorParametersSignature((CtConstructor)behavior, index);
- else if (behavior instanceof CtMethod)
- return new JavassistMethodParametersSignature((CtMethod)behavior, index);
- else
- throw new IllegalArgumentException("Unknown ct behavior: " + behavior);
- }
- catch (NotFoundException e)
- {
- throw new ClassNotFoundException("Exception creating signature: " + behavior, e);
- }
- }
-
- /**
- * Handle annotations.
- *
- * @param type where we found the annotations
- * @param member the ct member
- * @param annotations the actual annotations
- * @param className the className
- * @param commit the commit list
- */
- protected static void handleAnnotations(ElementType type, CtMember member, Object[] annotations, String className, List<CommitElement> commit)
- {
- Signature signature = null;
- if (member != null)
- signature = JavassistSignatureFactory.getSignature(member);
- handleAnnotations(type, signature, annotations, className, commit);
- }
-
- /**
- * Handle annotations.
- *
- * @param type where we found the annotations
- * @param signature the signature
- * @param annotations the actual annotations
- * @param className the className
- * @param commit the commit list
- */
- protected static void handleAnnotations(ElementType type, Signature signature, Object[] annotations, String className, List<CommitElement> commit)
- {
- if (annotations != null && annotations.length > 0)
- {
- for (Object annObject : annotations)
- {
- Annotation annotation = Annotation.class.cast(annObject);
- commit.add(new CommitElement(annotation, type, className, signature));
- }
- }
- }
-
- /**
- * Set the resource filter.
- *
- * @param resourceFilter the resource filter
- */
- public void setResourceFilter(ResourceFilter resourceFilter)
- {
- this.resourceFilter = resourceFilter;
- }
-
- /**
- * Should we force all annotations to be available.
- *
- * @param forceAnnotations the force annotations flag
- */
- public void setForceAnnotations(boolean forceAnnotations)
- {
- this.forceAnnotations = forceAnnotations;
- }
-
- /**
- * Set the keep annotations flag.
- *
- * @param keepAnnotations the keep annotations flag
- */
- public void setKeepAnnotations(boolean keepAnnotations)
- {
- env.setKeepAnnotations(keepAnnotations);
- }
-
- /**
- * Should we check super class for annotations as well.
- *
- * @param checkSuper the check super flag
- */
- public void setCheckSuper(boolean checkSuper)
- {
- this.checkSuper = checkSuper;
- }
-
- /**
- * Should we check interfaces for annotations as well.
- *
- * @param checkInterfaces the check interfaces flag
- */
- public void setCheckInterfaces(boolean checkInterfaces)
- {
- this.checkInterfaces = checkInterfaces;
- }
-
- /**
- * Get the built environment.
- *
- * @return the annoattion environment
- */
- public AnnotationEnvironment getEnv()
- {
- return env;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ParametersElement.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ParametersElement.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ParametersElement.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,88 +0,0 @@
-/*
-* 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;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.jboss.metadata.spi.signature.ConstructorParametersSignature;
-import org.jboss.metadata.spi.signature.MethodParametersSignature;
-import org.jboss.metadata.spi.signature.Signature;
-
-/**
- * Parameters annotations element.
- *
- * @param <A> the annotation type
- * @param <M> the annotated element type
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class ParametersElement<A extends Annotation, M extends AnnotatedElement> extends DefaultElement<A, M>
-{
- public ParametersElement(ClassLoader classLoader, String className, Signature signature, Class<A> annClass, A annotation, Class<M> aoClass)
- {
- super(classLoader, className, signature, annClass, annotation, aoClass);
- }
-
- protected A readAnnotation()
- {
- Annotation[] annotations = null;
- Class<?> clazz = getOwner();
- if (signature instanceof ConstructorParametersSignature)
- {
- ConstructorParametersSignature cps = (ConstructorParametersSignature)signature;
- try
- {
- Constructor<?> constructor = clazz.getConstructor(signature.getParametersTypes(clazz));
- annotations = constructor.getParameterAnnotations()[cps.getParam()];
- }
- catch (NoSuchMethodException ignored)
- {
- }
- }
- else if (signature instanceof MethodParametersSignature)
- {
- MethodParametersSignature mps = (MethodParametersSignature)signature;
- try
- {
- Method method = clazz.getMethod(signature.getName(), signature.getParametersTypes(clazz));
- annotations = method.getParameterAnnotations()[mps.getParam()];
- }
- catch (NoSuchMethodException ignored)
- {
- }
- }
-
- if (annotations == null || annotations.length == 0)
- throw new IllegalArgumentException("Expected annotations " + className + "." + signature);
-
- for(Annotation annotation : annotations)
- {
- if (annClass.equals(annotation.annotationType()))
- return annClass.cast(annotation);
- }
-
- throw new IllegalArgumentException("No matching annotation: " + Arrays.asList(annotations));
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ScopedGenericAnnotationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ScopedGenericAnnotationDeployer.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/ScopedGenericAnnotationDeployer.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,62 +0,0 @@
-/*
-* 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 javassist.scopedpool.ScopedClassPoolRepository;
-import javassist.ClassPool;
-
-/**
- * Scoped generic annotation deployer.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class ScopedGenericAnnotationDeployer extends GenericAnnotationDeployer
-{
- private ScopedClassPoolRepository repository;
-
- public ScopedGenericAnnotationDeployer()
- {
- }
-
- public ScopedGenericAnnotationDeployer(ScopedClassPoolRepository repository)
- {
- this.repository = repository;
- }
-
- /**
- * Set scoped class pool repository.
- *
- * @param repository the scoped class pool repository
- */
- public void setRepository(ScopedClassPoolRepository repository)
- {
- this.repository = repository;
- }
-
- protected ClassPool createClassPool(ClassLoader classLoader)
- {
- if (repository != null)
- return repository.findClassPool(classLoader);
-
- return super.createClassPool(classLoader);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2009-10-20 23:19:47 UTC (rev 95222)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2009-10-20 23:48:25 UTC (rev 95227)
@@ -1,79 +0,0 @@
-/*
-* 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.ref.WeakReference;
-
-import org.jboss.util.JBossObject;
-
-/**
- * ClassLoader holder helper.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-abstract class WeakClassLoaderHolder extends JBossObject
-{
- private transient WeakReference<ClassLoader> clRef;
-
- public WeakClassLoaderHolder(ClassLoader classLoader)
- {
- if (classLoader == null)
- throw new IllegalArgumentException("Null classloader");
-
- clRef = new WeakReference<ClassLoader>(classLoader);
- }
-
- /**
- * Get the classloader from weak ref.
- *
- * @return the classloader
- */
- protected ClassLoader getClassLoader()
- {
- if (clRef == null)
- throw new IllegalArgumentException("Null classloader ref, previously serialized?");
-
- ClassLoader classLoader = clRef.get();
- if (classLoader == null)
- throw new IllegalArgumentException("ClassLoader was already garbage collected.");
-
- return classLoader;
- }
-
- /**
- * Load class from class name.
- *
- * @param className the class name
- * @return loaded class
- */
- protected Class<?> loadClass(String className)
- {
- try
- {
- return Class.forName(className, false, getClassLoader());
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list