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 021import org.springframework.lang.Nullable; 022 023/** 024 * Extension of the AOP Alliance {@link org.aopalliance.intercept.MethodInvocation} 025 * interface, allowing access to the proxy that the method invocation was made through. 026 * 027 * <p>Useful to be able to substitute return values with the proxy, 028 * if necessary, for example if the invocation target returned itself. 029 * 030 * @author Juergen Hoeller 031 * @author Adrian Colyer 032 * @since 1.1.3 033 * @see org.springframework.aop.framework.ReflectiveMethodInvocation 034 * @see org.springframework.aop.support.DelegatingIntroductionInterceptor 035 */ 036public interface ProxyMethodInvocation extends MethodInvocation { 037 038 /** 039 * Return the proxy that this method invocation was made through. 040 * @return the original proxy object 041 */ 042 Object getProxy(); 043 044 /** 045 * Create a clone of this object. If cloning is done before {@code proceed()} 046 * is invoked on this object, {@code proceed()} can be invoked once per clone 047 * to invoke the joinpoint (and the rest of the advice chain) more than once. 048 * @return an invocable clone of this invocation. 049 * {@code proceed()} can be called once per clone. 050 */ 051 MethodInvocation invocableClone(); 052 053 /** 054 * Create a clone of this object. If cloning is done before {@code proceed()} 055 * is invoked on this object, {@code proceed()} can be invoked once per clone 056 * to invoke the joinpoint (and the rest of the advice chain) more than once. 057 * @param arguments the arguments that the cloned invocation is supposed to use, 058 * overriding the original arguments 059 * @return an invocable clone of this invocation. 060 * {@code proceed()} can be called once per clone. 061 */ 062 MethodInvocation invocableClone(Object... arguments); 063 064 /** 065 * Set the arguments to be used on subsequent invocations in the any advice 066 * in this chain. 067 * @param arguments the argument array 068 */ 069 void setArguments(Object... arguments); 070 071 /** 072 * Add the specified user attribute with the given value to this invocation. 073 * <p>Such attributes are not used within the AOP framework itself. They are 074 * just kept as part of the invocation object, for use in special interceptors. 075 * @param key the name of the attribute 076 * @param value the value of the attribute, or {@code null} to reset it 077 */ 078 void setUserAttribute(String key, @Nullable Object value); 079 080 /** 081 * Return the value of the specified user attribute. 082 * @param key the name of the attribute 083 * @return the value of the attribute, or {@code null} if not set 084 * @see #setUserAttribute 085 */ 086 @Nullable 087 Object getUserAttribute(String key); 088 089}