Top Description Fields Constructors Methods
org.aspectj.lang

public Class Aspects

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, .Modifier, .InvocationTargetException

Handles generic aspectOf method when those are not available in the aspects but added later on thru load time weaving. Aspects.aspectOf(..) is doing reflective calls to the aspect aspectOf, so for better performance consider using ajc compilation of the aspects and using them as a binary dependancies in your project.
Author
Alexandre Vasseur

Field Summary

Modifier and TypeField and Description
private static final String
private static final Class<T>[]
private static final Object[]
private static final String
private static final Class<T>[]
private static final Class<T>[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
the expected class of the aspect
T
>
T

Returns:

the singleton aspect or the percflow / percflowbelow associated with the current thread
aspectOf
(Class<T>
the aspect class
aspectClass
)

public static <
the expected class of the aspect
T
>
T

Returns:

the associated perthis / pertarget aspect instance
aspectOf
(Class<T>
the aspect class
aspectClass
,
Object
the this/target object for which to look for an aspect instance
perObject
)

public static <
the expected class of the aspect
T
>
T

Returns:

the associated aspect instance
aspectOf
(Class<T>
the aspect class
aspectClass
,
Class<?>
the class for which to search for an aspect instance
perTypeWithin
)

private static Method
checkAspectOf(Method method, Class<?> aspectClass)

private static Method
checkHasAspect(Method method, Class<?> aspectClass)

private static Method
getPerObjectAspectOf(Class<?> aspectClass)

private static Method
getPerObjectHasAspect(Class<?> aspectClass)

private static Method
private static Method
private static Method
private static Method
public static boolean

Returns:

true if singleton aspect or percflow / percflowbelow aspect is bound
hasAspect
(Class<?>
the aspect class
aspectClass
)

public static boolean

Returns:

true if the perthis / pertarget aspect is bound
hasAspect
(Class<?>
the aspect class
aspectClass
,
Object
the this/target object for which to look for an aspect instance
perObject
)

public static boolean

Returns:

true if the pertypewithin aspect is bound
hasAspect
(Class<?>
the aspect class
aspectClass
,
Class<?>
class
perTypeWithin
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASPECTOFback to summary
private static final String ASPECTOF
EMPTY_CLASS_ARRAYback to summary
private static final Class<T>[] EMPTY_CLASS_ARRAY
EMPTY_OBJECT_ARRAYback to summary
private static final Object[] EMPTY_OBJECT_ARRAY
HASASPECTback to summary
private static final String HASASPECT
PEROBJECT_CLASS_ARRAYback to summary
private static final Class<T>[] PEROBJECT_CLASS_ARRAY
PERTYPEWITHIN_CLASS_ARRAYback to summary
private static final Class<T>[] PERTYPEWITHIN_CLASS_ARRAY

Constructor Detail

Aspectsback to summary
public Aspects()

Method Detail

aspectOfback to summary
public static <T> T aspectOf(Class<T> aspectClass) throws NoAspectBoundException
Parameters
<T>
the expected class of the aspect
aspectClass:Class<T>

the aspect class

Returns:T

the singleton aspect or the percflow / percflowbelow associated with the current thread

Exceptions
NoAspectBoundException:
if no such aspect
aspectOfback to summary
public static <T> T aspectOf(Class<T> aspectClass, Object perObject) throws NoAspectBoundException
Parameters
<T>
the expected class of the aspect
aspectClass:Class<T>

the aspect class

perObject:Object

the this/target object for which to look for an aspect instance

Returns:T

the associated perthis / pertarget aspect instance

Exceptions
NoAspectBoundException:
if no such aspect, or no aspect bound
aspectOfback to summary
public static <T> T aspectOf(Class<T> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException
Parameters
<T>
the expected class of the aspect
aspectClass:Class<T>

the aspect class

perTypeWithin:Class<?>

the class for which to search for an aspect instance

Returns:T

the associated aspect instance

Exceptions
NoAspectBoundException:
if no such aspect, or no aspect bound
checkAspectOfback to summary
private static Method checkAspectOf(Method method, Class<?> aspectClass) throws NoSuchMethodException
checkHasAspectback to summary
private static Method checkHasAspect(Method method, Class<?> aspectClass) throws NoSuchMethodException
getPerObjectAspectOfback to summary
private static Method getPerObjectAspectOf(Class<?> aspectClass) throws NoSuchMethodException
getPerObjectHasAspectback to summary
private static Method getPerObjectHasAspect(Class<?> aspectClass) throws NoSuchMethodException
getPerTypeWithinAspectOfback to summary
private static Method getPerTypeWithinAspectOf(Class<?> aspectClass) throws NoSuchMethodException
getPerTypeWithinHasAspectback to summary
private static Method getPerTypeWithinHasAspect(Class<?> aspectClass) throws NoSuchMethodException
getSingletonOrThreadAspectOfback to summary
private static Method getSingletonOrThreadAspectOf(Class<?> aspectClass) throws NoSuchMethodException
getSingletonOrThreadHasAspectback to summary
private static Method getSingletonOrThreadHasAspect(Class<?> aspectClass) throws NoSuchMethodException
hasAspectback to summary
public static boolean hasAspect(Class<?> aspectClass) throws NoAspectBoundException
Parameters
aspectClass:Class<?>

the aspect class

Returns:boolean

true if singleton aspect or percflow / percflowbelow aspect is bound

Exceptions
NoAspectBoundException:
if not bound
hasAspectback to summary
public static boolean hasAspect(Class<?> aspectClass, Object perObject) throws NoAspectBoundException
Parameters
aspectClass:Class<?>

the aspect class

perObject:Object

the this/target object for which to look for an aspect instance

Returns:boolean

true if the perthis / pertarget aspect is bound

Exceptions
NoAspectBoundException:
if not bound
hasAspectback to summary
public static boolean hasAspect(Class<?> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException
Parameters
aspectClass:Class<?>

the aspect class

perTypeWithin:Class<?>

class

Returns:boolean

true if the pertypewithin aspect is bound

Exceptions
NoAspectBoundException:
if not bound