Class AnnotationParser
java.lang.Object
org.eclipse.jetty.ee10.annotations.AnnotationParser
- Direct Known Subclasses:
AnnotationParser
AnnotationParser
Use asm to scan classes for annotations. A SAX-style parsing is done. Handlers are registered which will be called back when various types of entity are encountered, eg a class, a method, a field.
Handlers are not called back in any particular order and are assumed to be order-independent.
As a registered Handler will be called back for each annotation discovered on a class, a method, a field, the Handler should test to see if the annotation is one that it is interested in.
For the servlet spec, we are only interested in annotations on classes, methods and fields, so the callbacks for handling finding a class, a method a field are themselves not fully implemented.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Convenience base class to provide no-ops for all Handler methods.static class
Immutable information gathered by parsing class header.static class
Immutable information gathered by parsing a field on a class.static interface
Signature for all handlers that respond to parsing class files.static class
Immutable information gathered by parsing a method on a class.static class
ASM visitor for a class.static class
An ASM visitor for parsing Fields.static class
ASM Visitor for parsing a method. -
Field Summary
Modifier and TypeFieldDescriptionMap of classnames scanned and the first location from which scan occurred -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Convert internal name to simple namestatic String[]
Convert internal names to simple names.void
parse
(Set<? extends AnnotationParser.Handler> handlers, Resource r) Parse a resourceprotected void
parseClass
(Set<? extends AnnotationParser.Handler> handlers, Resource containingResource, Path classFile) Use ASM on a classprotected void
parseDir
(Set<? extends AnnotationParser.Handler> handlers, Resource dirResource) Parse all classes in a directoryprotected void
parseJar
(Set<? extends AnnotationParser.Handler> handlers, Resource jarResource) Parse a resource that is a jar file.
-
Field Details
-
_parsedClassNames
Map of classnames scanned and the first location from which scan occurred
-
-
Constructor Details
-
AnnotationParser
public AnnotationParser() -
AnnotationParser
public AnnotationParser(int asmVersion) - Parameters:
asmVersion
- The target asm version or 0 for the internal version.
-
-
Method Details
-
normalize
Convert internal name to simple name- Parameters:
name
- the internal name- Returns:
- the simple name
-
normalize
Convert internal names to simple names.- Parameters:
list
- the list of internal names- Returns:
- the array of simple names
-
parse
Parse a resource- Parameters:
handlers
- the handlers to look for classes inr
- the resource to parse- Throws:
Exception
- if unable to parse
-
parseDir
protected void parseDir(Set<? extends AnnotationParser.Handler> handlers, Resource dirResource) throws Exception Parse all classes in a directory- Parameters:
handlers
- the set of handlers to look for classes indirResource
- the resource representing the baseResource being scanned (jar, dir, etc)- Throws:
Exception
- if unable to parse
-
parseJar
protected void parseJar(Set<? extends AnnotationParser.Handler> handlers, Resource jarResource) throws Exception Parse a resource that is a jar file.- Parameters:
handlers
- the handlers to look for classes injarResource
- the jar resource to parse- Throws:
Exception
- if unable to parse
-
parseClass
protected void parseClass(Set<? extends AnnotationParser.Handler> handlers, Resource containingResource, Path classFile) throws IOException Use ASM on a class- Parameters:
handlers
- the handlers to look for classes incontainingResource
- the dir or jar that the class is contained within, can be null if not knownclassFile
- the class file to parse- Throws:
IOException
- if unable to parse
-