com.sun.jersey.spi.scanning
Class AnnotationScannerListener

java.lang.Object
  extended by com.sun.jersey.spi.scanning.AnnotationScannerListener
All Implemented Interfaces:
ScannerListener
Direct Known Subclasses:
PathProviderScannerListener

public class AnnotationScannerListener
extends Object
implements ScannerListener

A scanner listener that processes Java class files (resource names ending in ".class") annotated with one or more of a set of declared annotations.

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.

Author:
Paul.Sandoz@Sun.Com

Constructor Summary
AnnotationScannerListener(Class<? extends Annotation>... annotations)
          Create a scanner listener to check for annotated Java classes in Java class files.
AnnotationScannerListener(ClassLoader classloader, Class<? extends Annotation>... annotations)
          Create a scanner listener to check for annotated Java classes in Java class files.
 
Method Summary
 Set<Class<?>> getAnnotatedClasses()
          Get the set of annotated classes.
 boolean onAccept(String name)
          Accept a scanned resource.
 void onProcess(String name, InputStream in)
          Process a scanned resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationScannerListener

public AnnotationScannerListener(Class<? extends Annotation>... annotations)
Create a scanner listener to check for annotated Java classes in Java class files.

Parameters:
annotations - the set of annotation classes to check on Java class files.

AnnotationScannerListener

public AnnotationScannerListener(ClassLoader classloader,
                                 Class<? extends Annotation>... annotations)
Create a scanner listener to check for annotated Java classes in Java class files.

Parameters:
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.
Method Detail

getAnnotatedClasses

public Set<Class<?>> getAnnotatedClasses()
Get the set of annotated classes.

Returns:
the set of annotated classes.

onAccept

public boolean onAccept(String name)
Description copied from interface: ScannerListener
Accept a scanned resource.

This method will be invoked by a Scanner to ascertain if the listener accepts the resource for processing. If acceptable then the Scanner will then invoke the ScannerListener.onProcess(java.lang.String, java.io.InputStream) method.

Specified by:
onAccept in interface ScannerListener
Parameters:
name - the resource name.
Returns:
true if the resource is accepted for processing, otherwise false.

onProcess

public void onProcess(String name,
                      InputStream in)
               throws IOException
Description copied from interface: ScannerListener
Process a scanned resource.

This method will be invoked after the listener has accepted the resource.

Specified by:
onProcess in interface ScannerListener
Parameters:
name - the resource name.
in - the input stream of the resource
Throws:
IOException - if an error occurs when processing the resource.


Copyright © 2013 Oracle Corporation. All Rights Reserved.