Top Description Inners Fields Constructors Methods
org.mortbay.jetty.annotations

public Class AnnotationFinder

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.lang.reflect.Array, .Field, .Method, java.net.URL, .URLClassLoader, java.util.ArrayList, .Arrays, .HashMap, .Iterator, .List, .Map, java.util.jar.JarEntry, java.util.regex.Pattern, org.mortbay.jetty.webapp.JarScanner, org.mortbay.log.Log, org.mortbay.resource.Resource, org.mortbay.util.Loader, org.objectweb.asm.AnnotationVisitor, .ClassReader, .FieldVisitor, .MethodVisitor, .Type, org.objectweb.asm.commons.EmptyVisitor

AnnotationFinder Scans class sources using asm to find annotations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AnnotationFinder.AnnotatedStructure

AnnotatedStructure Annotations on an object such as a class, field or method.

public class
AnnotationFinder.MyClassVisitor

MyClassVisitor ASM visitor for a class.

public static class
AnnotationFinder.ParsedClass

ParsedClass A class that contains annotations.

public static class
AnnotationFinder.ParsedField

ParsedField A class field that can contain annotations.

public static class
AnnotationFinder.ParsedMethod

ParsedMethod A class method that can contain annotations.

Field Summary

Modifier and TypeField and Description
private Map<String, AnnotationFinder.ParsedClass>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Class<T>
public static Class<T>[]
convertTypes(Type[] types)

protected boolean
excludeClass(String name)

Exclude class by name Instances of AnnotationFinder can implement this method to exclude classes by name.

public void
find(String className, ClassNameResolver resolver)

public void
find(String[] classNames, ClassNameResolver resolver)

public void
find(List<String> classNames, ClassNameResolver resolver)

public void
public void
find(ClassLoader loader, boolean visitParents, String jarNamePattern, boolean nullInclusive, final ClassNameResolver resolver)

public List<Class<?>>
getClassesForAnnotation(Class<?> annotationClass)

public List<Field>
public List<Method>
getMethodsForAnnotation(Class<?> annotationClass)

public static String
private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

parsedClassesback to summary
private Map<String, AnnotationFinder.ParsedClass> parsedClasses

Constructor Detail

AnnotationFinderback to summary
public AnnotationFinder()

Method Detail

convertTypeback to summary
public static Class<T> convertType(Type t) throws Exception
convertTypesback to summary
public static Class<T>[] convertTypes(Type[] types) throws Exception
excludeClassback to summary
protected boolean excludeClass(String name)

Exclude class by name Instances of AnnotationFinder can implement this method to exclude classes by name.

findback to summary
public void find(String className, ClassNameResolver resolver) throws Exception
findback to summary
public void find(String[] classNames, ClassNameResolver resolver) throws Exception
findback to summary
public void find(List<String> classNames, ClassNameResolver resolver) throws Exception
findback to summary
public void find(Resource dir, ClassNameResolver resolver) throws Exception
findback to summary
public void find(ClassLoader loader, boolean visitParents, String jarNamePattern, boolean nullInclusive, final ClassNameResolver resolver) throws Exception
getClassesForAnnotationback to summary
public List<Class<?>> getClassesForAnnotation(Class<?> annotationClass) throws Exception
getFieldsForAnnotationback to summary
public List<Field> getFieldsForAnnotation(Class<?> annotation) throws Exception
getMethodsForAnnotationback to summary
public List<Method> getMethodsForAnnotation(Class<?> annotationClass) throws Exception
normalizeback to summary
public static String normalize(String name)
scanClassback to summary
private void scanClass(InputStream is) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

org.mortbay.jetty.annotations back to summary

public Class AnnotationFinder.AnnotatedStructure

extends EmptyVisitor
Class Inheritance
Known Direct Subclasses
org.mortbay.jetty.annotations.AnnotationFinder.ParsedClass, org.mortbay.jetty.annotations.AnnotationFinder.ParsedMethod, org.mortbay.jetty.annotations.AnnotationFinder.ParsedField

AnnotatedStructure Annotations on an object such as a class, field or method.

Field Summary

Modifier and TypeField and Description
pack-priv Map<String, Map<String, Object>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AnnotationVisitor
addAnnotation(final String name)

