org.jboss.aop.joinpoint
Class MethodInvocation

java.lang.Object
  extended by org.jboss.aop.joinpoint.InvocationBase
      extended by org.jboss.aop.joinpoint.MethodInvocation
All Implemented Interfaces:
Externalizable, Serializable, Invocation
Direct Known Subclasses:
ContainerProxyMethodInvocation, MethodInvocationWrapper, ProxyMethodInvocation

public class MethodInvocation
extends InvocationBase
implements Externalizable

Version:
$Revision: 70849 $
Author:
Bill Burke
See Also:
Serialized Form

Field Summary
protected  Method advisedMethod
           
protected  Object[] arguments
          arguments of the method call expressed as an array of objects
protected  MarshalledObject marshalledArguments
           
protected  long methodHash
           
protected  Method unadvisedMethod
           
 
Fields inherited from class org.jboss.aop.joinpoint.InvocationBase
advisor, currentInterceptor, instanceResolver, interceptors, metadata, responseContextInfo, targetObject
 
Constructor Summary
  MethodInvocation()
           
protected MethodInvocation(Interceptor[] interceptors)
           
  MethodInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor)
           
  MethodInvocation(MethodInfo info, Interceptor[] interceptors)
           
 
Method Summary
 Invocation copy()
          Copies complete state of Invocation object.
 Method getActualMethod()
           
 Advisor getAdvisor()
           
 Object[] getArguments()
          Returns a non-null array containing all method arguments.
 Object getMetaData(Object group, Object attr)
          This method resolves metadata based on the context of the invocation.
 Method getMethod()
           
 long getMethodHash()
           
 Invocation getWrapper(Interceptor[] newchain)
          Returns a wrapper invocation object that can insert a new chain of interceptors at runtime to the invocation flow.
static Throwable handleErrors(Object target, Method method, Object[] arguments, Throwable t)
          Handle invocation errors
 Object invokeNext()
          Invoke on the next interceptor in the chain.
 Object invokeTarget()
          Invokes the target joinpoint for this invocation skipping any subsequent interceptors in the chain.
 void readExternal(ObjectInput in)
           
 Object resolveAnnotation(Class<? extends Annotation> annotation)
          This method resolves an annotation based on the context of the invocation.
 Object resolveAnnotation(Class<? extends Annotation>[] annotations)
          This method resolves an annotation based on the context of the invocation.
<T extends Annotation>
T
resolveTypedAnnotation(Class<T> annotation)
          Abstraction for resolving an annotation so that it can be overriden from the Method, Constructor, Field, etc.
<T extends Annotation>
T
resolveTypedAnnotation(Class<T>[] annotations)
          Abstraction for resolving an annotation so that it can be overriden from the Method, Constructor, Field, etc.
 void setArguments(Object[] arguments)
          Replaces method argument values by the ones contained in arguments.
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.jboss.aop.joinpoint.InvocationBase
addResponseAttachment, getCurrentInterceptor, getInstanceResolver, getInterceptors, getMetaData, getResponseAttachment, getResponseContextInfo, getTargetObject, invokeNext, resolveClassAnnotation, resolveClassMetaData, resolveTypedClassAnnotation, setAdvisor, setInstanceResolver, setMetaData, setResponseContextInfo, setTargetObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

arguments

protected Object[] arguments
arguments of the method call expressed as an array of objects


methodHash

protected long methodHash

marshalledArguments

protected MarshalledObject marshalledArguments

advisedMethod

protected Method advisedMethod

unadvisedMethod

protected Method unadvisedMethod
Constructor Detail

MethodInvocation

public MethodInvocation(MethodInfo info,
                        Interceptor[] interceptors)

MethodInvocation

public MethodInvocation(Interceptor[] interceptors,
                        long methodHash,
                        Method advisedMethod,
                        Method unadvisedMethod,
                        Advisor advisor)

MethodInvocation

protected MethodInvocation(Interceptor[] interceptors)

MethodInvocation

public MethodInvocation()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

invokeNext

public Object invokeNext()
                  throws Throwable
Invoke on the next interceptor in the chain. If this is already the end of the chain, reflection will call the constructor, field, or method you are invoking on.

