| Method from org.springframework.aop.framework.ReflectiveMethodInvocation Detail: |
public final Object[] getArguments() {
return (this.arguments != null ? this.arguments : new Object[0]);
}
|
public final Method getMethod() {
return this.method;
}
Return the method invoked on the proxied interface.
May or may not correspond with a method invoked on an underlying
implementation of that interface. |
public final Object getProxy() {
return this.proxy;
}
|
public final AccessibleObject getStaticPart() {
return this.method;
}
|
public final Object getThis() {
return this.target;
}
|
public Object getUserAttribute(String key) {
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
}
|
public Map getUserAttributes() {
if (this.userAttributes == null) {
this.userAttributes = new HashMap();
}
return this.userAttributes;
}
|
public MethodInvocation invocableClone() {
Object[] cloneArguments = null;
if (this.arguments != null) {
// Build an independent copy of the arguments array.
cloneArguments = new Object[this.arguments.length];
System.arraycopy(this.arguments, 0, cloneArguments, 0, this.arguments.length);
}
return invocableClone(cloneArguments);
}
This implementation returns a shallow copy of this invocation object,
including an independent copy of the original arguments array.
We want a shallow copy in this case: We want to use the same interceptor
chain and other object references, but we want an independent value for the
current interceptor index. |
public MethodInvocation invocableClone(Object[] arguments) {
// Force initialization of the user attributes Map,
// for having a shared Map reference in the clone.
if (this.userAttributes == null) {
this.userAttributes = new HashMap();
}
// Create the MethodInvocation clone.
try {
ReflectiveMethodInvocation clone = (ReflectiveMethodInvocation) clone();
clone.arguments = arguments;
return clone;
}
catch (CloneNotSupportedException ex) {
throw new IllegalStateException(
"Should be able to clone object of type [" + getClass() + "]: " + ex);
}
}
This implementation returns a shallow copy of this invocation object,
using the given arguments array for the clone.
We want a shallow copy in this case: We want to use the same interceptor
chain and other object references, but we want an independent value for the
current interceptor index. |
protected Object invokeJoinpoint() throws Throwable {
return AopUtils.invokeJoinpointUsingReflection(this.target, this.method, this.arguments);
}
Invoke the joinpoint using reflection.
Subclasses can override this to use custom invocation. |
public Object proceed() throws Throwable {
// We start with an index of -1 and increment early.
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
return invokeJoinpoint();
}
Object interceptorOrInterceptionAdvice =
this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex);
if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) {
// Evaluate dynamic method matcher here: static part will already have
// been evaluated and found to match.
InterceptorAndDynamicMethodMatcher dm =
(InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice;
if (dm.methodMatcher.matches(this.method, this.targetClass, this.arguments)) {
return dm.interceptor.invoke(this);
}
else {
// Dynamic matching failed.
// Skip this interceptor and invoke the next in the chain.
return proceed();
}
}
else {
// It's an interceptor, so we just invoke it: The pointcut will have
// been evaluated statically before this object was constructed.
return ((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this);
}
}
|
public void setArguments(Object[] arguments) {
this.arguments = arguments;
}
|
public void setUserAttribute(String key,
Object value) {
if (value != null) {
if (this.userAttributes == null) {
this.userAttributes = new HashMap();
}
this.userAttributes.put(key, value);
}
else {
if (this.userAttributes != null) {
this.userAttributes.remove(key);
}
}
}
|
public String toString() {
// Don't do toString on target, it may be proxied.
StringBuffer sb = new StringBuffer("ReflectiveMethodInvocation: ");
sb.append(this.method).append("; ");
if (this.target == null) {
sb.append("target is null");
}
else {
sb.append("target is of class [").append(this.target.getClass().getName()).append(']");
}
return sb.toString();
}
|