org.codehaus.aspectwerkz.xmldef
Class XmlDefSystem

java.lang.Object
  extended byorg.codehaus.aspectwerkz.xmldef.XmlDefSystem
All Implemented Interfaces:
System

public final class XmlDefSystem
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
XmlDefSystem(java.lang.String uuid, AspectWerkzDefinition definition)
          Should NEVER be invoked by the user.
 
Method Summary
 void createAdvice(java.lang.String name, java.lang.String className, java.lang.String deploymentModel, java.lang.ClassLoader loader)
          Creates and registers new advice 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.
 Advice getAdvice(IndexTuple index)
          Retrieves a specific advice based setfield's index.
 Advice getAdvice(java.lang.String name)
          Returns the advice for a specific name.
 IndexTuple getAdviceIndexFor(java.lang.String name)
          Returns the index for a specific name to advice mapping.
 AspectMetaData getAspectMetaData(java.lang.String name)
          Returns the aspect for the name specified.
 java.util.Collection getAspectsMetaData()
          Returns a list with all the aspects.
 java.util.List getCallPointcuts(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the caller side pointcut list for the class and method specified.
 java.util.List getCFlowExpressions(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns a list with the cflow call expressions that affects the join point with the class name and the method name specified.
 java.util.List getExecutionPointcuts(ClassMetaData classMetaData, MethodMetaData methodMetaData)
          Returns the method pointcut list for the class and method specified.
 java.util.List getGetPointcuts(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Returns the get field pointcut list for the class and field specified.
 int getIntroductionIndex(java.lang.String name)
          Returns the index for a specific name to introduction mapping.
 Introduction[] getIntroductions()
          Returns an array with all the introductions in the system.
 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 introduction based it's index.
 Mixin getMixin(java.lang.String name)
          Returns the introduction for a specific name.
 java.util.List getSetPointcuts(ClassMetaData classMetaData, FieldMetaData fieldMetaData)
          Returns the set field 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)
          ALEX RM 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 expression.
 boolean isXmlDef()
          Checks if the definition is of type XML definition.
 void register(AspectMetaData aspect)
          Registers a new aspect for a specific class.
 void register(java.lang.String name, Advice advice)
          Registers a new advice and maps it to a name.
 void register(java.lang.String name, Introduction introduction)
          Registers an introduction and maps it to a name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDefSystem

public XmlDefSystem(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 false for this system

isXmlDef

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

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

register

public void register(AspectMetaData aspect)
Registers a new aspect for a specific class.

Parameters:
aspect - the aspect to register

register

public void register(java.lang.String name,
                     Advice advice)
Registers a new advice and maps it to a name.

Parameters:
name - the name to map the advice to
advice - the advice to register

register

public void register(java.lang.String name,
                     Introduction introduction)
Registers an introduction and maps it to a name. At the moment it is not possible to add new introductions at runtime (don't know if it makes sense).

Parameters:
name - the name to map the introduction to
introduction - the introduction to register

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(CompiledPatternTuple patternTuple)
ALEX RM 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

isInControlFlowOf

public boolean isInControlFlowOf(Expression cflowExpression)
Checks if we are in the control flow of a specific cflow expression.

Specified by:
isInControlFlowOf in interface System
Parameters:
cflowExpression - the call expression of the cflow pointcut
Returns:
boolean

createAdvice

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

Parameters:
name - the name of the advice
className - the class name of the advice
deploymentModel - the deployment model for the advice
loader - an optional class loader (if null it uses the context classloader)

getAspectMetaData

public AspectMetaData getAspectMetaData(java.lang.String name)
Returns the aspect 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.

Specified by:
getAspectsMetaData in interface System
Returns:
the aspects

getExecutionPointcuts

public java.util.List getExecutionPointcuts(ClassMetaData classMetaData,
                                            MethodMetaData methodMetaData)
Returns the method 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 field 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 field
Returns:
the pointcuts for this join point

getSetPointcuts

public java.util.List getSetPointcuts(ClassMetaData classMetaData,
                                      FieldMetaData fieldMetaData)
Returns the set field 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 field
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 caller side 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)
Returns a list with the cflow call expressions that affects the join point with the class name and the method name specified.

Specified by:
getCFlowExpressions in interface System
Parameters:
classMetaData - the class meta-data for the join point
methodMetaData - the meta-data for the method for the join point
Returns:
a list with the cflow pointcuts

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

getAdvice

public Advice getAdvice(IndexTuple index)
Retrieves a specific advice based setfield's index.

Parameters:
index - the index of the advice
Returns:
the advice

getAdvice

public Advice getAdvice(java.lang.String name)
Returns the advice for a specific name.

Parameters:
name - the name of the advice
Returns:
the the advice

getIntroductions

public Introduction[] getIntroductions()
Returns an array with all the introductions in the system.

Returns:
the introductions

getIntroductionIndex

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

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

getMixin

public Mixin getMixin(int index)
Retrieves a specific introduction based it's index.

Specified by:
getMixin in interface System
Parameters:
index - the index of the introduction
Returns:
the introduction

getMixin

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

Specified by:
getMixin in interface System
Parameters:
name - the name of the introduction
Returns:
the the introduction

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.