org.codehaus.aspectwerkz.aspect
Class AbstractAspectContainer

java.lang.Object
  extended by org.codehaus.aspectwerkz.aspect.AbstractAspectContainer
All Implemented Interfaces:
AspectContainer
Direct Known Subclasses:
DefaultAspectContainerStrategy

public abstract class AbstractAspectContainer
extends Object
implements AspectContainer

Abstract base class for the aspect container implementations.

Author:
Jonas BonŽr , Alexandre Vasseur

Field Summary
protected  Object[] ARRAY_WITH_SINGLE_ASPECT_CONTEXT
          An array with the single aspect context, needed to save one array creation per invocation.
static int ASPECT_CONSTRUCTION_TYPE_ASPECT_CONTEXT
           
static int ASPECT_CONSTRUCTION_TYPE_DEFAULT
           
static int ASPECT_CONSTRUCTION_TYPE_UNKNOWN
           
static Object[] EMPTY_OBJECT_ARRAY
           
protected  Map m_adviceInfos
          Maps the advice infos to the hash codes of the the matching advice method.
protected  AspectContext m_aspectContext
          The aspect context prototype.
protected  int m_constructionType
          The aspect construction type.
protected  Map m_perClass
          Holds references to the per class aspect instances.
protected  Map m_perInstance
          Holds references to the per instance aspect instances.
protected  Object m_perJvm
          Holds a reference to the sole per JVM aspect instance.
protected  Map m_perThread
          Holds references to the per thread aspect instances.
 
Constructor Summary
AbstractAspectContainer(AspectContext aspectContext)
          Creates a new aspect container strategy.
 
Method Summary
 Object aspectOf()
          asm Creates a new perJVM cross-cutting instance, if it already exists then return it.
 Object aspectOf(Class klass)
          Creates a new perClass cross-cutting instance, if it already exists then return it.
 Object aspectOf(Object instance)
          Creates a new perInstance cross-cutting instance, if it already exists then return it.
 Object aspectOf(Thread thread)
          Creates a new perThread cross-cutting instance, if it already exists then return it.
protected abstract  Object createAspect()
          To be implemented by the concrete aspect containers.
 AspectContext getContext()
          Returns the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASPECT_CONSTRUCTION_TYPE_UNKNOWN

public static final int ASPECT_CONSTRUCTION_TYPE_UNKNOWN
See Also:
Constant Field Values

ASPECT_CONSTRUCTION_TYPE_DEFAULT

public static final int ASPECT_CONSTRUCTION_TYPE_DEFAULT
See Also:
Constant Field Values

ASPECT_CONSTRUCTION_TYPE_ASPECT_CONTEXT

public static final int ASPECT_CONSTRUCTION_TYPE_ASPECT_CONTEXT
See Also:
Constant Field Values

EMPTY_OBJECT_ARRAY

public static final Object[] EMPTY_OBJECT_ARRAY

ARRAY_WITH_SINGLE_ASPECT_CONTEXT

protected final Object[] ARRAY_WITH_SINGLE_ASPECT_CONTEXT
An array with the single aspect context, needed to save one array creation per invocation.


m_constructionType

protected int m_constructionType
The aspect construction type.


m_aspectContext

protected final AspectContext m_aspectContext
The aspect context prototype.


m_perJvm

protected Object m_perJvm
Holds a reference to the sole per JVM aspect instance.


m_perClass

protected final Map m_perClass
Holds references to the per class aspect instances.


m_perInstance

protected final Map m_perInstance
Holds references to the per instance aspect instances.


m_perThread

protected final Map m_perThread
Holds references to the per thread aspect instances.


m_adviceInfos

protected final Map m_adviceInfos
Maps the advice infos to the hash codes of the the matching advice method.

Constructor Detail

AbstractAspectContainer

public AbstractAspectContainer(AspectContext aspectContext)
Creates a new aspect container strategy.

Parameters:
aspectContext - the context
Method Detail

getContext

public AspectContext getContext()
Returns the context.

Specified by:
getContext in interface AspectContainer
Returns:
the context

aspectOf

public Object aspectOf()
asm Creates a new perJVM cross-cutting instance, if it already exists then return it.

Specified by:
aspectOf in interface AspectContainer
Returns:
the cross-cutting instance

aspectOf

public Object aspectOf(Class klass)
Creates a new perClass cross-cutting instance, if it already exists then return it.

Specified by:
aspectOf in interface AspectContainer
Parameters:
klass -
Returns:
the cross-cutting instance

aspectOf

public Object aspectOf(Object instance)
Creates a new perInstance cross-cutting instance, if it already exists then return it.

Specified by:
aspectOf in interface AspectContainer
Parameters:
instance -
Returns:
the cross-cutting instance

aspectOf

public Object aspectOf(Thread thread)
Creates a new perThread cross-cutting instance, if it already exists then return it.

Specified by:
aspectOf in interface AspectContainer
Parameters:
thread - the thread for the aspect
Returns:
the cross-cutting instance

createAspect

protected abstract Object createAspect()
To be implemented by the concrete aspect containers.

Should return a new aspect instance.

Returns:
a new aspect instance


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