public Map<String, Map<String, Object>>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.objectweb.asm.commons.EmptyVisitor:
visitvisitvisitAnnotationvisitAnnotationvisitAnnotationDefaultvisitArrayvisitAttributevisitCodevisitEndvisitEnumvisitFieldvisitFieldInsnvisitFramevisitIincInsnvisitInnerClassvisitInsnvisitIntInsnvisitJumpInsnvisitLabelvisitLdcInsnvisitLineNumbervisitLocalVariablevisitLookupSwitchInsnvisitMaxsvisitMethodvisitMethodInsnvisitMultiANewArrayInsnvisitOuterClassvisitParameterAnnotationvisitSourcevisitTableSwitchInsnvisitTryCatchBlockvisitTypeInsnvisitVarInsn

Field Detail

annotationsback to summary
pack-priv Map<String, Map<String, Object>> annotations

Constructor Detail

AnnotatedStructureback to summary
public AnnotatedStructure()

Method Detail

addAnnotationback to summary
public AnnotationVisitor addAnnotation(final String name)
getAnnotationsback to summary
public Map<String, Map<String, Object>> getAnnotations()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

org.mortbay.jetty.annotations back to summary

public Class AnnotationFinder.MyClassVisitor

extends EmptyVisitor
Class Inheritance

MyClassVisitor ASM visitor for a class.

Field Summary

