org.jboss.deployers.plugins.annotations
Class DefaultAnnotationEnvironment

java.lang.Object
  extended by org.jboss.util.JBossObject
      extended by org.jboss.deployers.plugins.annotations.DefaultAnnotationEnvironment
All Implemented Interfaces:
Serializable, Cloneable, AnnotationEnvironment, org.jboss.util.JBossInterface

public class DefaultAnnotationEnvironment
extends org.jboss.util.JBossObject
implements AnnotationEnvironment, Serializable

DefaultAnnotationEnvironment.

Author:
Ales Justin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.util.JBossObject
hashCode, toString
 
Constructor Summary
DefaultAnnotationEnvironment(ClassLoader classLoader)
           
 
Method Summary
<A extends Annotation>
Set<Element<A,Constructor<?>>>
classHasConstructorAnnotatedWith(Class<A> annotation)
          Get all classes who have some constructor annotated with annotation param.
 Set<Element<Annotation,Constructor<?>>> classHasConstructorAnnotatedWith(String annotationName)
          Get all classes who have some constructor annotated with annotation param.
<A extends Annotation>
Set<Element<A,Field>>
classHasFieldAnnotatedWith(Class<A> annotation)
          Get all classes who have some field annotated with annotation param.
 Set<Element<Annotation,Field>> classHasFieldAnnotatedWith(String annotationName)
          Get all classes who have some field annotated with annotation param.
<A extends Annotation>
Set<Element<A,Method>>
classHasMethodAnnotatedWith(Class<A> annotation)
          Get all classes who have some method annotated with annotation param.
 Set<Element<Annotation,Method>> classHasMethodAnnotatedWith(String annotationName)
          Get all classes who have some method annotated with annotation param.
<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.
 Set<Element<Annotation,AnnotatedElement>> classHasParameterAnnotatedWith(String annotationName)
          Get all classes who have some method's/constructor's parameter annotated with annotation param.
<A extends Annotation>
Set<Element<A,Class<?>>>
classIsAnnotatedWith(Class<A> annotation)
          Get all classes annotated with annotation param.
 Set<Element<Annotation,Class<?>>> classIsAnnotatedWith(String annotationName)
          Get all classes annotated with annotation param.
protected  Class<Annotation> getAnnotationClass(String annotationName)
          Load the annotation class.
protected  ClassLoader getClassLoader()
          Get the classloader from weak ref.
protected  Set<ClassSignaturePair> getCSPairs(Class<? extends Annotation> annClass, ElementType type)
          Get matching cs pairs.
protected  Map<Class<? extends Annotation>,Map<ElementType,Set<ClassSignaturePair>>> getEnv()
          Get env map.
 boolean hasClassAnnotatedWith(Class<? extends Annotation> annotation)
          Does this annotation environment contain a class which is annotated with annotation parameter.
 boolean hasClassAnnotatedWith(String annotationName)
          Does this annotation environment contain a class which is annotated with annotation parameter.
protected  Class<?> loadClass(String className)
          Load class from class name.
 void setKeepAnnotations(boolean keepAnnotations)
          Set the keep annotations flag.
protected
<A extends Annotation,M extends AnnotatedElement>
Set<Element<A,M>>
transformToElements(ElementType type, Class<A> annClass, Class<M> aoClass)
          Transform class names into classes.
 
Methods inherited from class org.jboss.util.JBossObject
cacheGetHashCode, cacheToString, clone, equals, flushJBossObjectCache, getClassShortName, getHashCode, hashCode, list, notEqual, toShortString, toShortString, toString, toString, toStringImplementation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultAnnotationEnvironment

public DefaultAnnotationEnvironment(ClassLoader classLoader)
Method Detail

setKeepAnnotations

public void setKeepAnnotations(boolean keepAnnotations)
Set the keep annotations flag.

Parameters:
keepAnnotations - the keep annotations flag

getEnv

protected Map<Class<? extends Annotation>,Map<ElementType,Set<ClassSignaturePair>>> getEnv()
Get env map.

Returns:
the env map

getCSPairs

protected Set<ClassSignaturePair> getCSPairs(Class<? extends Annotation> annClass,
                                             ElementType type)
Get matching cs pairs.

Parameters:
annClass - the annotation class
type - the annotation type
Returns:
class names

transformToElements

protected <A extends Annotation,M extends AnnotatedElement> Set<Element<A,M>> transformToElements(ElementType type,
                                                                                                  Class<A> annClass,
                                                                                                  Class<M> aoClass)
Transform class names into classes.

Type Parameters:
A - the annotation type
M - the annotated element type
Parameters:
type - the annotation type
annClass - the annotation class
aoClass - the ao class
Returns:
classes

hasClassAnnotatedWith

