org.codehaus.aspectwerkz.attribdef
Class AttribDefSystem

java.lang.Object
  extended byorg.codehaus.aspectwerkz.attribdef.AttribDefSystem
All Implemented Interfaces:
System

public final class AttribDefSystem
extends java.lang.Object
implements System

Manages the aspects in the AspectWerkz system.

Handles the initialization and configuration of the system.

Stores and indexes the aspects defined in the system.

Stores and indexes the advised methods.

Stores and indexes the introduced methods.

Author:
Jonas Bonér, Alexandre Vasseur

Field Summary
 
Fields inherited from interface org.codehaus.aspectwerkz.System
DEFAULT_SYSTEM, START_REMOTE_PROXY_SERVER
 
Constructor Summary
AttribDefSystem(java.lang.String uuid, AspectWerkzDefinition definition)
          Should NEVER be invoked by the user.
 
Method Summary
 void createAspect(java.lang.String name, java.lang.String className, int deploymentModel, java.lang.ClassLoader loader)
          Creates and registers new aspect at runtime.
 void enteringControlFlow(ClassNameMethodMetaDataTuple metaData)
          Registers entering of a control flow join point.
 void exitingControlFlow(ClassNameMethodMetaDataTuple metaData)
          Registers exiting from a control flow join point.
 IndexTuple getAdviceIndexFor(java.lang.String name)
          Returns the index for a specific name to advice mapping.
 Aspect getAspect(int index)
          Retrieves a specific aspect based on index.
 Aspect getAspect(java.lang.String name)
          Returns the aspect for a specific name.
 int getAspectIndexFor(java.lang.String name)
          Returns the index for a specific name to aspect mapping.
 AspectMetaData getAspectMetaData(java.lang.String name)
          Returns the aspect meta-data for the name specified.
 Aspect[] getAspects()
          Returns an array with all the aspects.
 java.util.Collection getAspectsMetaData()
          Returns a list with all the aspects meta-data.
 java.util.List getCallPointcuts(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the call pointcut list for the class and method specified.
 java.util.List getCFlowExpressions(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns all the cflow call expression for the given metadata (callee side)
 java.util.List getCFlowPointcuts(java.lang.String className, MethodMetaData methodMetaData)
          ALEX RM Returns a list with the cflow pointcuts that affects the join point with the class name and the method name specified.
 java.util.List getExecutionPointcuts(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the execution pointcut list for the class and method specified.
 java.util.List getGetPointcuts(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Returns the get pointcut list for the class and field specified.
 java.lang.reflect.Method getMethod(java.lang.Class klass, int index)
          Returns a specific method by the class and the method index.
 Mixin getMixin(int index)
          Retrieves a specific mixin based on its index.
 Mixin getMixin(java.lang.String name)
          Returns the mixin implementation for a specific name.
 java.util.List getSetPointcuts(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Returns the set pointcut list for the class and field specified.
 java.util.List getThrowsPointcuts(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the throws pointcut list for the class and method specified.
 boolean hasAspect(java.lang.String name)
          Checks if a specific class has an aspect defined.
 void initialize()
          Initializes the system.
 boolean isAttribDef()
          Checks if the definition is of type attribute definition.
 boolean isInControlFlowOf(CompiledPatternTuple patternTuple)
          Checks if we are in the control flow of a specific cflow pointcut.
 boolean isInControlFlowOf(Expression cflowExpression)
          Checks if we are in the control flow of a specific cflow pointcut.
 boolean isXmlDef()
          Checks if the definition is of type XML definition.
 void register(Aspect aspect, AspectMetaData aspectMetaData)
          Registers a new aspect.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttribDefSystem

public AttribDefSystem(java.lang.String uuid,
                       AspectWerkzDefinition definition)
Should NEVER be invoked by the user. Use SystemLoader.getSystem(uuid) to retrieve the system.

Creates a new AspectWerkz system instance.

Sets the UUID for the system.

Parameters:
uuid - the UUID for the system
definition - the definition for the system
Method Detail

initialize

public void initialize()
Initializes the system.

Specified by:
initialize in interface System

isAttribDef

public boolean isAttribDef()
Checks if the definition is of type attribute definition.

Specified by:
isAttribDef in interface System
Returns:
returns true for this system

isXmlDef

public boolean isXmlDef()
Checks if the definition is of type XML definition.

Specified by:
isXmlDef in interface System
Returns:
returns false for this system

register

public void register(Aspect aspect,
                     AspectMetaData aspectMetaData)
Registers a new aspect.

Parameters:
aspect - the aspect to register
aspectMetaData - the aspect meta-data

createAspect

public void createAspect(java.lang.String name,
                         java.lang.String className,
                         int deploymentModel,
                         java.lang.ClassLoader loader)
Creates and registers new aspect at runtime.

Parameters:
name - the name of the aspect
className - the class name of the aspect
deploymentModel - the deployment model for the aspect (constants in the DeploymemtModel class, e.g. f.e. DeploymentModel.PER_JVM)
loader - an optional class loader (if null it uses the context classloader)

enteringControlFlow

public void enteringControlFlow(ClassNameMethodMetaDataTuple metaData)
Registers entering of a control flow join point.

Specified by:
enteringControlFlow in interface System
Parameters:
metaData - the classname:methodMetaData metaData

exitingControlFlow

public void exitingControlFlow(ClassNameMethodMetaDataTuple metaData)
Registers exiting from a control flow join point.

Specified by:
exitingControlFlow in interface System
Parameters:
metaData - the classname:methodMetaData metaData

isInControlFlowOf

public boolean isInControlFlowOf(Expression cflowExpression)
Description copied from interface: System
Checks if we are in the control flow of a specific cflow pointcut.

Specified by:
isInControlFlowOf in interface System
Parameters:
cflowExpression - the compiled tuple with the class pattern and the method pattern of the cflow pointcut
Returns:
boolean

isInControlFlowOf

public boolean isInControlFlowOf(CompiledPatternTuple patternTuple)
Checks if we are in the control flow of a specific cflow pointcut.

Parameters:
patternTuple - the compiled tuple with the class pattern and the method pattern of the cflow pointcut
Returns:
boolean

getAspect

public Aspect getAspect(int index)
Retrieves a specific aspect based on index.

Parameters:
index - the index of the aspect
Returns:
the aspect

getAspect

public Aspect getAspect(java.lang.String name)
Returns the aspect for a specific name.

Parameters:
name - the name of the aspect
Returns:
the the aspect

getMixin

public Mixin getMixin(int index)
Retrieves a specific mixin based on its index.

Specified by:
getMixin in interface System
Parameters:
index - the index of the introduction (aspect in this case)
Returns:
the the mixin (aspect in this case)

getMixin

public Mixin getMixin(java.lang.String name)
Returns the mixin implementation for a specific name.

Specified by:
getMixin in interface System
Parameters:
name - the name of the introduction (aspect in this case)
Returns:
the the mixin (aspect in this case)

getAspectIndexFor

public int getAspectIndexFor(java.lang.String name)
Returns the index for a specific name to aspect mapping.

Parameters:
name - the name of the aspect
Returns:
the index of the aspect

getAdviceIndexFor

public IndexTuple getAdviceIndexFor(java.lang.String name)
Returns the index for a specific name to advice mapping.

Specified by:
getAdviceIndexFor in interface System
Parameters:
name - the name of the advice
Returns:
the index of the advice

getAspectMetaData

public AspectMetaData getAspectMetaData(java.lang.String name)
Returns the aspect meta-data for the name specified.

Specified by:
getAspectMetaData in interface System
Parameters:
name - the name of the aspect
Returns:
the aspect

getAspectsMetaData

public java.util.Collection getAspectsMetaData()
Returns a list with all the aspects meta-data.

Specified by:
getAspectsMetaData in interface System
Returns:
the aspects

getAspects

public Aspect[] getAspects()
Returns an array with all the aspects.

Returns:
the aspects

getExecutionPointcuts

public java.util.List getExecutionPointcuts(ClassMetaData classMetaData,
                                            MethodMetaData methodMetaData)
Returns the execution pointcut list for the class and method specified.

Caches the list, needed since the actual method call is expensive and is made each time a new instance of an advised class is created.

Specified by:
getExecutionPointcuts in interface System
Parameters:
classMetaData - the meta-data for the class
methodMetaData - meta-data for the method
Returns:
the pointcuts for this join point

getGetPointcuts

public java.util.List getGetPointcuts(ClassMetaData classMetaData,
                                      FieldMetaData fieldMetaData)
Returns the get pointcut list for the class and field specified.

Caches the list, needed since the actual method call is expensive and is made each time a new instance of an advised class is created.

Specified by:
getGetPointcuts in interface System
Parameters:
classMetaData - the meta-data for the class
fieldMetaData - meta-data for the method
Returns:
the pointcuts for this join point

getSetPointcuts

public java.util.List getSetPointcuts(ClassMetaData classMetaData,
                                      FieldMetaData fieldMetaData)
Returns the set pointcut list for the class and field specified.

Caches the list, needed since the actual method call is expensive and is made each time a new instance of an advised class is created.

Specified by:
getSetPointcuts in interface System
Parameters:
classMetaData - the meta-data for the class
fieldMetaData - meta-data for the method
Returns:
the pointcuts for this join point

getThrowsPointcuts

public java.util.List getThrowsPointcuts(ClassMetaData classMetaData,
                                         MethodMetaData methodMetaData)
Returns the throws pointcut list for the class and method specified.

Caches the list, needed since the actual method call is expensive and is made each time a new instance of an advised class is created.

Specified by:
getThrowsPointcuts in interface System
Parameters:
classMetaData - the meta-data for the class
methodMetaData - meta-data for the method
Returns:
the pointcuts for this join point

getCallPointcuts

public java.util.List getCallPointcuts(ClassMetaData classMetaData,
                                       MethodMetaData methodMetaData)
Returns the call pointcut list for the class and method specified.

Caches the list, needed since the actual method call is expensive and is made each time a new instance of an advised class is created.

Specified by:
getCallPointcuts in interface System
Parameters:
classMetaData - the meta-data for the class
methodMetaData - meta-data for the method
Returns:
the pointcuts for this join point

getCFlowExpressions

public java.util.List getCFlowExpressions(ClassMetaData classMetaData,
                                          MethodMetaData methodMetaData)
Description copied from interface: System
Returns all the cflow call expression for the given metadata (callee side)

Specified by:
getCFlowExpressions in interface System
Parameters:
classMetaData - the name of the class
methodMetaData - the meta-data for the method
Returns:
the pointcuts

getCFlowPointcuts

public java.util.List getCFlowPointcuts(java.lang.String className,
                                        MethodMetaData methodMetaData)
ALEX RM Returns a list with the cflow pointcuts that affects the join point with the class name and the method name specified.

Parameters:
className - the name of the class for the join point
methodMetaData - the meta-data for the method for the join point
Returns:
a list with the cflow pointcuts

hasAspect

public boolean hasAspect(java.lang.String name)
Checks if a specific class has an aspect defined.

Specified by:
hasAspect in interface System
Parameters:
name - the name of the aspect
Returns:
boolean true if the class has an aspect defined

getMethod

public java.lang.reflect.Method getMethod(java.lang.Class klass,
                                          int index)
Returns a specific method by the class and the method index.

Specified by:
getMethod in interface System
Parameters:
klass - the class housing the method
index - the method index
Returns:
the method


Copyright (c) 2002-2004 The AspectWerkz Team. All Rights Reserved.