org.codehaus.aspectwerkz.aspect.management
Class Aspects

java.lang.Object
  extended by org.codehaus.aspectwerkz.aspect.management.Aspects

public class Aspects
extends Object

Manages the aspects, registry for the aspect containers (one container per aspect type).

Author:
Jonas Bonér , Alexandre Vasseur

Field Summary
static String DEFAULT_ASPECT_CONTAINER
          The default aspect container class.
 
Method Summary
static Object aspect$Of(ClassLoader loader, String qName, String containerClassName)
           
static Object aspect$Of(String qName, String containerClassName, Class perClass)
           
static Object aspect$Of(String qName, String containerClassName, Object perInstance)
           
static Object aspectOf(Class aspectClass)
          Returns the singleton aspect instance for the given aspect class.
static Object aspectOf(Class aspectClass, Class targetClass)
          Returns the per class aspect attached to targetClass Consider using aspectOf(qName, targetClass) if the aspect is used more than once
static Object aspectOf(ClassLoader visibleFrom, String qName)
          Returns the singleton aspect instance for given aspect qName, with visibility from the given class loader
static Object aspectOf(Class aspectClass, Object targetInstance)
          Returns the per instance aspect attached to targetInstance Consider using aspectOf(qName, targetInstance) if the aspect is used more than once
static Object aspectOf(String qName)
          Returns the singleton aspect instance for the aspect with the given qualified name.
static Object aspectOf(String qName, Class targetClass)
          Returns the per class aspect instance for the aspect with the given qualified name for targetClass
static Object aspectOf(String qName, Object targetInstance)
          Returns the per instance aspect attached to targetInstance
static String[] getAspectQNameContainerClassName(ClassLoader visibleFrom, String qName)
          Returns the aspect container class for the given aspect class qName.
static AspectContainer getContainerQNamed(ClassLoader visibleFrom, Class containerClass, String qName)
          Returns or create the aspect container for the given container class with the given aspect qualified name

We keep a weak key for the containerClass, and we then keep a list of container instance based on a composite key based on the tuple {visibleFromClassLoader.hashCode, aspectQName}, so that when hot deploying a web app, the aspects gets tied to the web app class loader even when the container class is higher up (f.e. in aw.jar)

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ASPECT_CONTAINER

public static final String DEFAULT_ASPECT_CONTAINER
The default aspect container class.

Method Detail

getAspectQNameContainerClassName

public static String[] getAspectQNameContainerClassName(ClassLoader visibleFrom,
                                                        String qName)
Returns the aspect container class for the given aspect class qName. The qName is returned since we may have only the aspect class name upon lookup

Parameters:
visibleFrom - class loader to look from
qName -
Returns:
the container class

getContainerQNamed

public static AspectContainer getContainerQNamed(ClassLoader visibleFrom,
                                                 Class containerClass,
                                                 String qName)
Returns or create the aspect container for the given container class with the given aspect qualified name

We keep a weak key for the containerClass, and we then keep a list of container instance based on a composite key based on the tuple {visibleFromClassLoader.hashCode, aspectQName}, so that when hot deploying a web app, the aspects gets tied to the web app class loader even when the container class is higher up (f.e. in aw.jar)

Parameters:
visibleFrom - class loader hosting the advised class ie from where all is visible
containerClass -
qName -
Returns:

aspectOf

public static Object aspectOf(String qName)
Returns the singleton aspect instance for the aspect with the given qualified name. The aspect is looked up from the thread context classloader.

Parameters:
qName - the qualified name of the aspect
Returns:
the singleton aspect instance

aspectOf

public static Object aspectOf(Class aspectClass)
Returns the singleton aspect instance for the given aspect class. Consider using aspectOf(visibleFrom, qName) if the aspect is used more than once or if it is used in a class loader which is child of its own classloader.

Parameters:
aspectClass - the class of the aspect
Returns:
the singleton aspect instance

aspectOf

public static Object aspectOf(ClassLoader visibleFrom,
                              String qName)
Returns the singleton aspect instance for given aspect qName, with visibility from the given class loader

Parameters:
visibleFrom - the class loader from where aspect is visible, likely to be the class loader of the advised classes, or the one where the system hosting the aspect is deployed.
Returns:
the singleton aspect instance

aspectOf

public static Object aspectOf(Class aspectClass,
                              Class targetClass)
Returns the per class aspect attached to targetClass Consider using aspectOf(qName, targetClass) if the aspect is used more than once

Parameters:
aspectClass - the name of the aspect
targetClass - the target class
Returns:
the per class aspect instance

aspectOf

public static Object aspectOf(String qName,
                              Class targetClass)
Returns the per class aspect instance for the aspect with the given qualified name for targetClass

Parameters:
qName - the qualified name of the aspect
targetClass - the target class
Returns:
the per class aspect instance

aspectOf

public static Object aspectOf(Class aspectClass,
                              Object targetInstance)
Returns the per instance aspect attached to targetInstance Consider using aspectOf(qName, targetInstance) if the aspect is used more than once

Parameters:
aspectClass - the name of the aspect
targetInstance - the target instance
Returns:
the per class aspect instance

aspectOf

public static Object aspectOf(String qName,
                              Object targetInstance)
Returns the per instance aspect attached to targetInstance

Parameters:
qName - the qualified name of the aspect
targetInstance - the target instance
Returns:
the per class aspect instance

aspect$Of

public static Object aspect$Of(ClassLoader loader,
                               String qName,
                               String containerClassName)

aspect$Of

public static Object aspect$Of(String qName,
                               String containerClassName,
                               Class perClass)

aspect$Of

public static Object aspect$Of(String qName,
                               String containerClassName,
                               Object perInstance)


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