001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.aop;
018
019import org.aopalliance.intercept.MethodInvocation;
020
021/**
022 * Extension of the AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}
023 * interface, allowing access to the proxy that the method invocation was made through.
024 *
025 * <p>Useful to be able to substitute return values with the proxy,
026 * if necessary, for example if the invocation target returned itself.
027 *
028 * @author Juergen Hoeller
029 * @author Adrian Colyer
030 * @since 1.1.3
031 * @see org.springframework.aop.framework.ReflectiveMethodInvocation
032 * @see org.springframework.aop.support.DelegatingIntroductionInterceptor
033 */
034public interface ProxyMethodInvocation extends MethodInvocation {
035
036        /**
037         * Return the proxy that this method invocation was made through.
038         * @return the original proxy object
039         */
040        Object getProxy();
041
042        /**
043         * Create a clone of this object. If cloning is done before {@code proceed()}
044         * is invoked on this object, {@code proceed()} can be invoked once per clone
045         * to invoke the joinpoint (and the rest of the advice chain) more than once.
046         * @return an invocable clone of this invocation.
047         * {@code proceed()} can be called once per clone.
048         */
049        MethodInvocation invocableClone();
050
051        /**
052         * Create a clone of this object. If cloning is done before {@code proceed()}
053         * is invoked on this object, {@code proceed()} can be invoked once per clone
054         * to invoke the joinpoint (and the rest of the advice chain) more than once.
055         * @param arguments the arguments that the cloned invocation is supposed to use,
056         * overriding the original arguments
057         * @return an invocable clone of this invocation.
058         * {@code proceed()} can be called once per clone.
059         */
060        MethodInvocation invocableClone(Object... arguments);
061
062        /**
063         * Set the arguments to be used on subsequent invocations in the any advice
064         * in this chain.
065         * @param arguments the argument array
066         */
067        void setArguments(Object... arguments);
068
069        /**
070         * Add the specified user attribute with the given value to this invocation.
071         * <p>Such attributes are not used within the AOP framework itself. They are
072         * just kept as part of the invocation object, for use in special interceptors.
073         * @param key the name of the attribute
074         * @param value the value of the attribute, or {@code null} to reset it
075         */
076        void setUserAttribute(String key, Object value);
077
078        /**
079         * Return the value of the specified user attribute.
080         * @param key the name of the attribute
081         * @return the value of the attribute, or {@code null} if not set
082         * @see #setUserAttribute
083         */
084        Object getUserAttribute(String key);
085
086}