Modifier and TypeField and Description
pack-priv AnnotationFinder.ParsedClass

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
visit(int
the class version.
version
,
int
the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated.
access
,
String
the internal name of the class (see getInternalName).
name
,
String
the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
signature
,
String
the internal of name of the super class (see getInternalName). For interfaces, the super class is Object. May be null, but only for the Object class.
superName
,
String[]
the internal names of the class's interfaces (see getInternalName). May be null.
interfaces
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visit.

Implements org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of the class.
public FieldVisitor
visitField(int
the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.
access
,
String
the field's name.
name
,
String
the field's descriptor (see Type).
desc
,
String
the field's signature. May be null if the field's type does not use generic types.
signature
,
Object
the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.
value
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitField.

Implements org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.
public MethodVisitor
visitMethod(int
the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
access
,
String
the method's name.
name
,
String
the method's descriptor (see Type).
desc
,
String
the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
signature
,
String[]
the internal names of the method's exception classes (see getInternalName). May be null.
exceptions
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitMethod.

Implements org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class.
Inherited from org.objectweb.asm.commons.EmptyVisitor:
visitvisitAnnotationvisitAnnotationDefaultvisitArrayvisitAttributevisitCodevisitEndvisitEnumvisitFieldInsnvisitFramevisitIincInsnvisitInnerClassvisitInsnvisitIntInsnvisitJumpInsnvisitLabelvisitLdcInsnvisitLineNumbervisitLocalVariablevisitLookupSwitchInsnvisitMaxsvisitMethodInsnvisitMultiANewArrayInsnvisitOuterClassvisitParameterAnnotationvisitSourcevisitTableSwitchInsnvisitTryCatchBlockvisitTypeInsnvisitVarInsn

Field Detail

pclassback to summary
pack-priv AnnotationFinder.ParsedClass pclass

Constructor Detail

MyClassVisitorback to summary
public MyClassVisitor()

Method Detail

visitback to summary
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)

Overrides org.objectweb.asm.commons.EmptyVisitor.visit.

Implements org.objectweb.asm.ClassVisitor.visit.

Doc from org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.

Parameters
version:int

the class version.

access:int

the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated.

name:String

the internal name of the class (see getInternalName).

signature:String

the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.

superName:String

the internal of name of the super class (see getInternalName). For interfaces, the super class is Object. May be null, but only for the Object class.

interfaces:String[]

the internal names of the class's interfaces (see getInternalName). May be null.

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Doc from org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

visitFieldback to summary
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitField.

Implements org.objectweb.asm.ClassVisitor.visitField.

Doc from org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.

Parameters
access:int

the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.

name:String

the field's name.

desc:String

the field's descriptor (see Type).

signature:String

the field's signature. May be null if the field's type does not use generic types.

value:Object

the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.

Returns:FieldVisitor

a visitor to visit field annotations and attributes, or null if this class visitor is not interested in visiting these annotations and attributes.

visitMethodback to summary
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitMethod.

Implements org.objectweb.asm.ClassVisitor.visitMethod.

Doc from org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class. This method must return a new MethodVisitor instance (or null) each time it is called, i.e., it should not return a previously returned visitor.

Parameters
access:int

the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.

name:String

the method's name.

desc:String

the method's descriptor (see Type).

signature:String

the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.

exceptions:String[]

the internal names of the method's exception classes (see getInternalName). May be null.

Returns:MethodVisitor

an object to visit the byte code of the method, or null if this class visitor is not interested in visiting the code of this method.

org.mortbay.jetty.annotations back to summary

public Class AnnotationFinder.ParsedClass

extends AnnotatedStructure
Class Inheritance

ParsedClass A class that contains annotations.

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv Class<T>
pack-priv List<AnnotationFinder.ParsedField>
pack-priv List<AnnotationFinder.ParsedMethod>
pack-priv String
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
annotations

Constructor Summary

AccessConstructor and Description
public
ParsedClass(String className, String superClassName)

Method Summary

Modifier and TypeMethod and Description
public void
public void
public String
public AnnotationFinder.ParsedField
public List<AnnotationFinder.ParsedField>
public AnnotationFinder.ParsedMethod
getMethod(String name, String paramString)

public List<AnnotationFinder.ParsedMethod>
public String
public Class<T>
public String
toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Returns a string representation of the object.
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
addAnnotationgetAnnotations

Field Detail

classNameback to summary
pack-priv String className
clazzback to summary
pack-priv Class<T> clazz
fieldsback to summary
pack-priv List<AnnotationFinder.ParsedField> fields
methodsback to summary
pack-priv List<AnnotationFinder.ParsedMethod> methods
superClassNameback to summary
pack-priv String superClassName

Constructor Detail

ParsedClassback to summary
public ParsedClass(String className, String superClassName)

Method Detail

addFieldback to summary
public void addField(AnnotationFinder.ParsedField f)
addMethodback to summary
public void addMethod(AnnotationFinder.ParsedMethod m)
getClassNameback to summary
public String getClassName()
getFieldback to summary
public AnnotationFinder.ParsedField getField(String name)
getFieldsback to summary
public List<AnnotationFinder.ParsedField> getFields()
getMethodback to summary
public AnnotationFinder.ParsedMethod getMethod(String name, String paramString)
getMethodsback to summary
public List<AnnotationFinder.ParsedMethod> getMethods()
getSuperClassNameback to summary
public String getSuperClassName()
toClassback to summary
public Class<T> toClass() throws ClassNotFoundException
toStringback to summary
public String toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

org.mortbay.jetty.annotations back to summary

public Class AnnotationFinder.ParsedField

extends AnnotatedStructure
Class Inheritance

ParsedField A class field that can contain annotations. Also implements the asm visitor for Annotations.

Field Summary

Modifier and TypeField and Description
pack-priv Field
pack-priv String
pack-priv AnnotationFinder.ParsedClass
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
annotations

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public Field
public String
toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Returns a string representation of the object.
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of the class.
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
addAnnotationgetAnnotations

Field Detail

fieldback to summary
pack-priv Field field
fieldNameback to summary
pack-priv String fieldName
pclassback to summary
pack-priv AnnotationFinder.ParsedClass pclass

Constructor Detail

ParsedFieldback to summary
public ParsedField(AnnotationFinder.ParsedClass pclass, String name)

Method Detail

matchesback to summary
public boolean matches(String name)
toFieldback to summary
public Field toField() throws Exception
toStringback to summary
public String toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Doc from org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

org.mortbay.jetty.annotations back to summary

public Class AnnotationFinder.ParsedMethod

extends AnnotatedStructure
Class Inheritance

ParsedMethod A class method that can contain annotations.

Field Summary

Modifier and TypeField and Description
pack-priv Method
pack-priv String
pack-priv String
pack-priv AnnotationFinder.ParsedClass
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
annotations

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
matches(String name, String paramString)

public Method
public String
toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Returns a string representation of the object.
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of the class.
Inherited from org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure:
addAnnotationgetAnnotations

Field Detail

methodback to summary
pack-priv Method method
methodNameback to summary
pack-priv String methodName
paramStringback to summary
pack-priv String paramString
pclassback to summary
pack-priv AnnotationFinder.ParsedClass pclass

Constructor Detail

ParsedMethodback to summary
public ParsedMethod(AnnotationFinder.ParsedClass pclass, String name, String paramString)

Method Detail

matchesback to summary
public boolean matches(String name, String paramString)
toMethodback to summary
public Method toMethod() throws Exception
toStringback to summary
public String toString()

Overrides org.mortbay.jetty.annotations.AnnotationFinder.AnnotatedStructure.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.commons.EmptyVisitor.visitAnnotation.

Implements org.objectweb.asm.ClassVisitor.visitAnnotation, org.objectweb.asm.FieldVisitor.visitAnnotation, org.objectweb.asm.MethodVisitor.visitAnnotation.

Doc from org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.