org.springframework.aop.support.DelegatePerTargetObjectIntroductionInterceptor Maven / Gradle / Ivy
/*
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.aop.support;
import java.util.Map;
import java.util.WeakHashMap;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.DynamicIntroductionAdvice;
import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.ProxyMethodInvocation;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;
/**
* Convenient implementation of the
* {@link org.springframework.aop.IntroductionInterceptor} interface.
*
* This differs from {@link DelegatingIntroductionInterceptor} in that a single
* instance of this class can be used to advise multiple target objects, and each target
* object will have its own delegate (whereas DelegatingIntroductionInterceptor
* shares the same delegate, and hence the same state across all targets).
*
*
The {@code suppressInterface} method can be used to suppress interfaces
* implemented by the delegate class but which should not be introduced to the
* owning AOP proxy.
*
*
An instance of this class is serializable if the delegates are.
*
*
Note: There are some implementation similarities between this class and
* {@link DelegatingIntroductionInterceptor} that suggest a possible refactoring
* to extract a common ancestor class in the future.
*
* @author Adrian Colyer
* @author Juergen Hoeller
* @since 2.0
* @see #suppressInterface
* @see DelegatingIntroductionInterceptor
*/
@SuppressWarnings("serial")
public class DelegatePerTargetObjectIntroductionInterceptor extends IntroductionInfoSupport
implements IntroductionInterceptor {
/**
* Hold weak references to keys as we don't want to interfere with garbage collection..
*/
private final Map