public final class AnnotationAcceptingListener extends java.lang.Object implements ResourceProcessor
Java classes of a Java class file are processed, using ASM, to ascertain if those classes are annotated with one or more of the set of declared annotations.
Such an annotated Java class of a Java class file is loaded if the class is public or is an inner class that is static and public.
Modifier and Type | Class and Description |
---|---|
private class |
AnnotationAcceptingListener.AnnotatedClassVisitor |
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
annotations |
private java.util.Set<java.lang.Class<?>> |
classes |
private java.lang.ClassLoader |
classloader |
private AnnotationAcceptingListener.AnnotatedClassVisitor |
classVisitor |
Constructor and Description |
---|
AnnotationAcceptingListener(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Create a scanner listener to check for annotated Java classes in Java
class files.
|
AnnotationAcceptingListener(java.lang.ClassLoader classloader,
java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Create a scanner listener to check for annotated Java classes in Java
class files.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.lang.String name)
Accept a scanned resource.
|
java.util.Set<java.lang.Class<?>> |
getAnnotatedClasses()
Get the set of annotated classes.
|
private java.util.Set<java.lang.String> |
getAnnotationSet(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations) |
static AnnotationAcceptingListener |
newJaxrsResourceAndProviderListener()
Create a scanning listener to check for Java classes in Java
class files annotated with
Path or Provider . |
static AnnotationAcceptingListener |
newJaxrsResourceAndProviderListener(java.lang.ClassLoader classLoader)
Create a scanning listener to check for Java classes in Java
class files annotated with
Path or Provider . |
void |
process(java.lang.String name,
java.io.InputStream in)
Process a scanned resource.
|
private final java.lang.ClassLoader classloader
private final java.util.Set<java.lang.Class<?>> classes
private final java.util.Set<java.lang.String> annotations
private final AnnotationAcceptingListener.AnnotatedClassVisitor classVisitor
public AnnotationAcceptingListener(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
annotations
- the set of annotation classes to check on Java class
files.public AnnotationAcceptingListener(java.lang.ClassLoader classloader, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
classloader
- the class loader to use to load Java classes that
are annotated with any one of the annotations.annotations
- the set of annotation classes to check on Java class
files.public static AnnotationAcceptingListener newJaxrsResourceAndProviderListener()
Path
or Provider
.AnnotationAcceptingListener
which looks for
Path
or Provider
annotated classes.public static AnnotationAcceptingListener newJaxrsResourceAndProviderListener(java.lang.ClassLoader classLoader)
Path
or Provider
.classLoader
- the class loader to use to load Java classes that
are annotated with any one of the annotations.AnnotationAcceptingListener
which looks for
Path
or Provider
annotated classes.public java.util.Set<java.lang.Class<?>> getAnnotatedClasses()
private java.util.Set<java.lang.String> getAnnotationSet(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
public boolean accept(java.lang.String name)
ResourceProcessor
accept
in interface ResourceProcessor
name
- the resource name.public void process(java.lang.String name, java.io.InputStream in) throws java.io.IOException
ResourceProcessor
This method will be invoked after the listener has accepted the resource.
process
in interface ResourceProcessor
name
- the resource name.in
- the input stream of the resourcejava.io.IOException
- if an error occurs when processing the resource.