net.sf.staccatocommons.instrument.handler
Interface MethodAnnotationHandler<A extends Annotation>

Type Parameters:
A - the type of annotation this handler can process
All Superinterfaces:
AnnotationHandler<A>

public interface MethodAnnotationHandler<A extends Annotation>
extends AnnotationHandler<A>

Interface for annotation handlers that can process annotations in methods.

This interface exposes both a preProcessAnnotatedMethod(Annotation, MethodAnnotationContext) and postProcessAnnotatedMethod(Annotation, MethodAnnotationContext), in order to let clients perform any instrumentation or context update whenever they need - after, before or around processing argument annotations.

Although in most scenarios implementing the handling logic in either on preprocesing or postprocessing is the same, there are specific cases where the distinction is important. Typical case is when a MethodAnnotationHandler instruments a method by surrounding it with some kind of block - a try-catch, for instance: if that instrumentation is performing during preprocessing, and then, an ArgumentAnnotationHandler that discovers an annotation on the same method inserts some portion of code, that code may be placed after or before the block. However, if performed on postprocessing, such portion of code will be always surrounded by the block.

Author:
flbulgarelli
See Also:
AnnotationHandler

Method Summary
 void postProcessAnnotatedMethod(A annotation, MethodAnnotationContext context)
          Process an annotation discovered in a method by the instrumenter, instrumenting the given context where the annotation was found.
 void preProcessAnnotatedMethod(A annotation, MethodAnnotationContext context)
          Process an annotation discovered in a method by the instrumenter, instrumenting the given context where the annotation was found.
 
Methods inherited from interface net.sf.staccatocommons.instrument.handler.AnnotationHandler
getSupportedAnnotationType
 

Method Detail

preProcessAnnotatedMethod

void preProcessAnnotatedMethod(@NonNull
                               A annotation,
                               @NonNull
                               MethodAnnotationContext context)
                               throws javassist.CannotCompileException,
                                      javassist.NotFoundException
Process an annotation discovered in a method by the instrumenter, instrumenting the given context where the annotation was found. This message is sent by the instrumenter before discovering any argument annotation.

Parameters:
annotation - the annotation to process
context - the instrumentable context where the annotation was found
Throws:
javassist.CannotCompileException - if compilation errors occur during instrumentation
javassist.NotFoundException - if any type needed by instrumentation was not found

postProcessAnnotatedMethod

void postProcessAnnotatedMethod(@NonNull
                                A annotation,
                                @NonNull
                                MethodAnnotationContext context)
                                throws javassist.CannotCompileException,
                                       javassist.NotFoundException
Process an annotation discovered in a method by the instrumenter, instrumenting the given context where the annotation was found. This message is sent by the instrumenter after discovering and processing all arguments annotations.

Parameters:
annotation - the annotation to process
context - the instrumentable context where the annotation was found
Throws:
javassist.CannotCompileException - if compilation errors occur during instrumentation
javassist.NotFoundException - if any type needed by instrumentation was not found


Copyright © 2010-2012 StaccatoCommons. All Rights Reserved.