org.jboss.aop.instrument
Class Instrumentor

java.lang.Object
  extended byorg.jboss.aop.instrument.Instrumentor
Direct Known Subclasses:
ClassicInstrumentor, GeneratedAdvisorInstrumentor

public class Instrumentor
extends Object

Transforms byte code, making a class advisable. Implements command line class instrumentor as well. Reads classes from class path and creates advised versions in specified directory. Usage:

 Instrumentor [dest. directory] [class[ class...]]
 

Version:
$Revision: 1.37.2.3 $ =======, $Revision: 1.37.2.3 $ >>>>>>> 1.40
Author:
Bill Burke, Austin Chau, Bob Lee <<<<<<< Instrumentor.java

Field Summary
static String AOP_PACKAGE
          Package of AOP classes.
static String ASPECT_MANAGER_CLASS_NAME
          Name of helper class.
protected  boolean basicsSet
           
protected  AOPClassPool classPool
           
protected  javassist.CodeConverter converter
           
static String HELPER_CLASS_NAME
          Name of helper class.
static String HELPER_FIELD_NAME
          Helper class's field name.
protected  JoinpointClassifier joinpointClassifier
           
protected  AspectManager manager
           
 
Constructor Summary
protected Instrumentor(AOPClassPool pool, AspectManager manager, JoinpointClassifier joinpointClassifier, DynamicTransformationObserver observer)
          Constructs new instrumentor.
protected Instrumentor(AspectManager manager, JoinpointClassifier joinpointClassifier)
           
 
Method Summary
 boolean applyCallerPointcuts(javassist.CtClass clazz, ClassAdvisor advisor)
           
 void convertProcessedClasses(HotSwapper hotSwapper, javassist.CtClass clazz, Collection fieldReads, Collection fieldWrites, boolean constructor)
          Converts all processed classes to make wrapping of the appropriate joinpoints.
protected  boolean convertReferences(javassist.CtClass clazz)
          Find all classes that this class references.
 javassist.CtClass forName(String name)
          Gets a class by its name.
static List getAdvisableFields(javassist.CtClass clazz)
          Gets sorted collection of advisable methods.
 javassist.ClassPool getClassPool()
           
 List getConstructors(javassist.CtClass clazz)
           
 void interceptorChainsUpdated(Collection joinpointUpdates, HotSwapper hotSwapper)
          Notifies the Instrumentor that some joinpoint status were updated.
static boolean isAdvisable(javassist.CtField field)
          Is the method advisable?
static boolean isAdvisable(javassist.CtMethod method)
          Is the method advisable?
 boolean isAdvised(javassist.CtClass clazz)
           
 boolean isTransformable(javassist.CtClass clazz)
           
 void setupBasics(javassist.CtClass clazz)
           
 boolean transform(javassist.CtClass clazz, ClassAdvisor advisor)
          Makes class advisable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AOP_PACKAGE

public static final String AOP_PACKAGE
Package of AOP classes.


HELPER_CLASS_NAME

public static final String HELPER_CLASS_NAME
Name of helper class.


ASPECT_MANAGER_CLASS_NAME

public static final String ASPECT_MANAGER_CLASS_NAME
Name of helper class.


HELPER_FIELD_NAME

public static final String HELPER_FIELD_NAME
Helper class's field name.

See Also:
Constant Field Values

classPool

protected AOPClassPool classPool

basicsSet

protected boolean basicsSet

converter

protected javassist.CodeConverter converter

manager

protected AspectManager manager

joinpointClassifier

protected JoinpointClassifier joinpointClassifier
Constructor Detail

Instrumentor

protected Instrumentor(AOPClassPool pool,
                       AspectManager manager,
                       JoinpointClassifier joinpointClassifier,
                       DynamicTransformationObserver observer)
Constructs new instrumentor.

Parameters:
observer - need be notified of every joinpoint wrapping caused only by pointcuts dynamicaly added.

Instrumentor

protected Instrumentor(AspectManager manager,
                       JoinpointClassifier joinpointClassifier)
Method Detail

getClassPool

public javassist.ClassPool getClassPool()

isAdvisable

public static boolean isAdvisable(javassist.CtMethod method)
Is the method advisable?


isAdvisable

public static boolean isAdvisable(javassist.CtField field)
Is the method advisable?


isAdvised

public boolean isAdvised(javassist.CtClass clazz)
                  throws javassist.NotFoundException
Throws:
javassist.NotFoundException

isTransformable

public boolean isTransformable(javassist.CtClass clazz)
                        throws javassist.NotFoundException
Throws:
javassist.NotFoundException

applyCallerPointcuts

public boolean applyCallerPointcuts(javassist.CtClass clazz,
                                    ClassAdvisor advisor)
                             throws javassist.CannotCompileException
Throws:
javassist.CannotCompileException

convertReferences

protected boolean convertReferences(javassist.CtClass clazz)
                             throws Exception
Find all classes that this class references. If any of those classes are advised and have field and/or constructor interception, do instrumentation on this class so that those fields and constructors are instrumented

Throws:
Exception

transform

public boolean transform(javassist.CtClass clazz,
                         ClassAdvisor advisor)
Makes class advisable.


getConstructors

public List getConstructors(javassist.CtClass clazz)

getAdvisableFields

public static List getAdvisableFields(javassist.CtClass clazz)
                               throws javassist.NotFoundException
Gets sorted collection of advisable methods.

Throws:
javassist.NotFoundException

forName

public javassist.CtClass forName(String name)
                          throws javassist.NotFoundException
Gets a class by its name.

Throws:
javassist.NotFoundException

setupBasics

public void setupBasics(javassist.CtClass clazz)
                 throws javassist.CannotCompileException,
                        javassist.NotFoundException
Throws:
javassist.CannotCompileException
javassist.NotFoundException

interceptorChainsUpdated

public void interceptorChainsUpdated(Collection joinpointUpdates,
                                     HotSwapper hotSwapper)
Notifies the Instrumentor that some joinpoint status were updated. This method hot swaps the code of afected classes.

Parameters:
joinpointUpdates - a collection of org.jboss.aop.instrument.JoinpointStatusUpdate.
hotSwapper - object capable of hot swapping classes.

convertProcessedClasses

public void convertProcessedClasses(HotSwapper hotSwapper,
                                    javassist.CtClass clazz,
                                    Collection fieldReads,
                                    Collection fieldWrites,
                                    boolean constructor)
Converts all processed classes to make wrapping of the appropriate joinpoints. This method must be called if some dynamic transformation ocurred (i. e. a class has just been loaded and one or more of its joinpoints were wrapped due only to bindings added dynamicaly; in this case, the previously loaded classes may not call the wrappers of this joinpoints, and need to be instrumented).

Parameters:
clazz - the clazz whose transformation involved dynamic wrapping.
fieldReads - collection of fields whose read joinpoit was dynamicaly wrapped.
fieldWrites - collection of fields whose read joinpoit was dynamicaly wrapped.
constructor - true if the clazz constructors were dynamicaly wrapped.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.