org.objectweb.jac.wrappers
Class ForwardingWrapper

java.lang.Object
  extended byorg.objectweb.jac.core.Wrapper
      extended byorg.objectweb.jac.wrappers.ForwardingWrapper
All Implemented Interfaces:
Advice, ConstructorInterceptor, Interceptor, MethodInterceptor, Serializable

public class ForwardingWrapper
extends Wrapper

This wrapper forwards the method calls that arrive on the wrappee to another object. The wrapped methods should be supported both by the wrappee and the forwardee. Otherwise, an exception is raised.

Author:
Renaud Pawlak
See Also:
ForwardingException, Serialized Form

Field Summary
protected  Object forwardee
          The forwardee.
 
Fields inherited from class org.objectweb.jac.core.Wrapper
ac, cr
 
Constructor Summary
ForwardingWrapper(AspectComponent ac, Object forwardee)
          Construct a new forwarding wrapper.
 
Method Summary
 Object construct(ConstructorInvocation invocation)
           
 Object forward(Interaction interaction)
          Forwards all the incoming calls to the forwardee.
 Object getForwardee()
          The getter method for the forwardee.
 Object invoke(MethodInvocation invocation)
           
 
Methods inherited from class org.objectweb.jac.core.Wrapper
attr, attrdef, defines, getAspectComponent, getAspectComponentName, getExceptionHandlers, proceed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

forwardee

protected Object forwardee
The forwardee.

Constructor Detail

ForwardingWrapper

public ForwardingWrapper(AspectComponent ac,
                         Object forwardee)
Construct a new forwarding wrapper.

Parameters:
forwardee - the object that receives the forwarded calls
Method Detail

getForwardee

public Object getForwardee()
The getter method for the forwardee.

Returns:
the object to which the calls are forwarded
See Also:
forward(Interaction)

forward

public Object forward(Interaction interaction)
               throws ForwardingException
Forwards all the incoming calls to the forwardee.

The forwardee class must support the wrapped method prototype. Otherwise, an exception is raised.

Returns:
the result of the forwarded method call
Throws:
ForwardingException

invoke

public Object invoke(MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface MethodInterceptor
Overrides:
invoke in class Wrapper
Throws:
Throwable

construct

public Object construct(ConstructorInvocation invocation)
                 throws Throwable
Specified by:
construct in interface ConstructorInterceptor
Overrides:
construct in class Wrapper
Throws:
Throwable