|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.Wrapping
This class provides a set of useful static methods that allow the wrapping of wrappable objects (wrappee) by some wrapper objects.
Field Summary | |
static Object[] |
emptyArray
|
Constructor Summary | |
Wrapping()
|
Method Summary | |
static void |
addExceptionHandler(Wrappee wrappee,
Wrapper wrapper,
String method)
|
static void |
addExceptionHandler(Wrappee wrappee,
Wrapper wrapper,
String method,
AbstractMethodItem listenedMethod)
|
static Object |
clone(Object org)
|
static List |
getCatchingChain(Wrappee wrappee,
AbstractMethodItem method)
Returns the catching chain that wraps the given method. |
static List |
getWrapperClasses(Wrappee wrappee,
ClassItem wrappeeClass)
Returns the classes of the wrappers that wrap the given wrappee or wrappee's class. |
static List |
getWrappers(Wrappee wrappee,
ClassItem wrappeeClass)
Returns the wrappers that wrap the given wrappee or wrappee's class. |
static WrappingChain |
getWrappingChain(Wrappee wrappee,
AbstractMethodItem method)
Returns the wrapping chain that wraps the given method. |
static Object |
invokeOrg(Wrappee wrappee,
MethodItem method,
Object[] parameters)
|
static Object |
invokeOrg(Wrappee wrappee,
String name,
Object[] parameters)
This method can be used to shortcut the wrapping chain and directly call the original method. |
static Object |
invokeRoleMethod(Wrappee wrappee,
ClassItem wrappeeClass,
Class wrapperClass,
String methodName,
Object[] parameters)
Invokes a role method on the wrappee. |
static Object |
invokeRoleMethod(Wrappee wrappee,
Class wrapperClass,
String methodName,
Object[] parameters)
Invokes a role method on the wrappee. |
static Object |
invokeRoleMethod(Wrappee wrappee,
String methodName,
Object[] parameters)
Invokes a role method on the wrappee. |
static boolean |
isExtendedBy(Wrappee wrappee,
ClassItem wrappeeClass,
Class wrapperClass)
Tells wether a wrappee has a wrapper whose class can be assigned to a given wrapper class. |
static boolean |
isWrappable(AbstractMethodItem method)
Tells if a given method is wrappable. |
static boolean |
isWrappedBy(Wrappee wrappee,
ClassItem wrappeeClass,
Class wrapperClass)
Returns true if the wrappee or the wrappeeClass is wrapped by a wrapper class. |
static boolean |
isWrappedBy(Wrappee wrappee,
ClassItem wrappeeClass,
Wrapper wrapper)
Tells wether a wrapper wraps a wrappee or a class |
static Object |
methodNextWrapper(Interaction interaction)
|
static Object |
nextWrapper(Interaction interaction)
This method factorizes the common code that is used when the next wrapper is called. |
static String |
printWrappingChain(Interceptor[] wrappingChain)
|
static void |
unwrap(Wrappee wrappee,
ClassItem wrappeeClass,
Collection acWrappers)
Removes all wrappers that belong to list of wrappers |
static void |
unwrap(Wrappee wrappee,
ClassItem wrappeeClass,
Wrapper wrapper)
Definitively removes a wrapper. |
static void |
unwrap(Wrappee wrappee,
Wrapper wrapper,
AbstractMethodItem wrappedMethod)
Unwraps a single method. |
static void |
unwrapAll(Wrappee wrappee,
ClassItem wrappeeClass,
Wrapper wrapper)
|
static void |
wrap(Wrappee wrappee,
ClassItem wrappeeClass,
Wrapper wrapper)
Adds a wrapper to the current wrappee. |
static void |
wrap(Wrappee wrappee,
Wrapper wrapper,
AbstractMethodItem wrappedMethod)
Wrap a method of an object. |
static void |
wrap(Wrappee wrappee,
Wrapper wrapper,
AbstractMethodItem[] wrappedMethods)
A nicer way to write wrap when several base methods
need to be wrapped. |
static void |
wrap(Wrappee wrappee,
Wrapper wrapper,
String[] wrappedMethods)
A string based version of wrap (for simplification purpose). |
static void |
wrapAll(Wrappee wrappee,
ClassItem wrappeeClass,
Wrapper wrapper)
Wraps all the wrappable (public) methods of the current wrappee. |
static boolean |
wrapMethod(Wrappee wrappee,
Wrapper wrapper,
AbstractMethodItem wrappedMethod)
Wrap a method of an object. |
static void |
wrapModifiers(Wrappee wrappee,
Wrapper wrapper)
Wraps all the writer wrappable (public) methods of the current wrappee. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Object[] emptyArray
Constructor Detail |
public Wrapping()
Method Detail |
public static WrappingChain getWrappingChain(Wrappee wrappee, AbstractMethodItem method)
wrappee
- the wrappee (if null, the given method is
nesserally a static method)method
- the wrapped method (can be static, then wrappee is
null)public static List getCatchingChain(Wrappee wrappee, AbstractMethodItem method)
wrappee
- the wrappee (if null, the given method is
nesserally a static method)method
- the wrapped method (can be static, then wrappee is
null)public static List getWrappers(Wrappee wrappee, ClassItem wrappeeClass)
wrappee
- the wrappee (can be null if wrappeeClass is not
null)wrappeeClass
- the wrappee's class (can be null if wrappee
is not null)public static List getWrapperClasses(Wrappee wrappee, ClassItem wrappeeClass)
wrappee
- the wrappee (can be null if wrappeeClass is not
null)wrappeeClass
- the wrappee's class (can be null if wrappee
is not null)public static void wrap(Wrappee wrappee, ClassItem wrappeeClass, Wrapper wrapper)
Any method of this wrapper can then be used on the wrappee
with invokeRoleMethod
.
To precise which method of this wrapper should actually wrap
the current wrappee methods, use the wrap
methods.
wrappee
- the wrappee (can be null if wrappeeClass is not
null, then wraps all the instances of the class in a static
mode)wrappeeClass
- the wrappee's class (can be null if wrappee
is not null)wrapper
- the new wrapperpublic static boolean isWrappable(AbstractMethodItem method)
method
- the method to checkpublic static String printWrappingChain(Interceptor[] wrappingChain)
public static void wrap(Wrappee wrappee, Wrapper wrapper, AbstractMethodItem wrappedMethod)
wrappee
- the object to wrapwrapper
- the wrapperwrappedMethod
- the method of wrappee to wrappublic static boolean wrapMethod(Wrappee wrappee, Wrapper wrapper, AbstractMethodItem wrappedMethod)
wrappee
- the object to wrapwrapper
- the wrapperwrappedMethod
- the method of wrappee to wrap
public static void wrap(Wrappee wrappee, Wrapper wrapper, AbstractMethodItem[] wrappedMethods)
wrap
when several base methods
need to be wrapped.
wrappee
- the wrappee (can be null if the wrappeed methods
are static)wrapper
- the wrapper where the wrapping method is
implementedwrappedMethods
- the names of the wrapped methodspublic static void wrap(Wrappee wrappee, Wrapper wrapper, String[] wrappedMethods)
wrappee
- the wrappee (cannot be null, this version only
works for non-static methods)wrapper
- the wrapper where the wrapping method is
implementedwrappedMethods
- the names of the wrapped methodswrap(Wrappee,Wrapper,AbstractMethodItem[])
public static void wrapAll(Wrappee wrappee, ClassItem wrappeeClass, Wrapper wrapper)
wrappee
- the wrappee (can be null, then only wrap static
methods)wrappeeClass
- the wrappee's class (can be null if wrappee
is not null)wrapper
- the wrapperpublic static void wrapModifiers(Wrappee wrappee, Wrapper wrapper)
wrappee
- the wrappee (cannot be null, this version only
works for non-static methods)wrapper
- the wrapperpublic static void unwrap(Wrappee wrappee, ClassItem wrappeeClass, Wrapper wrapper)
When this method is called, none of the methods of the wrapper can be used as role methods anymore.
This method before calls the unwrapAll
to ensure
that none of the current wrappee methods are yet wrapped.
wrappee
- the wrappee (can be null, then only wrap static
methods)wrappeeClass
- the wrappee's class (can be null if wrappee
is not null)wrapper
- the wrapper to removeunwrapAll(Wrappee,ClassItem,Wrapper)
,
invokeRoleMethod(Wrappee,String,Object[])
public static void unwrap(Wrappee wrappee, ClassItem wrappeeClass, Collection acWrappers)
wrappee
- the wrappee to unwrap (may be null for static methods)wrappeeClass
- the class of the wrappee to unwrapacWrappers
- the wrappers to remove (the wrappers of an aspect component)public static void unwrap(Wrappee wrappee, Wrapper wrapper, AbstractMethodItem wrappedMethod)
The wrapper must implement wrappingMethod
. If
the wrapped method was not actually wrapped at the time this
method is called, then this code has no effect.
To definitively remove the wrapper so that none of its method
will not be considered as role methods anymore, use the
unwrap(Wrappee,ClassItem,Wrapper)
method.
wrappee
- the wrappee (can be null, then the wrappedMethod
must be static)wrapper
- the wrapperwrappedMethod
- the name of the method to unwrapunwrap(Wrappee,ClassItem,Wrapper)
public static void unwrapAll(Wrappee wrappee, ClassItem wrappeeClass, Wrapper wrapper)
public static boolean isWrappedBy(Wrappee wrappee, ClassItem wrappeeClass, Wrapper wrapper)
public static boolean isWrappedBy(Wrappee wrappee, ClassItem wrappeeClass, Class wrapperClass)
public static boolean isExtendedBy(Wrappee wrappee, ClassItem wrappeeClass, Class wrapperClass)
public static void addExceptionHandler(Wrappee wrappee, Wrapper wrapper, String method, AbstractMethodItem listenedMethod)
public static void addExceptionHandler(Wrappee wrappee, Wrapper wrapper, String method)
public static Object invokeRoleMethod(Wrappee wrappee, String methodName, Object[] parameters)
wrappee
- the wrappee (must be wrapped by a wrapper that
supports the role method)methodName
- the name of the role method to invoke.parameters
- the parameters.
invokeRoleMethod(Wrappee,Class,String,Object[])
public static Object invokeRoleMethod(Wrappee wrappee, Class wrapperClass, String methodName, Object[] parameters)
wrappee
- the wrappee (must be wrapped by a wrapper that
supports the role method).wrapperClass
- the class of the role method to invoke.methodName
- the name of the role method to invoke.parameters
- the parameters.
public static Object invokeRoleMethod(Wrappee wrappee, ClassItem wrappeeClass, Class wrapperClass, String methodName, Object[] parameters)
wrappee
- the wrappee (must be wrapped by a wrapper that
supports the role method).wrappeeClass
- the class of the wrapper (for static methods)wrapperClass
- the class of the role method to invoke.methodName
- the name of the role method to invoke.parameters
- the parameters.
public static Object invokeOrg(Wrappee wrappee, String name, Object[] parameters)
NOTE: avoid doing this unless you really know what you
are doing. It is not clean to shortcut the whole wrapping
chain. Instead, use the invoke
method or, if you
really need to,
AspectComponent.before/afterRunningWrapper()
to
skip some wrappers.
wrappee
- the object that supports the methodname
- the name of the method to callparameters
- the argument values
AspectComponent.beforeRunningWrapper(Wrapper,String)
,
AspectComponent.afterRunningWrapper(Wrapper,String)
public static Object invokeOrg(Wrappee wrappee, MethodItem method, Object[] parameters)
public static Object clone(Object org)
public static Object nextWrapper(Interaction interaction)
interaction
- the method call being interceptedpublic static Object methodNextWrapper(Interaction interaction)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |