org.springframework.jee
Class JeeAnnotationUtils

java.lang.Object
  extended by org.springframework.jee.JeeAnnotationUtils

public abstract class JeeAnnotationUtils
extends java.lang.Object

Utility class used for finding annotation using the inheritance rules from jsr250.

Author:
Costin Leau

Field Summary
static java.lang.Class[] AROUND_INVOKE_METHOD_PARAM
           
 
Constructor Summary
JeeAnnotationUtils()
           
 
Method Summary
static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation> A)
          Find all the methods on the given class and superclasses that have the given annotation.
static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation> A, java.lang.Class... argTypes)
          Find all the methods on the given class and superclasses that have the given annotation and the given signature (jsr250 is not applied).
static java.lang.reflect.Method findAroundInvokeMethod(java.lang.Class clazz)
          Find the EJB3 around invoke method
static
<A extends java.lang.annotation.Annotation>
A
findFieldAnnotation(java.lang.Class<A> annotationClass, java.lang.Class targetClass, java.lang.String fieldName, java.lang.Class fieldType)
          Returns the annotation for the given field (specified by name and type) using the inheritance mechanism defined in JSR 250.
static java.lang.reflect.Method findFirstAnnotatedMethod(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation> A, java.lang.Class... argTypes)
          Find all methods with the given annotation and argument types on the given class and all its superclasses.
static
<A extends java.lang.annotation.Annotation>
A
findInheritedMemberAnnotation(java.lang.Class<A> annotationClass, java.lang.Class enclosingClass, java.lang.reflect.AccessibleObject member)
          Apply the jsr250 annotation algorithm to retrieve the annotation value for the given member.
static
<A extends java.lang.annotation.Annotation>
A
findMethodAnnotation(java.lang.Class<A> annotationClass, java.lang.Class targetClass, java.lang.String methodName)
           
static
<A extends java.lang.annotation.Annotation>
A
findMethodAnnotation(java.lang.Class<A> annotationClass, java.lang.Class targetClass, java.lang.String methodName, java.lang.Class... parameterTypes)
          Returns the annotation for the given method (specified by name and parameterTypes) using the inheritance mechanism defined in JSR 250.
static
<A extends java.lang.annotation.Annotation>
A
findMethodAnnotation(java.lang.Class<A> annotationClass, java.lang.reflect.Method method, java.lang.Class clazz)
          Finds the annotation for a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AROUND_INVOKE_METHOD_PARAM

public static final java.lang.Class[] AROUND_INVOKE_METHOD_PARAM
Constructor Detail

JeeAnnotationUtils

public JeeAnnotationUtils()
Method Detail

findInheritedMemberAnnotation

public static <A extends java.lang.annotation.Annotation> A findInheritedMemberAnnotation(java.lang.Class<A> annotationClass,
                                                                                          java.lang.Class enclosingClass,
                                                                                          java.lang.reflect.AccessibleObject member)
Apply the jsr250 annotation algorithm to retrieve the annotation value for the given member. This method has to be called by after the lookup for the member has been executed.

Type Parameters:
A -
Parameters:
annotationClass -
enclosingClass -
member -
Returns:

findFieldAnnotation

public static <A extends java.lang.annotation.Annotation> A findFieldAnnotation(java.lang.Class<A> annotationClass,
                                                                                java.lang.Class targetClass,
                                                                                java.lang.String fieldName,
                                                                                java.lang.Class fieldType)
Returns the annotation for the given field (specified by name and type) using the inheritance mechanism defined in JSR 250. If the annotation is not found in the target class, the super classes will be searched for annotation using the jsr250 specs inheritance mechanism.

Type Parameters:
A -
Parameters:
annotationClass - annotation class to look for
targetClass - target class to look at
fieldName - field name
fieldType - field type (optional - can be null)
Returns:
null if no annotation was found using the algorithm, not null otherwise

findMethodAnnotation

public static <A extends java.lang.annotation.Annotation> A findMethodAnnotation(java.lang.Class<A> annotationClass,
                                                                                 java.lang.Class targetClass,
                                                                                 java.lang.String methodName,
                                                                                 java.lang.Class... parameterTypes)
Returns the annotation for the given method (specified by name and parameterTypes) using the inheritance mechanism defined in JSR 250. If the annotation is not found in the target class, the super classes will be searched for the annotation using the jsr250 spec inheritance mechanism.

Type Parameters:
A -
Parameters:
annotationClass -
targetClass -
methodName -
parameterTypes -
Returns:

findMethodAnnotation

public static <A extends java.lang.annotation.Annotation> A findMethodAnnotation(java.lang.Class<A> annotationClass,
                                                                                 java.lang.Class targetClass,
                                                                                 java.lang.String methodName)

findMethodAnnotation

public static <A extends java.lang.annotation.Annotation> A findMethodAnnotation(java.lang.Class<A> annotationClass,
                                                                                 java.lang.reflect.Method method,
                                                                                 java.lang.Class clazz)
Finds the annotation for a method. It does not use JSR-250 inheritance (ignores class level annotations and looks only at method level).

Type Parameters:
A -
Parameters:
annotationClass -
method -
clazz -
Returns:

findAnnotatedMethods

public static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz,
                                                                            java.lang.Class<? extends java.lang.annotation.Annotation> A)
Find all the methods on the given class and superclasses that have the given annotation.

Parameters:
clazz -
A -
Returns:

findAnnotatedMethods

public static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz,
                                                                            java.lang.Class<? extends java.lang.annotation.Annotation> A,
                                                                            java.lang.Class... argTypes)
Find all the methods on the given class and superclasses that have the given annotation and the given signature (jsr250 is not applied).

Parameters:
clazz -
A -
argTypes -
Returns:

findFirstAnnotatedMethod

public static java.lang.reflect.Method findFirstAnnotatedMethod(java.lang.Class clazz,
                                                                java.lang.Class<? extends java.lang.annotation.Annotation> A,
                                                                java.lang.Class... argTypes)
Find all methods with the given annotation and argument types on the given class and all its superclasses.

Parameters:
clazz - component class to introspect
A - class of annotation to find
argTypes - types of arguments to expect
Returns:
a no-arg method with this annotation

findAroundInvokeMethod

public static java.lang.reflect.Method findAroundInvokeMethod(java.lang.Class clazz)
Find the EJB3 around invoke method



Copyright 2006 Interface21. All Rights Reserved.