Package org.aspectj.lang
Class Aspects
java.lang.Object
org.aspectj.lang.Aspects
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 dependencies in your project.
- Author:
- Alexandre Vasseur
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
static <T> T
static <T> T
static boolean
static boolean
static boolean
-
Constructor Details
-
Aspects
public Aspects()
-
-
Method Details
-
aspectOf
- Type Parameters:
T
- the expected class of the aspect- Parameters:
aspectClass
- the aspect class- Returns:
- the singleton aspect or the percflow / percflowbelow associated with the current thread
- Throws:
NoAspectBoundException
- if no such aspect
-
aspectOf
- Type Parameters:
T
- the expected class of the aspect- Parameters:
aspectClass
- the aspect classperObject
- the this/target object for which to look for an aspect instance- Returns:
- the associated perthis / pertarget aspect instance
- Throws:
NoAspectBoundException
- if no such aspect, or no aspect bound
-
aspectOf
public static <T> T aspectOf(Class<T> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException - Type Parameters:
T
- the expected class of the aspect- Parameters:
aspectClass
- the aspect classperTypeWithin
- the class for which to search for an aspect instance- Returns:
- the associated aspect instance
- Throws:
NoAspectBoundException
- if no such aspect, or no aspect bound
-
hasAspect
- Parameters:
aspectClass
- the aspect class- Returns:
- true if singleton aspect or percflow / percflowbelow aspect is bound
- Throws:
NoAspectBoundException
- if not bound
-
hasAspect
public static boolean hasAspect(Class<?> aspectClass, Object perObject) throws NoAspectBoundException - Parameters:
aspectClass
- the aspect classperObject
- the this/target object for which to look for an aspect instance- Returns:
- true if the perthis / pertarget aspect is bound
- Throws:
NoAspectBoundException
- if not bound
-
hasAspect
public static boolean hasAspect(Class<?> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException - Parameters:
aspectClass
- the aspect classperTypeWithin
- class- Returns:
- true if the pertypewithin aspect is bound
- Throws:
NoAspectBoundException
- if not bound
-