org.jboss.aop.instrument
Class ConstructorExecutionTransformer

java.lang.Object
  extended by org.jboss.aop.instrument.ConstructorExecutionTransformer
Direct Known Subclasses:
GeneratedAdvisorConstructorExecutionTransformer, NonOptimizedConstructorExecutionTransformer, OptimizedConstructorExecutionTransformer

public abstract class ConstructorExecutionTransformer
extends Object

Comment

Version:
$Revision: 78458 $
Author:
Bill Burke

Nested Class Summary
protected  class ConstructorExecutionTransformer.ConstructorTransformation
           
 
Field Summary
protected  Codifier codifier
           
protected static String CONSTRUCTOR_INFO_CLASS_NAME
           
protected static int CONSTRUCTOR_STATUS
           
protected  Instrumentor instrumentor
           
 
Constructor Summary
protected ConstructorExecutionTransformer(Instrumentor instrumentor)
           
 
Method Summary
protected  String addConstructorInfoField(int modifiers, javassist.CtClass addTo, String infoName)
          Adds a ConstructorInfo field to the passed in class
protected  String addConstructorInfoField(int modifiers, javassist.CtClass addTo, String infoName, javassist.CtField.Initializer init)
          Adds a ConstructorInfo field to the passed in class
protected  boolean addInfoAsWeakReference()
           
protected  void buildConstructorWrappers(javassist.CtClass clazz, ClassAdvisor advisor)
           
 void codeConverted()
          Notifies this transformer that the code conversion is done.
static String constructorFactory(String className)
           
protected static String constructorInfoFromWeakReference(String localName, String ctorInfoName)
           
protected abstract  void createWrapper(ConstructorExecutionTransformer.ConstructorTransformation trans)
           
protected  void generateConstructorInfoField(javassist.CtClass clazz, javassist.CtConstructor constructor, int index)
           
static String getConstructorInfoFieldName(String classname, int index)
           
protected  Instrumentor getInstrumentor()
           
protected  WrapperTransformer getWrapper()
           
protected  javassist.CtMethod getWrapperMethod(javassist.CtConstructor constructor)
           
protected  void initialiseWrapper(int mod, javassist.CtConstructor constructor, int index)
           
static boolean isAdvisableConstructor(javassist.CtConstructor con, ClassAdvisor advisor)
           
protected  boolean isAnyConstructorAdvised(javassist.CtClass clazz, ClassAdvisor advisor)
          Returns true if there is at least one constructor that is classified as WRAPPED.
protected  boolean markInfoAsSynthetic()
           
 boolean replaceConstructorAccess(ClassAdvisor sourceAdvisor, javassist.CtClass source)
           
protected  void setEmptyWrapperCode(javassist.CtConstructor constructor)
          Sets the wrapper method code as an empty wrapper, i.e., a wrapper that simply invokes the constructor.
protected  void setEmptyWrapperCodeLater(javassist.CtConstructor constructor)
          Sets the wrapper method code as an empty wrapper, i.e., a wrapper that simply invokes the constructor.
protected  void setTemporaryWrapperCode(javassist.CtClass type, javassist.CtMethod wrapperMethod)
          Sets a temporary wrapper method code.
 boolean transform(javassist.CtClass clazz, ClassAdvisor classAdvisor)
          Transforms the constructor executions of this class according to the pointcuts registered in AspectManager.
 void unwrap(javassist.CtClass clazz, Collection<Integer> constructorIndexes)
          Unwraps the constructor executions contained in constructorIndexes.
 void wrap(javassist.CtClass clazz, Collection<Integer> constructorIndexes)
          Wraps the constructor executions contained in constructorIndexes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRUCTOR_INFO_CLASS_NAME

protected static final String CONSTRUCTOR_INFO_CLASS_NAME
See Also:
Constant Field Values

instrumentor

protected Instrumentor instrumentor

codifier

protected Codifier codifier

CONSTRUCTOR_STATUS

protected static final int CONSTRUCTOR_STATUS
See Also:
Constant Field Values
Constructor Detail

ConstructorExecutionTransformer

protected ConstructorExecutionTransformer(Instrumentor instrumentor)
Method Detail

getInstrumentor

protected Instrumentor getInstrumentor()

getWrapper

protected WrapperTransformer getWrapper()

constructorFactory

public static String constructorFactory(String className)

addConstructorInfoField

protected String addConstructorInfoField(int modifiers,
                                         javassist.CtClass addTo,
                                         String infoName)
                                  throws javassist.NotFoundException,
                                         javassist.CannotCompileException
Adds a ConstructorInfo field to the passed in class

Throws:
javassist.NotFoundException
javassist.CannotCompileException

addConstructorInfoField

protected String addConstructorInfoField(int modifiers,
                                         javassist.CtClass addTo,
                                         String infoName,
                                         javassist.CtField.Initializer init)
                                  throws javassist.NotFoundException,
                                         javassist.CannotCompileException
Adds a ConstructorInfo field to the passed in class

