Package org.glassfish.apf.impl
Class AnnotationProcessorImpl
- java.lang.Object
-
- org.glassfish.apf.impl.AnnotationProcessorImpl
-
- All Implemented Interfaces:
AnnotationProcessor
public class AnnotationProcessorImpl extends Object implements AnnotationProcessor
- Author:
- dochez
-
-
Constructor Summary
Constructors Constructor Description AnnotationProcessorImpl()
Creates a new instance of AnnotationProcessorImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProcessingContext
createContext()
Creates a new empty ProcessingContext instance which can be configured before invoking the process() method.AnnotationHandler
getAnnotationHandler(Class<? extends Annotation> type)
AnnotatedElement
getLastAnnotatedElement(ElementType type)
Stack<org.glassfish.apf.impl.StackElement>
getStack()
void
log(Level level, AnnotationInfo locator, String localizedMessage)
Log a message on the default loggervoid
popAnnotationHandler(Class<? extends Annotation> type)
Unregisters the last annotation handler registered for an annotation type.ProcessingResult
process(ProcessingContext ctx)
Starts the annotation processing tool passing the processing context which encapsulate all information necessary for the configuration of the tool.ProcessingResult
process(ProcessingContext ctx, Class[] classes)
Process a set of classes from the parameter list rather than from the processing context.void
pushAnnotationHandler(String type, AnnotationHandler handler)
This method is similar topushAnnotationHandler(AnnotationHandler)
except that it takes an additional String type argument which allows us to avoid extracting the information from the AnnotationHandler.void
pushAnnotationHandler(AnnotationHandler handler)
Registers a new AnnotationHandler for a particular annotation type.void
setDelegate(AnnotationProcessorImpl delegate)
-
-
-
Method Detail
-
setDelegate
public void setDelegate(AnnotationProcessorImpl delegate)
-
createContext
public ProcessingContext createContext()
Description copied from interface:AnnotationProcessor
Creates a new empty ProcessingContext instance which can be configured before invoking the process() method.- Specified by:
createContext
in interfaceAnnotationProcessor
- Returns:
- an empty ProcessingContext
-
log
public void log(Level level, AnnotationInfo locator, String localizedMessage)
Log a message on the default logger- Specified by:
log
in interfaceAnnotationProcessor
- Parameters:
level
-locator
-localizedMessage
-
-
process
public ProcessingResult process(ProcessingContext ctx) throws AnnotationProcessorException
Starts the annotation processing tool passing the processing context which encapsulate all information necessary for the configuration of the tool.- Specified by:
process
in interfaceAnnotationProcessor
- Parameters:
ctx
- is the initialised processing context- Returns:
- the result of the annotations processing
- Throws:
AnnotationProcessorException
-
process
public ProcessingResult process(ProcessingContext ctx, Class[] classes) throws AnnotationProcessorException
Process a set of classes from the parameter list rather than from the processing context. This allow the annotation handlers to call be the annotation processing tool when classes need to be processed in a particular context rather than when they are picked up by the scanner.- Specified by:
process
in interfaceAnnotationProcessor
- Parameters:
ctx
- the processing contextclasses
- the list of classes to process- Returns:
- the processing result for such classes
- Throws:
AnnotationProcessorException
- if handlers fail to process an annotation
-
pushAnnotationHandler
public void pushAnnotationHandler(AnnotationHandler handler)
Description copied from interface:AnnotationProcessor
Registers a new AnnotationHandler for a particular annotation type. New annotation handler are pushed on a List of annotation handlers for that particular annotation type, the last annotation handler to be registered will be invoked first and so on. The annotation type handled by the AnnotationHandler instance is defined by the getAnnotationType() method of the AnnotationHandler instance- Specified by:
pushAnnotationHandler
in interfaceAnnotationProcessor
- Parameters:
handler
- the annotation handler instance
-
pushAnnotationHandler
public void pushAnnotationHandler(String type, AnnotationHandler handler)
This method is similar topushAnnotationHandler(AnnotationHandler)
except that it takes an additional String type argument which allows us to avoid extracting the information from the AnnotationHandler. Calling the AnnotationHandler can lead to its instantiation where as the annotation that a handler is responsible for handling is a metadata that can be statically extracted. This allows us to build more lazy systems.- Parameters:
type
-handler
-
-
popAnnotationHandler
public void popAnnotationHandler(Class<? extends Annotation> type)
Description copied from interface:AnnotationProcessor
Unregisters the last annotation handler registered for an annotation type.- Specified by:
popAnnotationHandler
in interfaceAnnotationProcessor
- Parameters:
type
- the annotation type.
-
getAnnotationHandler
public AnnotationHandler getAnnotationHandler(Class<? extends Annotation> type)
- Specified by:
getAnnotationHandler
in interfaceAnnotationProcessor
- Parameters:
type
- the annotation type- Returns:
- the top annotation handler for a particular annotation type
-
getLastAnnotatedElement
public AnnotatedElement getLastAnnotatedElement(ElementType type)
- Specified by:
getLastAnnotatedElement
in interfaceAnnotationProcessor
- Parameters:
type
-- Returns:
- the last element pushed on the stack which ElementType was the one passed or null if no stack element is of the given type.
-
getStack
public Stack<org.glassfish.apf.impl.StackElement> getStack()
-
-