org.codehaus.aspectwerkz
Class AspectSystem

java.lang.Object
  extended byorg.codehaus.aspectwerkz.AspectSystem

public final class AspectSystem
extends Object

Represents the aspect runtime system.
Manages the different parts of the runtime system and provides and API to access and manage the system.

There is an AspectSystem per ClassLoader. An AspectSystem is aware of the classloader hierarchy and reflects it by gathering the AspectManager, which represents a single <system ..> entry.

When an instance of an AspectSystem is created (perClassLoader), it checks for existence of previous AspectManager defined in parent ClassLoader. AspectManager are shared among AspectSystem as shown below:

 
  
   
    
              [0d, 1d, 2d]  (3 SystemDefs, all defined in this classloader)
                      /   \
     [0r, 1r, 2r, 3d]      \  (3 reused, one more defined)
                         [0r, 1r, 2r, 3d]  (one more defined, not the same)
     
    
   
  
 

This composition strategy allow to avoid global static repository, but is tight to following ClassLoader parent hierarchy.

If an AspectManager is added at runtime, it should be added in the whole child hierarchy. TODO

TODO: caution when addding a new SystemDefinition in between. TODO: move the remote proxy elsewhere unless defining classloader is needed.

Author:
Jonas Bonér , Alexandre Vasseur

Method Summary
 void enteringControlFlow(PointcutType pointcutType, MethodInfo methodInfo, ClassInfo withinInfo)
          Registers entering of a control flow join point.
 void exitingControlFlow(PointcutType pointcutType, MethodInfo methodInfo, ClassInfo withinInfo)
          Registers exiting from a control flow join point.
 AspectManager getAspectManager(int aspectManagerIndex)
          Returns an AspectManager by its index.
 AspectManager getAspectManager(String uuid)
          Returns an AspectManager by its uuid
 AspectManager[] getAspectManagers()
          Returns the aspect managers for this system.
 ClassLoader getDefiningClassLoader()
          Returns the classloader which defines this AspectSystem
 void initialize()
          Initializes the system.
 boolean isInControlFlowOf(CflowExpressionVisitorRuntime expression, ExpressionContext expressionContext)
          Checks if we are in the control flow of a join point picked out by a specific pointcut expression.
 void propagateAspectManagers(AspectManager[] block, int blockSizeBefore)
          Propagates the aspect managers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefiningClassLoader

public ClassLoader getDefiningClassLoader()
Returns the classloader which defines this AspectSystem

Returns:
the classloader which defines this AspectSystem

getAspectManager

public AspectManager getAspectManager(int aspectManagerIndex)
Returns an AspectManager by its index. The index are stable when the ClassLoader hierarchy is crossed from top to bottom

Parameters:
aspectManagerIndex -
Returns:
AspectManager, or throw an IndexOutOfBoundException

getAspectManager

public AspectManager getAspectManager(String uuid)
Returns an AspectManager by its uuid

Parameters:
uuid -
Returns:
AspectManager
Throws:
DefinitionException - (runtime exception) if not found

initialize

public void initialize()
Initializes the system. The initialization needs to be separated from the construction of the manager, and is triggered by the runtime system


getAspectManagers

public AspectManager[] getAspectManagers()
Returns the aspect managers for this system.

Returns:
the aspect managers

enteringControlFlow

public void enteringControlFlow(PointcutType pointcutType,
                                MethodInfo methodInfo,
                                ClassInfo withinInfo)
Registers entering of a control flow join point.

Parameters:
pointcutType - the pointcut type
methodInfo - the method info
withinInfo - the within info

exitingControlFlow

public void exitingControlFlow(PointcutType pointcutType,
                               MethodInfo methodInfo,
                               ClassInfo withinInfo)
Registers exiting from a control flow join point.

Parameters:
pointcutType - the pointcut type
methodInfo - the method info
withinInfo - the within info

isInControlFlowOf

public boolean isInControlFlowOf(CflowExpressionVisitorRuntime expression,
                                 ExpressionContext expressionContext)
Checks if we are in the control flow of a join point picked out by a specific pointcut expression.

Parameters:
expression - the cflow expression runtime visitor
expressionContext - the join point expression context whose pointcut contains cflows sub expression(s)
Returns:
boolean

propagateAspectManagers

public void propagateAspectManagers(AspectManager[] block,
                                    int blockSizeBefore)
Propagates the aspect managers.

Parameters:
block -
blockSizeBefore -


Copyright © 2002-2004 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.