pt.digitalis.dif.codegen.util
Class ClassEnhancementContext

java.lang.Object
  extended by pt.digitalis.dif.codegen.util.ClassEnhancementContext

public class ClassEnhancementContext
extends Object

Holds the information needed to enhance a set of classes.

Author:
Rodrigo Gon�alves rgoncalves@digitalis.pt
Created on:
2007/12/10

Constructor Summary
ClassEnhancementContext(pt.digitalis.utils.bytecode.holders.ClassHolder classHolder)
          Builds a class enhancement context from a class holder.
ClassEnhancementContext(String originalClassID)
          Builds a class enhancement context from a class ID.
 
Method Summary
 void addEnhancement(String className, ClassMethodEnhancement enhancement)
          Adds an enhancement to a given class method.
 void addEnhancement(String methodName, String enhancement)
          Adds an enhancement to a given class method.
 void addEnhancement(String className, String methodName, String enhancement)
          Adds an enhancement to a given class method.
 void addEnhancementTerminatorCode(String className, String methodName, String terminator)
          Adds an enhancement to a given class method.
 void commitEnhancements()
          Commits all the enhancements to a class file and returns the class holder object.
 boolean containsEnhancement(String methodName)
          Inspects the enhancement map to see of the given method has been inserted for enhancement
 boolean containsEnhancement(String className, String methodName)
          Inspects the enhancement map to see of the given method has been inserted for enhancement
 Map<String,ClassEnhancements> getClassEnhancements()
          Returns the class enhancements map.
 pt.digitalis.utils.bytecode.holders.ClassHolder getEntityClass()
          Return the enriched entity class holder.
 String getOriginalClassName()
          Returns the original class name.
 pt.digitalis.utils.bytecode.holders.ClassHolder getOriginalClassObject()
          Return the original POJO class holder.
 void setEnhancements(String className, String methodName, String enhancement)
          Adds an enhancement to a given class method.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassEnhancementContext

public ClassEnhancementContext(pt.digitalis.utils.bytecode.holders.ClassHolder classHolder)
                        throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException,
                               pt.digitalis.utils.bytecode.exceptions.CodeGenerationException
Builds a class enhancement context from a class holder.

Parameters:
classHolder - the class holder for the class to enhance
Throws:
pt.digitalis.utils.inspection.exception.ResourceNotFoundException - if the class annotations can't be read
pt.digitalis.utils.bytecode.exceptions.CodeGenerationException - if the passed class holder isn't a valid DEM entity or the class holder's target semantics is incorrect

ClassEnhancementContext

public ClassEnhancementContext(String originalClassID)
                        throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException,
                               pt.digitalis.utils.bytecode.exceptions.CodeGenerationException
Builds a class enhancement context from a class ID.

Parameters:
originalClassID - the original annotated class
Throws:
pt.digitalis.utils.inspection.exception.ResourceNotFoundException - if the class with the given id can't be found
pt.digitalis.utils.bytecode.exceptions.CodeGenerationException - if the code can't be compiled
Method Detail

addEnhancement

public void addEnhancement(String className,
                           ClassMethodEnhancement enhancement)
                    throws DIFCodeGenerationException
Adds an enhancement to a given class method.

Parameters:
className - the name of the class to add the enhancement to
enhancement - the enhancement to add
Throws:
DIFCodeGenerationException

addEnhancement

public void addEnhancement(String methodName,
                           String enhancement)
                    throws DIFCodeGenerationException
Adds an enhancement to a given class method. This method should be used for non-stage classes only since it does provide means for specifying what class is to be enhanced

Parameters:
methodName - the name of the method to add the enhancement to
enhancement - the enhancement to add
Throws:
DIFCodeGenerationException

addEnhancement

public void addEnhancement(String className,
                           String methodName,
                           String enhancement)
                    throws DIFCodeGenerationException
Adds an enhancement to a given class method.

Parameters:
className - the name of the class to add the enhancement to
methodName - the name of the method to add the enhancement to
enhancement - the enhancement to add
Throws:
DIFCodeGenerationException

addEnhancementTerminatorCode

public void addEnhancementTerminatorCode(String className,
                                         String methodName,
                                         String terminator)
                                  throws DIFCodeGenerationException
Adds an enhancement to a given class method.

Parameters:
className - the name of the class to add the enhancement to
methodName - the name of the method to add the enhancement to
terminator - the finalize code for the method
Throws:
DIFCodeGenerationException

commitEnhancements

public void commitEnhancements()
                        throws pt.digitalis.utils.inspection.exception.ResourceNotFoundException,
                               pt.digitalis.utils.bytecode.exceptions.CodeGenerationException
Commits all the enhancements to a class file and returns the class holder object.

Throws:
pt.digitalis.utils.inspection.exception.ResourceNotFoundException - if the class can't be found
pt.digitalis.utils.bytecode.exceptions.CodeGenerationException - if the code can't be compiled

containsEnhancement

public boolean containsEnhancement(String methodName)
Inspects the enhancement map to see of the given method has been inserted for enhancement

Parameters:
methodName - the name of the method to add the enhancement to
Returns:
T if the method is present

containsEnhancement

public boolean containsEnhancement(String className,
                                   String methodName)
Inspects the enhancement map to see of the given method has been inserted for enhancement

Parameters:
className - the name of the class to add the enhancement to
methodName - the name of the method to add the enhancement to
Returns:
T if the method is present

getClassEnhancements

public Map<String,ClassEnhancements> getClassEnhancements()
Returns the class enhancements map.

Returns:
the class enhancements map.

getEntityClass

public pt.digitalis.utils.bytecode.holders.ClassHolder getEntityClass()
Return the enriched entity class holder.

Returns:
the class holder

getOriginalClassObject

public pt.digitalis.utils.bytecode.holders.ClassHolder getOriginalClassObject()
Return the original POJO class holder.

Returns:
the class holder

getOriginalClassName

public String getOriginalClassName()
Returns the original class name.

Returns:
the original class name

setEnhancements

public void setEnhancements(String className,
                            String methodName,
                            String enhancement)
Adds an enhancement to a given class method.

Parameters:
className - the name of the class to add the enhancement to
methodName - the name of the method to add the enhancement to
enhancement - the enhancement to add

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.