Throws:
javassist.NotFoundException
javassist.CannotCompileException

addInfoAsWeakReference

protected boolean addInfoAsWeakReference()

markInfoAsSynthetic

protected boolean markInfoAsSynthetic()

getConstructorInfoFieldName

public static String getConstructorInfoFieldName(String classname,
                                                 int index)

constructorInfoFromWeakReference

protected static String constructorInfoFromWeakReference(String localName,
                                                         String ctorInfoName)

transform

public boolean transform(javassist.CtClass clazz,
                         ClassAdvisor classAdvisor)
                  throws Exception
Transforms the constructor executions of this class according to the pointcuts registered in AspectManager.

Parameters:
clazz - the clazz to be transformed.
classAdvisor - the advisor associated to clazz.
Returns:
true is clazz is instrumented.
Throws:
Exception

wrap

public void wrap(javassist.CtClass clazz,
                 Collection<Integer> constructorIndexes)
          throws Exception
Wraps the constructor executions contained in constructorIndexes.

Parameters:
clazz - the class being instrumented.
constructorIndexes - a collection of java.lang.Integer indentifying the constructors to be wrapped.
Throws:
Exception

unwrap

public void unwrap(javassist.CtClass clazz,
                   Collection<Integer> constructorIndexes)
            throws javassist.NotFoundException
Unwraps the constructor executions contained in constructorIndexes.

Parameters:
clazz - the class being instrumented.
constructorIndexes - a collection of java.lang.Integer indentifying the constructors to be unwrapped.
Throws:
javassist.NotFoundException

codeConverted

public void codeConverted()
                   throws javassist.CannotCompileException
Notifies this transformer that the code conversion is done.

Throws:
javassist.CannotCompileException

replaceConstructorAccess

public boolean replaceConstructorAccess(ClassAdvisor sourceAdvisor,
                                        javassist.CtClass source)
                                 throws javassist.NotFoundException
Throws:
javassist.NotFoundException

buildConstructorWrappers

protected void buildConstructorWrappers(javassist.CtClass clazz,
                                        ClassAdvisor advisor)
                                 throws Exception
Throws:
Exception

generateConstructorInfoField

protected void generateConstructorInfoField(javassist.CtClass clazz,
                                            javassist.CtConstructor constructor,
                                            int index)
                                     throws javassist.CannotCompileException,
                                            javassist.NotFoundException
Throws:
javassist.CannotCompileException
javassist.NotFoundException

setTemporaryWrapperCode

protected void setTemporaryWrapperCode(javassist.CtClass type,
                                       javassist.CtMethod wrapperMethod)
Sets a temporary wrapper method code. Later, the wrapper method body must be replaced by it's definitive implementation.

Parameters:
type -
wrapperMethod -

setEmptyWrapperCode

protected void setEmptyWrapperCode(javassist.CtConstructor constructor)
                            throws javassist.NotFoundException
Sets the wrapper method code as an empty wrapper, i.e., a wrapper that simply invokes the constructor.

Parameters:
type - the class being instrumented.
wrapperMethod - the wrapper method.
Throws:
javassist.NotFoundException

setEmptyWrapperCodeLater

protected void setEmptyWrapperCodeLater(javassist.CtConstructor constructor)
                                 throws javassist.NotFoundException
Sets the wrapper method code as an empty wrapper, i.e., a wrapper that simply invokes the constructor.

Parameters:
type - the class being instrumented.
wrapperMethod - the wrapper method.
Throws:
javassist.NotFoundException

isAnyConstructorAdvised

protected boolean isAnyConstructorAdvised(javassist.CtClass clazz,
                                          ClassAdvisor advisor)
                                   throws javassist.NotFoundException
Returns true if there is at least one constructor that is classified as WRAPPED.

Parameters:
clazz - the clazz whose constructors will be classified.
advisor - the advisor associated with clazz
Returns:
true only if one or more clazz constructors are classified as WRAPPED.
Throws:
javassist.NotFoundException

isAdvisableConstructor

public static boolean isAdvisableConstructor(javassist.CtConstructor con,
                                             ClassAdvisor advisor)
                                      throws javassist.NotFoundException
Throws:
javassist.NotFoundException

createWrapper

protected abstract void createWrapper(ConstructorExecutionTransformer.ConstructorTransformation trans)
                               throws javassist.CannotCompileException,
                                      javassist.NotFoundException
Throws:
javassist.CannotCompileException
javassist.NotFoundException

initialiseWrapper

protected void initialiseWrapper(int mod,
                                 javassist.CtConstructor constructor,
                                 int index)
                          throws javassist.NotFoundException,
                                 javassist.CannotCompileException
Throws:
javassist.NotFoundException
javassist.CannotCompileException

getWrapperMethod

protected javassist.CtMethod getWrapperMethod(javassist.CtConstructor constructor)
                                       throws javassist.NotFoundException
Throws:
javassist.NotFoundException


Copyright © 2008 JBoss, a division of Red Hat, Inc.. All Rights Reserved.