Specified by:
invokeNext in interface Invocation
Overrides:
invokeNext in class InvocationBase
Throws:
Throwable

invokeTarget

public Object invokeTarget()
                    throws Throwable
Invokes the target joinpoint for this invocation skipping any subsequent interceptors in the chain.

Specified by:
invokeTarget in interface Invocation
Overrides:
invokeTarget in class InvocationBase
Throws:
Throwable

handleErrors

public static Throwable handleErrors(Object target,
                                     Method method,
                                     Object[] arguments,
                                     Throwable t)
                              throws Throwable
Handle invocation errors

Parameters:
target - the target
method - the method
arguments - the arguments
t - the error
Returns:
never
Throws:
Throwable - the throwable

resolveAnnotation

public Object resolveAnnotation(Class<? extends Annotation> annotation)
This method resolves an annotation based on the context of the invocation.

Specified by:
resolveAnnotation in interface Invocation
Overrides:
resolveAnnotation in class InvocationBase
Returns:

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
Description copied from interface: Invocation
Abstraction for resolving an annotation so that it can be overriden from the Method, Constructor, Field, etc.

Specified by:
resolveTypedAnnotation in interface Invocation
Overrides:
resolveTypedAnnotation in class InvocationBase
Returns:

resolveAnnotation

public Object resolveAnnotation(Class<? extends Annotation>[] annotations)
This method resolves an annotation based on the context of the invocation.

Specified by:
resolveAnnotation in interface Invocation
Overrides:
resolveAnnotation in class InvocationBase
Returns:

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Class<T>[] annotations)
Description copied from interface: Invocation
Abstraction for resolving an annotation so that it can be overriden from the Method, Constructor, Field, etc.

Specified by:
resolveTypedAnnotation in interface Invocation
Overrides:
resolveTypedAnnotation in class InvocationBase
Returns:

getMetaData

public Object getMetaData(Object group,
                          Object attr)
This method resolves metadata based on the context of the invocation. It iterates through its list of MetaDataResolvers to find out the value of the metadata desired.

This list usually is ThreadMetaData, InstanceAdvisor.getMetaData ClassAdvisor.getMethodMetaData (or field, or constructor) ClassAdvisor.getDefaultMetaData

Specified by:
getMetaData in interface Invocation
Overrides:
getMetaData in class InvocationBase

getWrapper

public Invocation getWrapper(Interceptor[] newchain)
Returns a wrapper invocation object that can insert a new chain of interceptors at runtime to the invocation flow. CFlow makes use of this. When the wrapper object finishes its invocation chain it delegates back to the wrapped invocation.

Specified by:
getWrapper in interface Invocation
Parameters:
newchain - chain of interceptors to be inserted on invocation
Returns:
an invocation wrapper

copy

public Invocation copy()
Copies complete state of Invocation object.

Specified by:
copy in interface Invocation
Returns:
a copy of this instance

getArguments

public Object[] getArguments()
Returns a non-null array containing all method arguments.

The returned array can be changed by the advice or interceptor accordingly. All changes are reflected on joinpoint execution, and are noticed as well by other advices and interceptors that are executed after the current one.
However, changes to this array are limited to the scope of current advice execution, and must be performed before execution of invokeNext(), InvocationBase.invokeNext(Interceptor[]), or invokeTarget() method. Otherwise, inconsistency on joinpoint argument values may be noticed.

Returns:
the method arguments

setArguments

public void setArguments(Object[] arguments)
Replaces method argument values by the ones contained in arguments.

Advices and interceptors must be aware that, for performance reasons, this array does not get copied across; its reference is directly used instead. Hence, changes to arguments array after this method being called are forbidden. Otherwise, inconsistency on joinpoint argument values may be noticed.

Parameters:
arguments - a non-null array containing the new values of method arguments. The size of this array must be the same as the one of getArguments(), as well as the element types.

getMethod

public Method getMethod()

getActualMethod

public Method getActualMethod()

getMethodHash

public long getMethodHash()

getAdvisor

public Advisor getAdvisor()
Specified by:
getAdvisor in interface Invocation
Overrides:
getAdvisor in class InvocationBase

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException


Copyright © 2008 JBoss, a division of Red Hat, Inc.. All Rights Reserved.