|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.Wrapper
This class is the root class for all the wrappers. A wrapper is part of a collaboration point when one or several of its methods wrap a base program object (a wrappee). The set of wrappers (methods) that wrap a wrappee (method) it called a wrapping (method) chain.
When a method call occurs on a wrappee, the system creates a new collaboration point in the current collaboration and all the wrappers are sequentially called.
A given wrapper passes the hand to the next wrapper (or to the
wrappee if last) by explicitly calling the proceed()
method.
For futher details about wrapping semantics, see the
Wrapper.proceed()
method and the
Wrappee.wrap()
methods.
Field Summary | |
protected AspectComponent |
ac
The AC of the wrapper. |
Constructor Summary | |
Wrapper(AspectComponent ac)
The constructor sets the aspect component that owns the wrapper from the context. |
Method Summary | |
Object |
attr(String name)
|
void |
attrdef(String name,
Object value)
|
static boolean |
defines(String methodName)
Returns true if the method is defined in the wrapper class. |
AspectComponent |
getAspectComponent()
Returns the Aspect Component the wrapper belongs to by resolving the name. |
String |
getAspectComponentName()
Returns the Aspect Component name the wrapper belongs to. |
static Vector |
getExceptionHandlers(Class wrapperClass)
Returns the exception handlers of the given wrapper class. |
Object |
proceed(Interaction interaction)
Run the next wrapper of the collaboration point. |
void |
setAspectComponent(AspectComponent ac)
Set the aspect component name that owns the wrapper. |
String |
toString()
String representation of a wrapper (eg {wrapper
className owned by aspectComponentName} ). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient AspectComponent ac
Constructor Detail |
public Wrapper(AspectComponent ac)
Method Detail |
public static boolean defines(String methodName)
methodName
- the method to test
public static Vector getExceptionHandlers(Class wrapperClass)
wrapperClass
- the wrapper class
public AspectComponent getAspectComponent()
getAspectComponentName()
public String getAspectComponentName()
Wrappee
public void setAspectComponent(AspectComponent ac)
ACManager
(see ACManager.get()
). This
method should not be called directly since the aspect component
is automatically set by the system when the wrap method is
called on a wrappee.
Wrappee
public String toString()
{wrapper
className owned by aspectComponentName}
).
toString
in class Object
public final Object proceed(Interaction interaction)
A new collaboration point is initiated by the system when a
method call occurs on a base program object (a wrappee). If the
called method is wrapped by one or several wrapping methods
(wrappers methods - see Wrappee.wrap()
), then the
system first upcalls all the wrapping methods.
A wrapping method is a regular Java method that takes no
argument and returns an object. It can access the currently
called method runtime caracteristics by using the
CollaborationParticipant
interface methods
implemented by the wrapper (see method()
or
args
).
The set of wrapping methods that wraps a wrappee method is
called a wrapping method chain. The wrapping methods of a
wrapping chain are sequentially called. A given wrapping method
of the wrapping chain passes the hand to the next wrapping
method of this chain by calling proceed()
.
A wrapper should ALWAYS call the proceed method except if it
delibaratly wants to replace all the upcoming wrappers and base
method functionalities (e.g. the
org.objectweb.jac.aspects.binding.ForwardingWrapper
).
The wrapping methods are called in a well-defined order. A
wrapper cannot change this order by himself since it is the
composition aspect that is responsible for setting this order
(see Wrappee.wrap()
and
CompositionAspect.getWeaveTimeRank()
).
Within a clean aspect-oriented design, the wrapper can be
shortcutted by its aspect component if needed (see
AspectComponent.beforeRunningWrapper()
).
In a wrapping method, proceed returns the value returned by
the wrappee method. A wrapper can modify this return value if
needed. The wrapping method code that is placed before the
proceed()
call is called before code (since
it is executed before the wrapped method execution), and the
code that is placed after the proceed call is called
after code (since it is executed after).
A typical wrapping method looks like the following:
public class MyWrapper { public Object myWrappingMethod() { // before code (can access the called method infos) ... Object result = proceed(); // after code (can modify the returned value) ... // must return a value (most of the time the proceed() value) return result; } }
Wrapping.wrap(Wrappee,Wrapper,String,AbstractMethodItem)
,
CollaborationParticipant
,
CompositionAspect.getWeaveTimeRank(WrappingChain,Wrapper,String)
,
AspectComponent.beforeRunningWrapper(Wrapper,String)
public final void attrdef(String name, Object value)
public final Object attr(String name)
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |