|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.tnt.ldaputils.annotations.processing.LdapEntityHandler
public abstract class LdapEntityHandler
IAnnotationHandler
abstract implementation that processes LPA
annotations for the purpose of providing a base Class for other LdapEntity
annotation processing handlers.
Field Summary | |
---|---|
protected Object |
entity
The LdapEntity annotated object instance. |
protected LdapManager |
manager
Manager instance that is calling the handler |
Constructor Summary | |
---|---|
LdapEntityHandler()
|
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. |
protected Object |
getReferencedEntity(Class entityClass,
String dnReference,
Object attributeValue)
Retrieves the referenced dn, given the dnReference (see LdapAttribute.referencedDNMethod() for more information) and the
attributeValue, and creates a new LdapEntity object. |
protected static boolean |
isMultiValued(Class fieldType)
Simply determines if this is a multi valued field. |
void |
noAnnotation(Class annotatedClass)
Called if no annotation on a particular class exists. |
protected boolean |
preProcessAnnotation(LdapEntity annotation,
Class annotatedClass)
Does annotation pre-processing, in case the subclass wants to do something special before anything is processed. |
protected Object |
processAggregate(Field field,
Class annotatedClass,
Class<?> aggClass,
LdapAttribute attrAnnotation)
WARNING! WARNING! WARNING! It is not recommended that you override this method. |
boolean |
processAnnotation(Annotation annotation,
Class annotatedClass)
WARNING! WARNING! WARNING! It is not recommended that you override this method. |
protected abstract Object |
processAttribute(Field field,
LdapAttribute attrAnnotation)
Simple attribute processing. |
protected abstract void |
processDN(Class annotatedClass,
Field field)
Processing for DN annotation |
protected abstract Object |
processForeignAggregate(Field field,
Class<?> aggClass,
String dnReference,
LdapAttribute attrAnnotation)
Called to process a foreign aggregate. |
protected void |
processLdapAttribute(Class annotatedClass,
Field field)
WARNING! WARNING! WARNING! It is not recommended that you override this method. |
protected abstract void |
processLdapAttributes(Field field)
Processing for LdapAttribute annotation where name is '*' |
protected abstract Object |
processLocalAggregate(Field field,
Class<?> aggClass,
LdapAttribute attrAnnotation)
Do what you need to for the local aggregate. |
protected void |
processManager(Field field)
Handles injecting the manager. |
protected boolean |
validateDN(Class annotatedClass,
Field field)
WARNING! WARNING! WARNING! It is not recommended that you override this method. |
protected boolean |
validateObjectClasses(LdapEntity annotation,
Attributes attributes)
Validates object classes for the entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface ca.tnt.ldaputils.annotations.processing.IAnnotationHandler |
---|
setManager, validateProcessing |
Field Detail |
---|
protected Object entity
LdapEntity
annotated object instance.
protected LdapManager manager
Constructor Detail |
---|
public LdapEntityHandler()
Method Detail |
---|
protected static boolean isMultiValued(Class fieldType)
fieldType
- the field's type
public boolean processAnnotation(Annotation annotation, Class annotatedClass)
LdapEntity
related annotation methods, such as processManager(java.lang.reflect.Field)
, processDN(java.lang.Class, java.lang.reflect.Field)
, and processLdapAttribute(java.lang.Class, java.lang.reflect.Field)
,
processAnnotation
in interface IAnnotationHandler
annotation
- the annotationannotatedClass
- the field to process
protected boolean preProcessAnnotation(LdapEntity annotation, Class annotatedClass)
annotation
- the annotation being processedannotatedClass
- the annotated class with the annotation
protected boolean validateObjectClasses(LdapEntity annotation, Attributes attributes)
annotation
- the LdapEntity
annotation instance for the
classattributes
- the attributes to validate against
protected void processManager(Field field) throws IllegalAccessException
field
- the field to inject the manager to
IllegalAccessException
- if java policies prevent access to fields
via reflectionprotected abstract void processLdapAttributes(Field field) throws IllegalAccessException
LdapAttribute
annotation where name is '*'
field
- the field the annotation is on
IllegalAccessException
- if java policies prevent access to fields
via reflectionprotected abstract void processDN(Class annotatedClass, Field field) throws IllegalAccessException, NoSuchMethodException
DN
annotation
annotatedClass
- class of the annotated objectfield
- the field the annotation is on
IllegalAccessException
- if java policies prevent access to fields
via reflection
NoSuchMethodException
- if the LdapAttribute.referencedDNMethod()
is the name of a method that does not
existprotected boolean validateDN(Class annotatedClass, Field field) throws NoSuchMethodException
DN
, and that the
property getter is available.
CRITICAL ldap entities REQUIRE dn setter too (issue-17)
annotatedClass
- the LdapEntity
annotated classfield
- the field annotated with DN
NoSuchMethodException
- if the LdapAttribute.referencedDNMethod()
is the name of a method that does not
existprotected void processLdapAttribute(Class annotatedClass, Field field) throws IllegalAccessException, NamingException, InvocationTargetException, NoSuchMethodException, InstantiationException
processAttribute(Field, LdapAttribute)
or processAggregate(Field, Class, Class, LdapAttribute)
. We also handle
the field injection.
Processing for LdapAttribute
annotation.
DOC move this to the appropriate subclass if needed, when we're done.
If the LdapEntity annotated Class is an instanceof TypeHandler
,
the TypeHandler.processValues(List, Class)
will be called for all
aggregate fields, instead of the normal type processing that goes on,
described by LdapAttribute
annotatedClass
- the class of the annotated objectfield
- the field the annotation is on
IllegalAccessException
- if java policies prevent access to
fields via reflection
InvocationTargetException
- an exception occured during the call to
the method defined by LdapAttribute.referencedDNMethod()
NoSuchMethodException
- if the LdapAttribute.referencedDNMethod()
is the name of a method that does not
exist
NamingException
- general JNDI exception wrapper for any
errors that occur in the directory
InstantiationException
- if an error occurs creating an
aggregate instance
ClassCastException
- if you use a supported collection that
is not parameterized, such as
SortedSet, instead of SortedSet<String>,
for example.protected abstract Object processAttribute(Field field, LdapAttribute attrAnnotation) throws NamingException, IllegalAccessException
field
- the field being processedattrAnnotation
- the LdapAttribute
annotation instance being
processed
NamingException
- general JNDI exception wrapper for any
errors that occur in the directory
IllegalAccessException
- if java policies prevent access to fields
via reflectionprotected Object processAggregate(Field field, Class annotatedClass, Class<?> aggClass, LdapAttribute attrAnnotation) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, NamingException
processForeignAggregate(Field,
Class, String, LdapAttribute)
or the processLocalAggregate(Field,
Class, LdapAttribute)
as appropriate.
field
- the field being processedannotatedClass
- the annotated LdapEntity
classaggClass
- the aggregate class as defined by LdapAttribute.aggregateClass()
attrAnnotation
- the LdapAttribute
annotation instance being
processed
IllegalAccessException
- if java policies prevent access to
fields via reflection
InstantiationException
- if an error occurs creating an
aggregate instance
NoSuchMethodException
- if the LdapAttribute.referencedDNMethod()
is the name of a method that does not
exist
InvocationTargetException
- an exception occured during the call to
the method defined by LdapAttribute.referencedDNMethod()
NamingException
- general JNDI exception wrapper for any
errors that occur in the directoryprotected Object getReferencedEntity(Class entityClass, String dnReference, Object attributeValue) throws InvalidNameException
LdapAttribute.referencedDNMethod()
for more information) and the
attributeValue, and creates a new LdapEntity object.
entityClass
- the java class of the LdapEntitydnReference
- the dn reference with a '?' bind parameterattributeValue
- the value of the attribute to escape, and inject
into dnReference before conversion to an LdapName
InvalidNameException
- if an error occurs creating the LdapName.public Class getAnnotatedClass()
IAnnotationHandler
AnnotationProcessor
also needs access to
this object in order to determine annotations on it.
getAnnotatedClass
in interface IAnnotationHandler
public Class<? extends Annotation> getAnnotationClass()
IAnnotationHandler
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.
getAnnotationClass
in interface IAnnotationHandler
public void noAnnotation(Class annotatedClass)
IAnnotationHandler
noAnnotation
in interface IAnnotationHandler
annotatedClass
- the class, in the object tree of IAnnotationHandler.getAnnotatedClass()
, that the annotation was NOT
found on.protected abstract Object processForeignAggregate(Field field, Class<?> aggClass, String dnReference, LdapAttribute attrAnnotation) throws NamingException, IllegalAccessException
LdapEntity
annotated instance, but is
instead reading from the instance.
Tip on implementing: aggregates are stored in one of two ways. SortedSet<MyAggregateClass> myAggregates
LdapAttribute.aggregateClass()
by asking if they are equal. See the LdapEntityLoader
source for
an example.
field
- the field being processedaggClass
- the aggregate class as defined by LdapAttribute.aggregateClass()
dnReference
- the "properly" formatted dn, with bind parameter,
as returned by the LdapAttribute.referencedDNMethod()
methodattrAnnotation
- the LdapAttribute
annotation instance being
processed
NamingException
- general JNDI exception wrapper for any
errors that occur in the directory
IllegalAccessException
- if java policies prevent access to fields
via reflectionprotected abstract Object processLocalAggregate(Field field, Class<?> aggClass, LdapAttribute attrAnnotation) throws IllegalAccessException, InstantiationException, NamingException
LdapEntity
annotated instance, but is instead reading from the instance.
A local aggregate is an aggregate object which will be injected into the
object field, which has requested it via LdapAttribute.aggregateClass()
,
and is also using the existing LDAP entry's attributes as a basis for the
object. See the documentation on LdapAttribute.aggregateClass()
for more information.
field
- the field being processedaggClass
- the aggregate class, if needed.attrAnnotation
- the LdapAttribute
annotation instance being
processed
IllegalAccessException
- if java policies prevent access to fields
via reflection
InstantiationException
- if an error occurs creating an aggregate
instance
NamingException
- general JNDI exception wrapper for any
errors that occur in the directory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This documentation is part of the LDAP Persistence API (LPA).
Copyright Trenton D. Adams <lpa at trentonadams daught ca>
LPA is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
LPA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with LPA. If not, see GNU Licenses.
See the COPYING file, in the git repository, for more information.