public boolean hasClassAnnotatedWith(Class<? extends Annotation> annotation)
Description copied from interface: AnnotationEnvironment
Does this annotation environment contain a class which is annotated with annotation parameter. This only applies to annotations for ElementType.TYPE level. This method should be used if we have no intention to do real lookup of annotated classes, but we're only interested in existance of the annotation. e.g. deployment unit contains @Stateful EJBs

Specified by:
hasClassAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotation - the annotation we're querying for
Returns:
true if there exists a class with annotation param
See Also:
AnnotationEnvironment.hasClassAnnotatedWith(Class annotation)

classIsAnnotatedWith

public <A extends Annotation> Set<Element<A,Class<?>>> classIsAnnotatedWith(Class<A> annotation)
Description copied from interface: AnnotationEnvironment
Get all classes annotated with annotation param.

Specified by:
classIsAnnotatedWith in interface AnnotationEnvironment
Type Parameters:
A - the annotation type
Parameters:
annotation - the annotation we're querying for
Returns:
set of matching classes

classHasConstructorAnnotatedWith

public <A extends Annotation> Set<Element<A,Constructor<?>>> classHasConstructorAnnotatedWith(Class<A> annotation)
Description copied from interface: AnnotationEnvironment
Get all classes who have some constructor annotated with annotation param.

Specified by:
classHasConstructorAnnotatedWith in interface AnnotationEnvironment
Type Parameters:
A - the annotation type
Parameters:
annotation - the annotation we're querying for
Returns:
set of matching classes

classHasFieldAnnotatedWith

public <A extends Annotation> Set<Element<A,Field>> classHasFieldAnnotatedWith(Class<A> annotation)
Description copied from interface: AnnotationEnvironment
Get all classes who have some field annotated with annotation param.

Specified by:
classHasFieldAnnotatedWith in interface AnnotationEnvironment
Type Parameters:
A - the annotation type
Parameters:
annotation - the annotation we're querying for
Returns:
set of matching classes

classHasMethodAnnotatedWith

public <A extends Annotation> Set<Element<A,Method>> classHasMethodAnnotatedWith(Class<A> annotation)
Description copied from interface: AnnotationEnvironment
Get all classes who have some method annotated with annotation param.

Specified by:
classHasMethodAnnotatedWith in interface AnnotationEnvironment
Type Parameters:
A - the annotation type
Parameters:
annotation - the annotation we're querying for
Returns:
set of matching classes

classHasParameterAnnotatedWith

public <A extends Annotation> Set<Element<A,AnnotatedElement>> classHasParameterAnnotatedWith(Class<A> annotation)
Description copied from interface: AnnotationEnvironment
Get all classes who have some method's/constructor's parameter annotated with annotation param.

Specified by:
classHasParameterAnnotatedWith in interface AnnotationEnvironment
Type Parameters:
A - the annotation type
Parameters:
annotation - the annotation we're querying for
Returns:
set of matching classes

getAnnotationClass

protected Class<Annotation> getAnnotationClass(String annotationName)
Load the annotation class.

Parameters:
annotationName - the annoation class name
Returns:
annotation class

hasClassAnnotatedWith

public boolean hasClassAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Does this annotation environment contain a class which is annotated with annotation parameter. This only applies to annotations for ElementType.TYPE level. This method should be used if we have no intention to do real lookup of annotated classes, but we're only interested in existance of the annotation. e.g. deployment unit contains @Stateful EJBs

Specified by:
hasClassAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
true if there exists a class with annotation param
See Also:
AnnotationEnvironment.hasClassAnnotatedWith(Class annotation)

classIsAnnotatedWith

public Set<Element<Annotation,Class<?>>> classIsAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Get all classes annotated with annotation param.

Specified by:
classIsAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
set of matching classes

classHasConstructorAnnotatedWith

public Set<Element<Annotation,Constructor<?>>> classHasConstructorAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Get all classes who have some constructor annotated with annotation param.

Specified by:
classHasConstructorAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
set of matching classes

classHasFieldAnnotatedWith

public Set<Element<Annotation,Field>> classHasFieldAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Get all classes who have some field annotated with annotation param.

Specified by:
classHasFieldAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
set of matching classes

classHasMethodAnnotatedWith

public Set<Element<Annotation,Method>> classHasMethodAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Get all classes who have some method annotated with annotation param.

Specified by:
classHasMethodAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
set of matching classes

classHasParameterAnnotatedWith

public Set<Element<Annotation,AnnotatedElement>> classHasParameterAnnotatedWith(String annotationName)
Description copied from interface: AnnotationEnvironment
Get all classes who have some method's/constructor's parameter annotated with annotation param.

Specified by:
classHasParameterAnnotatedWith in interface AnnotationEnvironment
Parameters:
annotationName - the annotation name we're querying for
Returns:
set of matching classes

getClassLoader

protected ClassLoader getClassLoader()
Get the classloader from weak ref.

Returns:
the classloader

loadClass

protected Class<?> loadClass(String className)
Load class from class name.

Parameters:
className - the class name
Returns:
loaded class


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.