org.codehaus.aspectwerkz.aspect.management
Class Mixins

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

public class Mixins
extends Object

Manages the mixins, registry for the mixin factories (one factory per mixin type).

Author:
Jonas BonŽr , Alexandre Vasseur

Field Summary
static String DEFAULT_MIXIN_FACTORY
          The default mixin factory class.
 
Method Summary
static MixinFactory getFactory(Class mixinClass, ClassLoader mixinCalledFromLoader)
          Returns the mixin factory for the mixin with the given name.
static MixinDefinition getMixinDefinition(Class mixinClass, ClassLoader visibleFrom)
          Lookups a mixin definition based on the mixin impl class and a classloader from where the mixin is visible.
static Map getParameters(Class mixinClass, ClassLoader loader)
          Returns the parameter for a mixin based on the mixin implementation class and a classloader from where the mixin is visible (the classloader that owns the aop.xml with the "mixin" element, or a child of it).
static Object mixinOf(Class mixinClass)
          Returns the per jvm mixin instance for the mixin with the given implementation class deployed using the perJVM model.
static Object mixinOf(Class mixinClass, Class targetClass)
          Returns the per class mixin instance for the mixin with the given implemnentation class deployed using the perClass model.
static Object mixinOf(Class mixinClass, Object targetInstance)
          Returns the per class mixin instance for the mixin with the given implemnentation class deployed using the perClass model.
static Object mixinOf(String name, Class targetClass)
          Returns the per class mixin instance for the mixin with the given name for the perClass model
static Object mixinOf(String name, ClassLoader loader)
          Returns the per JVM mixin instance for the mixin with the given name
static Object mixinOf(String name, Object targetInstance)
          Returns the per targetClass instance mixin instance for the mixin with the given name for the perInstance model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MIXIN_FACTORY

public static final String DEFAULT_MIXIN_FACTORY
The default mixin factory class.

Method Detail

getFactory

public static MixinFactory getFactory(Class mixinClass,
                                      ClassLoader mixinCalledFromLoader)
Returns the mixin factory for the mixin with the given name.

Parameters:
mixinClass - the class of the mixin
mixinCalledFromLoader -
Returns:
the factory, put in cache based on mixin class as a key

mixinOf

public static Object mixinOf(String name,
                             ClassLoader loader)
Returns the per JVM mixin instance for the mixin with the given name

Parameters:
name - the name of the mixin
loader - target class classloader
Returns:
the per jvm mixin instance

mixinOf

public static Object mixinOf(Class mixinClass)
Returns the per jvm mixin instance for the mixin with the given implementation class deployed using the perJVM model.

Parameters:
mixinClass - the name of the mixin
Returns:
the per jvm mixin instance

mixinOf

public static Object mixinOf(String name,
                             Class targetClass)
Returns the per class mixin instance for the mixin with the given name for the perClass model

Parameters:
name - the name of the mixin
targetClass - the targetClass class
Returns:
the per class mixin instance

mixinOf

public static Object mixinOf(Class mixinClass,
                             Class targetClass)
Returns the per class mixin instance for the mixin with the given implemnentation class deployed using the perClass model.

Parameters:
mixinClass - the name of the mixin
targetClass - the targetClass class
Returns:
the per class mixin instance

mixinOf

public static Object mixinOf(String name,
                             Object targetInstance)
Returns the per targetClass instance mixin instance for the mixin with the given name for the perInstance model.

Parameters:
name - the name of the mixin
targetInstance - the targetClass instance, can be null (static method, ctor call)
Returns:
the per instance mixin instance, fallback on perClass if targetInstance is null

mixinOf

public static Object mixinOf(Class mixinClass,
                             Object targetInstance)
Returns the per class mixin instance for the mixin with the given implemnentation class deployed using the perClass model.

Parameters:
mixinClass - the name of the mixin
targetInstance - the targetClass instance, can be null
Returns:
the per targetClass instance mixin instance, fallback to perClass if targetInstance is null

getParameters

public static Map getParameters(Class mixinClass,
                                ClassLoader loader)
Returns the parameter for a mixin based on the mixin implementation class and a classloader from where the mixin is visible (the classloader that owns the aop.xml with the "mixin" element, or a child of it).

Note: the mixinClass classloader can be different, if you place the mixin in the system classpath, and reference it only from a deployed application.

Note: you should not use a mixin more than once. Consider subclassing the mixin in this case. The returned parameters are the one from the first mixin found.

Parameters:
mixinClass -
Returns:

getMixinDefinition

public static MixinDefinition getMixinDefinition(Class mixinClass,
                                                 ClassLoader visibleFrom)
Lookups a mixin definition based on the mixin impl class and a classloader from where the mixin is visible. The given classloader can be different from the mixin class classloader.

Parameters:
mixinClass -
visibleFrom -
Returns:


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