|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.digitalis.dif.dem.DEMAnnotationLogic
public class DEMAnnotationLogic
Defines validation and enrichment logic for an annotationName or family of annotations. A set of methods validate general rules for any annotationName. Specific methods that can be overrided on sub-classes allow fine-grained validation rules. Methods that define the source code used on the code generation are also part of this class. TODO: Some logic that read the annotation values for processing is repeated here and in the ClassEnhancerImpl. Should be refactored for a single read operation. Maybe in 2.1 TODO: Making the xHolder classes inherit from a parent would eliminate the need of several similar methods with just different parameter types (as in validate() and validatePrimary()).
Field Summary | |
---|---|
protected static String |
APPLICATION_ATTRIBUTE_NAME
The 'application' attribute name. |
static String |
DEFAULT_DEM_ANNOTATION_LOGIC_CLASS
The the default DEM Annotation Logic class. |
protected static String |
PROVIDER_ATTRIBUTE_NAME
The 'provider' attribute name. |
protected static String |
SERVICE_ATTRIBUTE_NAME
The 'service' attribute name. |
protected static String |
TARGET_ATTRIBUTE_NAME
The 'target' attribute name. |
Constructor Summary | |
---|---|
DEMAnnotationLogic(String annotationFQName,
String annotationName,
boolean isPrimary)
Constructor. |
Method Summary | |
---|---|
void |
addSourceCodeForAnnotation(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
ClassEnhancementContext classEnhancementContext)
This method will define the code to enhance the classes based on the annotations. |
void |
addSourceCodeForAnnotation(ClassEnhancementContext classEnhancementContext,
pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
This method will define the code to enhance the attributes based on the annotations. |
void |
addSourceCodeForAnnotation(ClassEnhancementContext classEnhancementContext,
pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
pt.digitalis.utils.bytecode.holders.MethodHolder method)
This method will define the code to enhance the methods based on the annotations. |
protected void |
addStage(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
ClassEnhancementContext classEnhancementContext,
boolean errorStage,
boolean defaultStage,
String attributeName)
Adds an injected stage to the current stage to enhance. |
protected void |
addView(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
ClassEnhancementContext classEnhancementContext,
boolean errorView,
boolean defaultView,
String attributeName)
Adds an injected view to the current stage to enhance. |
protected boolean |
checkUseWith(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotationToCheck,
pt.digitalis.utils.bytecode.holders.AnnotationHolder thisAnnotation)
Checks if a given annotation can be used with another. |
String |
getAnnotation()
Returns the annotationName. |
protected IAuthorizationManager |
getAuthorizationManager()
|
protected String |
getCodeForExecutionMethod(String signature,
String methodName)
Return the appropriated execute method call injecting a return view if necessary and the appropriated parameters |
protected boolean |
isDEMAnnotation()
|
boolean |
isPrimary()
Returns the value of the primary annotationName flag. |
protected boolean |
isPrimary(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation)
Checks if a given annotation is primary. |
static DEMAnnotationLogic |
makeObject(String annotationLogicClassName,
pt.digitalis.utils.bytecode.holders.ClassHolder annotationClass)
Factory method for DEMAnnotationLogic objects. |
protected Map<String,Object> |
prepareExceptionContext(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Prepares the exception context from the attribute. |
protected Map<String,Object> |
prepareExceptionContext(pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Prepares the exception context from the class. |
protected Map<String,Object> |
prepareExceptionContext(pt.digitalis.utils.bytecode.holders.MethodHolder method)
Prepares the exception context from the method. |
void |
setAnnotation(String newAnnotation)
Sets the annotationName value. |
protected void |
validateDEMConsistency(String annotationName,
pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Validates if the entities referred on the annotation parameters are valid on the DEM context. |
protected void |
validateMessages(pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Validates if a given class message file exists. |
protected boolean |
validateNonPrivate(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Validates that the attribute is non-private. |
protected void |
validatePrimary(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Validates the use of primary annotations on a given attribute. |
protected void |
validatePrimary(pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Validates the use of primary annotations on a given class. |
protected void |
validatePrimary(pt.digitalis.utils.bytecode.holders.MethodHolder method)
Validates the use of primary annotations on a given method. |
protected boolean |
validateScope(String annotationName,
pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Validates the usage scope of attribute annotations. |
protected boolean |
validateSpecificRules(String annotationName,
pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Defines specific rules for applying the annotationName on a given attribute. |
protected boolean |
validateSpecificRules(String annotationName,
pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Defines specific rules for applying the annotationName on a given class. |
protected boolean |
validateSpecificRules(String annotationName,
pt.digitalis.utils.bytecode.holders.MethodHolder method)
Defines specific rules for applying the annotationName on a given method. |
void |
validateUsage(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
Validates the use of the annotation on a given attribute. |
void |
validateUsage(pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
Validates the use of the annotation on a given class. |
void |
validateUsage(pt.digitalis.utils.bytecode.holders.MethodHolder method)
Validates the use of the annotation on a given method. |
protected void |
validateViewExistence(String attributeName,
String className,
Map<String,pt.digitalis.utils.bytecode.holders.AnnotationHolder> annotations)
Checks if the received set of annotations contains the |
protected void |
warnOfEnityMisuseOnClass(String className,
String entityName)
Warns of an entity misuse on a given class. |
protected boolean |
yieldsTo(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation,
String yieldToAnnotationName)
Checks if a given primary annotation has the 'yieldTo' member value and if it contains a given annotation name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String APPLICATION_ATTRIBUTE_NAME
public static final String DEFAULT_DEM_ANNOTATION_LOGIC_CLASS
protected static final String PROVIDER_ATTRIBUTE_NAME
protected static final String SERVICE_ATTRIBUTE_NAME
protected static final String TARGET_ATTRIBUTE_NAME
Constructor Detail |
---|
public DEMAnnotationLogic(String annotationFQName, String annotationName, boolean isPrimary)
annotationFQName
- the annotation fully qualified nameannotationName
- the annotation simple nameisPrimary
- T if annotation is primary, F otherwiseMethod Detail |
---|
public static DEMAnnotationLogic makeObject(String annotationLogicClassName, pt.digitalis.utils.bytecode.holders.ClassHolder annotationClass) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, pt.digitalis.utils.inspection.exception.AuxiliaryOperationException
pt.digitalis.dif.codegen.util.DEMLoaderHelper#getAnnotationLogicMap()
which generates a map
whose values are DEMAnnotationLogic subclasses. These values can't be inserted on the map if they belong to a
runtime determined type.
annotationLogicClassName
- The name of the annotationName logic classannotationClass
- The argument annotationName
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any needed class cannot be found
pt.digitalis.utils.inspection.exception.AuxiliaryOperationException
- if any illegal operation or instantiation exceptions are raisedpublic void addSourceCodeForAnnotation(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, ClassEnhancementContext classEnhancementContext) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, DIFCodeGenerationException
classEnhancementContext
- the class enhancement contextannotation
- the annotation used to define the source code needed for enhancement
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if annotation members can't be accessed
DIFCodeGenerationException
public void addSourceCodeForAnnotation(ClassEnhancementContext classEnhancementContext, pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, pt.digitalis.utils.bytecode.holders.AttributeHolder attribute) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, DIFCodeGenerationException
classEnhancementContext
- the class enhancement contextannotation
- the annotation used to define the source code needed for enhancementattribute
- the attribute to be enhanced (to make the context available to the source building process)
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if annotation members can't be accessed
DIFCodeGenerationException
public void addSourceCodeForAnnotation(ClassEnhancementContext classEnhancementContext, pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, pt.digitalis.utils.bytecode.holders.MethodHolder method) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, DIFCodeGenerationException
classEnhancementContext
- the class enhancement contextannotation
- the annotation used to define the source code needed for enhancementmethod
- the method to be enhanced (to make the context available to the source building process)
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if annotation members can't be accessed
DIFCodeGenerationException
protected void addStage(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, ClassEnhancementContext classEnhancementContext, boolean errorStage, boolean defaultStage, String attributeName) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, DIFCodeGenerationException
annotation
- the annotation that declared the stageclassEnhancementContext
- the class enhancement contexterrorStage
- if the stage to add is an error stagedefaultStage
- if the current stage is the default stageattributeName
- the name of the attribute to assign the new stage to
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if the annotation cannot be read
DIFCodeGenerationException
protected void addView(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, ClassEnhancementContext classEnhancementContext, boolean errorView, boolean defaultView, String attributeName) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException, DIFCodeGenerationException
annotation
- the annotation that declared the stageclassEnhancementContext
- the class enhancement contexterrorView
- if the view to add is an error viewdefaultView
- if the view to add is the default stage viewattributeName
- the name of the attribute to assign the new view to
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if the annotation cannot be read
DIFCodeGenerationException
protected boolean checkUseWith(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotationToCheck, pt.digitalis.utils.bytecode.holders.AnnotationHolder thisAnnotation) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
annotationToCheck
- the annotation to checkthisAnnotation
- the annotation to validate against
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for validation could not be found.public String getAnnotation()
protected IAuthorizationManager getAuthorizationManager()
protected String getCodeForExecutionMethod(String signature, String methodName)
signature
- the method to call signaturemethodName
- the method name to call
protected boolean isDEMAnnotation()
public final boolean isPrimary()
protected boolean isPrimary(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
annotation
- the annotation to check
@Primary
, F otherwise.
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if meta-annotations can't be foundprotected Map<String,Object> prepareExceptionContext(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
attribute
- the class object
protected Map<String,Object> prepareExceptionContext(pt.digitalis.utils.bytecode.holders.ClassHolder clazz)
clazz
- the class object
protected Map<String,Object> prepareExceptionContext(pt.digitalis.utils.bytecode.holders.MethodHolder method)
method
- the class object
public void setAnnotation(String newAnnotation)
newAnnotation
- the new annotationName valueprotected void validateDEMConsistency(String annotationName, pt.digitalis.utils.bytecode.holders.ClassHolder clazz) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
annotationName
- the name of the annotation to validateclazz
- the class holder
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundprotected void validateMessages(pt.digitalis.utils.bytecode.holders.ClassHolder clazz) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
clazz
- the class to validate the messages *
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundprotected boolean validateNonPrivate(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute)
attribute
- the attribute to validate
protected void validatePrimary(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
attribute
- the attribute to search for primary annotations
AnnotationMisuseException
- if an annotation is misused
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for validation could not be found.protected void validatePrimary(pt.digitalis.utils.bytecode.holders.ClassHolder clazz) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
clazz
- the class to search for primary annotations
AnnotationMisuseException
- if an annotation is misused
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for validation could not be found.protected void validatePrimary(pt.digitalis.utils.bytecode.holders.MethodHolder method) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
method
- the method to search for primary annotations
AnnotationMisuseException
- if an annotation is misused
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for validation could not be found.protected boolean validateScope(String annotationName, pt.digitalis.utils.bytecode.holders.AttributeHolder attribute) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
annotationName
- the name of the annotation to validateattribute
- the attribute to validate
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundprotected boolean validateSpecificRules(String annotationName, pt.digitalis.utils.bytecode.holders.AttributeHolder attribute) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
attribute
- the annotated attributeannotationName
- the annotationName
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
protected boolean validateSpecificRules(String annotationName, pt.digitalis.utils.bytecode.holders.ClassHolder clazz) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
annotationName
- the annotationNameclazz
- the annotated class
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any needed resource for validation is not foundprotected boolean validateSpecificRules(String annotationName, pt.digitalis.utils.bytecode.holders.MethodHolder method) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
method
- the annotated methodannotationName
- the annotationName
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
public final void validateUsage(pt.digitalis.utils.bytecode.holders.AttributeHolder attribute) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
attribute
- the attribute on which the annotationName is used
AnnotationMisuseException
- if an inappropriate annotation usage was made
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundpublic final void validateUsage(pt.digitalis.utils.bytecode.holders.ClassHolder clazz) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
clazz
- the class on which the annotation is used
AnnotationMisuseException
- if an inappropriate annotation usage was made
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundpublic final void validateUsage(pt.digitalis.utils.bytecode.holders.MethodHolder method) throws AnnotationMisuseException, pt.digitalis.utils.inspection.exception.ResourceNotFoundException
method
- the method on which the annotation is used
AnnotationMisuseException
- if an inappropriate annotation usage was made
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundprotected void validateViewExistence(String attributeName, String className, Map<String,pt.digitalis.utils.bytecode.holders.AnnotationHolder> annotations) throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException
attributeName
- the name of the annotated attribute if it existsclassName
- the name of the annotated class or the attribute's class nameannotations
- the annotation set to validate
pt.digitalis.utils.inspection.exception.ResourceNotFoundException
- if any resource needed for the validation can't be foundprotected void warnOfEnityMisuseOnClass(String className, String entityName)
className
- the name of the class where the reference is being madeentityName
- the name of the referred entityprotected boolean yieldsTo(pt.digitalis.utils.bytecode.holders.AnnotationHolder annotation, String yieldToAnnotationName)
annotation
- the primary annotation to checkyieldToAnnotationName
- the name on the 'yieldTo' value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |