ca.tnt.ldaputils.annotations.processing
Interface IAnnotationHandler

Package class diagram package IAnnotationHandler
All Known Implementing Classes:
LdapEntityBinder, LdapEntityHandler, LdapEntityLoader

public interface IAnnotationHandler

Annotation callback handler. Implement this when you want to process annotations recursively through the entire tree of subclasses.

Created : 21-Aug-2010 11:51:11 PM MST

Author:
Trenton D. Adams

Method Summary
 Class getAnnotatedClass()
          It is expected that this handler has a reference to the object it wants to operate on.
 Class<? extends Annotation> getAnnotationClass()
          This is the primary Annotation (with target ElementType.TYPE) that this handler expects the annotated Class to be annotated with.
 void noAnnotation(Class annotatedClass)
          Called if no annotation on a particular class exists.
 boolean processAnnotation(Annotation annotation, Class annotatedClass)
          Process the annotation on the given annotatedClass.
 void setManager(LdapManager managerInstance)
          Sets the established ldap manager object, which should be pre-authenticated.
 void validateProcessing()
          Method for validating the processing of the annotations.
 

Method Detail

processAnnotation

boolean processAnnotation(Annotation annotation,
                          Class annotatedClass)
Process the annotation on the given annotatedClass. This is a callback to actually do something with the annotation.

it is recommended that the implementing object keeps track of problems and throws a RuntimeException in the validateProcessing() method if something went wrong.

Parameters:
annotation - the annotation
annotatedClass - the field to process
Returns:
true if annotation processing was successful
Throws:
RuntimeException - The implementor may throw a RuntimeException from this method. It is recommended that this does not occur, unless it is severe. First see validateProcessing()

getAnnotatedClass

Class getAnnotatedClass()
It is expected that this handler has a reference to the object it wants to operate on. The AnnotationProcessor also needs access to this object in order to determine annotations on it.

Returns:
the object to traverse the Class tree for.

getAnnotationClass

Class<? extends Annotation> getAnnotationClass()
This is the primary Annotation (with target ElementType.TYPE) that this handler expects the annotated Class to be annotated with. If the annotated class is annotated with this annotation, this indicates that this handler supports the Class being processed. If this handler does not support the Class being processed, the handler will never be called.

Returns:
the annotation class that this handler supports

noAnnotation

void noAnnotation(Class annotatedClass)
Called if no annotation on a particular class exists. The handler can do what it wants with it. It may be that we need annotated classes at only certain levels of the object tree, but not others. So, the handler could, for example, require that only the top level object has annotations, while the super classes do not need them. Or, perhaps it requires it the other way around, for some reason.

Parameters:
annotatedClass - the class, in the object tree of getAnnotatedClass(), that the annotation was NOT found on.

validateProcessing

void validateProcessing()
Method for validating the processing of the annotations. This is called after all classes in the class tree have been traversed and processed. This is the final validation, and is meant for problems that could not be detected until traversing the entire class tree. For example, it may be that you require a particular annotation on at least one class in the hierarchy, but your handler doesn't know when the end of Class hierarchy traversal is complete; this method is called after traversal completion.

Throws:
RuntimeException - if it is determined that a processing error has occurred that could not be determined until class hierarchy traversal is complete

setManager

void setManager(LdapManager managerInstance)
Sets the established ldap manager object, which should be pre-authenticated.

Parameters:
managerInstance - the already authenticated manager