View Javadoc
1   /*
2    * Copyright 2002-2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.aop;
18  
19  import org.aopalliance.intercept.MethodInvocation;
20  
21  /**
22   * Extension of the AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}
23   * interface, allowing access to the proxy that the method invocation was made through.
24   *
25   * <p>Useful to be able to substitute return values with the proxy,
26   * if necessary, for example if the invocation target returned itself.
27   *
28   * @author Juergen Hoeller
29   * @author Adrian Colyer
30   * @since 1.1.3
31   * @see org.springframework.aop.framework.ReflectiveMethodInvocation
32   * @see org.springframework.aop.support.DelegatingIntroductionInterceptor
33   */
34  public interface ProxyMethodInvocation extends MethodInvocation {
35  
36  	/**
37  	 * Return the proxy that this method invocation was made through.
38  	 * @return the original proxy object
39  	 */
40  	Object getProxy();
41  
42  	/**
43  	 * Create a clone of this object. If cloning is done before {@code proceed()}
44  	 * is invoked on this object, {@code proceed()} can be invoked once per clone
45  	 * to invoke the joinpoint (and the rest of the advice chain) more than once.
46  	 * @return an invocable clone of this invocation.
47  	 * {@code proceed()} can be called once per clone.
48  	 */
49  	MethodInvocation invocableClone();
50  
51  	/**
52  	 * Create a clone of this object. If cloning is done before {@code proceed()}
53  	 * is invoked on this object, {@code proceed()} can be invoked once per clone
54  	 * to invoke the joinpoint (and the rest of the advice chain) more than once.
55  	 * @param arguments the arguments that the cloned invocation is supposed to use,
56  	 * overriding the original arguments
57  	 * @return an invocable clone of this invocation.
58  	 * {@code proceed()} can be called once per clone.
59  	 */
60  	MethodInvocation invocableClone(Object[] arguments);
61  
62  	/**
63  	 * Set the arguments to be used on subsequent invocations in the any advice
64  	 * in this chain.
65  	 * @param arguments the argument array
66  	 */
67  	void setArguments(Object[] arguments);
68  
69  	/**
70  	 * Add the specified user attribute with the given value to this invocation.
71  	 * <p>Such attributes are not used within the AOP framework itself. They are
72  	 * just kept as part of the invocation object, for use in special interceptors.
73  	 * @param key the name of the attribute
74  	 * @param value the value of the attribute, or {@code null} to reset it
75  	 */
76  	void setUserAttribute(String key, Object value);
77  
78  	/**
79  	 * Return the value of the specified user attribute.
80  	 * @param key the name of the attribute
81  	 * @return the value of the attribute, or {@code null} if not set
82  	 * @see #setUserAttribute
83  	 */
84  	Object getUserAttribute(String key);
85  
86  }