001/* 002 * Copyright 2002-2018 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.framework.adapter; 018 019import org.aopalliance.intercept.MethodInterceptor; 020 021import org.springframework.aop.Advisor; 022 023/** 024 * Interface for registries of Advisor adapters. 025 * 026 * <p><i>This is an SPI interface, not to be implemented by any Spring user.</i> 027 * 028 * @author Rod Johnson 029 * @author Rob Harrop 030 */ 031public interface AdvisorAdapterRegistry { 032 033 /** 034 * Return an {@link Advisor} wrapping the given advice. 035 * <p>Should by default at least support 036 * {@link org.aopalliance.intercept.MethodInterceptor}, 037 * {@link org.springframework.aop.MethodBeforeAdvice}, 038 * {@link org.springframework.aop.AfterReturningAdvice}, 039 * {@link org.springframework.aop.ThrowsAdvice}. 040 * @param advice object that should be an advice 041 * @return an Advisor wrapping the given advice (never {@code null}; 042 * if the advice parameter is an Advisor, it is to be returned as-is) 043 * @throws UnknownAdviceTypeException if no registered advisor adapter 044 * can wrap the supposed advice 045 */ 046 Advisor wrap(Object advice) throws UnknownAdviceTypeException; 047 048 /** 049 * Return an array of AOP Alliance MethodInterceptors to allow use of the 050 * given Advisor in an interception-based framework. 051 * <p>Don't worry about the pointcut associated with the {@link Advisor}, if it is 052 * a {@link org.springframework.aop.PointcutAdvisor}: just return an interceptor. 053 * @param advisor Advisor to find an interceptor for 054 * @return an array of MethodInterceptors to expose this Advisor's behavior 055 * @throws UnknownAdviceTypeException if the Advisor type is 056 * not understood by any registered AdvisorAdapter 057 */ 058 MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException; 059 060 /** 061 * Register the given {@link AdvisorAdapter}. Note that it is not necessary to register 062 * adapters for an AOP Alliance Interceptors or Spring Advices: these must be 063 * automatically recognized by an {@code AdvisorAdapterRegistry} implementation. 064 * @param adapter AdvisorAdapter that understands particular Advisor or Advice types 065 */ 066 void registerAdvisorAdapter(AdvisorAdapter adapter); 067 068}