org.objectweb.jac.core
Class CompositionAspect

java.lang.Object
  |
  +--org.objectweb.jac.core.AspectComponent
        |
        +--org.objectweb.jac.core.CompositionAspect
All Implemented Interfaces:
BaseProgramListener, Serializable

public class CompositionAspect
extends AspectComponent

This special aspect component is used by the system to solve inter-aspect composition issues.

It is typically used to order the different wrappers at runtime (see getWeaveTimeRank()) or to check if two aspect components are incompatible of dependent (see addIncompatibleACPairs() and addDependentACPair()).

Author:
Renaud Pawlak
See Also:
Serialized Form

Field Summary
protected  Vector dependentACs
          Store the dependent aspect component pairs.
protected  Vector incompatibleACs
          Store the exclusive aspect component pairs.
protected  Vector wrappingOrder
          Store the default wrapping order.
 
Fields inherited from class org.objectweb.jac.core.AspectComponent
application, blockKeywords, cr, currentConfigMethod, currentImports, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers
 
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener
FOUND_OBJECT
 
Constructor Summary
CompositionAspect()
          The default contructor (reads the jac.prop file to initialize the composition aspect).
 
Method Summary
 void addDependentACPair(AspectComponent ac1, AspectComponent ac2)
          Add a new dependent aspect component pair.
 void addIncompatibleACPair(AspectComponent ac1, AspectComponent ac2)
          Add a new exlusive aspect component pair.
 boolean areCorrectlyOrdered(String wrapperType1, String wrapperType2)
          Returns true if wrapperType1 has to be run before wrapperType2.
 boolean areDependent(AspectComponent ac1, AspectComponent ac2)
          Returns true if the aspect components are dependent.
 boolean areIncompatible(AspectComponent ac1, AspectComponent ac2)
          Returns true if the aspect components are incompatible.
 int getWeaveTimeRank(WrappingChain wrappingChain, Wrapper wrapper)
          When a wrappee method is beeing wrapped by a wrapper, this method is upcalled by the system to get the rank of the wrapper within the wrapping chain (the set of wrappers that allready wrap the wrappee method).
 Vector getWrappingTypesOrder()
          The getter for the wrapping types order.
 
Methods inherited from class org.objectweb.jac.core.AspectComponent
addWrapper, afterApplicationStarted, afterRunningWrapper, afterWrap, afterWrappeeInit, attr, attrdef, beforeConfiguration, beforeReload, beforeRunningWrapper, beforeWrappeeInit, configure, defines, defineTimer, doRegister, doUnregister, error, getAC, getApplication, getBlockKeywords, getConfigurationMethods, getConfigurationMethodsName, getConfigurationMethodsName, getDefaultConfigs, getName, getNameCounters, getWrappers, init, isConfigurationMethod, isSystemListener, onExit, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, setApplication, setAttribute, setAttribute, setAttribute, setSystemListener, simulateUsingNewInstance, unweave, unwrapAll, updateNameCounters, warning, weave, whenClone, whenCloseDisplay, whenConfigured, whenDeleted, whenDeserialized, whenFree, whenGetObjects, whenNameObject, whenObjectMiss, whenReload, whenRemoteInstantiation, whenSerialized, whenTopologyChanged, whenUsingNewClass, whenUsingNewInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wrappingOrder

protected Vector wrappingOrder
Store the default wrapping order.


incompatibleACs

protected Vector incompatibleACs
Store the exclusive aspect component pairs.


dependentACs

protected Vector dependentACs
Store the dependent aspect component pairs.

Constructor Detail

CompositionAspect

public CompositionAspect()
The default contructor (reads the jac.prop file to initialize the composition aspect).

Method Detail

getWeaveTimeRank

public int getWeaveTimeRank(WrappingChain wrappingChain,
                            Wrapper wrapper)
When a wrappee method is beeing wrapped by a wrapper, this method is upcalled by the system to get the rank of the wrapper within the wrapping chain (the set of wrappers that allready wrap the wrappee method).

Parameters:
wrappingChain - the set of wrapping methods that allready wraps the wrappee method
wrapper - the wrapper that is going be added to the wrapping chain
See Also:
Wrapping.wrap(Wrappee,Wrapper,AbstractMethodItem)

areCorrectlyOrdered

public final boolean areCorrectlyOrdered(String wrapperType1,
                                         String wrapperType2)
Returns true if wrapperType1 has to be run before wrapperType2. This method is used by getWeaveTimeRank().

Parameters:
wrapperType1 - the first type to check
wrapperType2 - the second type to check
Returns:
true if (wrapperType1 < wrapperType2 )
See Also:
getWeaveTimeRank(WrappingChain,Wrapper)

getWrappingTypesOrder

public final Vector getWrappingTypesOrder()
The getter for the wrapping types order.

Returns:
a vector that contains the ordered wrapper classes

addIncompatibleACPair

public final void addIncompatibleACPair(AspectComponent ac1,
                                        AspectComponent ac2)
Add a new exlusive aspect component pair.

If ac1 and ac2 are incompatible, then ac1 cannot be registered in the Aspect Component Manager if ac2 is already registered (and reverse).

NOTE: this is a reflexive relation.

Parameters:
ac1 - the aspect component that is incompatible with ac2
ac2 - the aspect component that is incompatible with ac1
See Also:
ACManager.register(String,Object)

addDependentACPair

public final void addDependentACPair(AspectComponent ac1,
                                     AspectComponent ac2)
Add a new dependent aspect component pair.

If ac1 depends on ac2, then ac1 cannot be registered in the Aspect Component Manager if ac2 is not already registered.

NOTE: this is a transitive relation.

Parameters:
ac1 - the aspect component that depends on ac2
ac2 - the aspect component on which ac1 depends
See Also:
ACManager.register(String,Object)

areIncompatible

public final boolean areIncompatible(AspectComponent ac1,
                                     AspectComponent ac2)
Returns true if the aspect components are incompatible.

NOTE: areIncompatible(ac1,ac2) equals areIncompatible(ac2,ac1)

Parameters:
ac1 - the first aspect component to check
ac2 - the second aspect component to check
Returns:
true if ac1 is incompatible with ac2
See Also:
addIncompatibleACPair(AspectComponent,AspectComponent)

areDependent

public final boolean areDependent(AspectComponent ac1,
                                  AspectComponent ac2)
Returns true if the aspect components are dependent.

NOTE: areDependent(ac1,ac2) not equals areDependent(ac2,ac1)

Parameters:
ac1 - the first aspect component to check
ac2 - the second aspect component to check
Returns:
true if ac1 depends on ac2
See Also:
addDependentACPair(AspectComponent,AspectComponent)