001/*
002 * Copyright 2002-2012 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.aop.Advice;
020import org.aopalliance.intercept.MethodInterceptor;
021
022import org.springframework.aop.Advisor;
023
024/**
025 * Interface allowing extension to the Spring AOP framework to allow
026 * handling of new Advisors and Advice types.
027 *
028 * <p>Implementing objects can create AOP Alliance Interceptors from
029 * custom advice types, enabling these advice types to be used
030 * in the Spring AOP framework, which uses interception under the covers.
031 *
032 * <p>There is no need for most Spring users to implement this interface;
033 * do so only if you need to introduce more Advisor or Advice types to Spring.
034 *
035 * @author Rod Johnson
036 */
037public interface AdvisorAdapter {
038
039        /**
040         * Does this adapter understand this advice object? Is it valid to
041         * invoke the {@code getInterceptors} method with an Advisor that
042         * contains this advice as an argument?
043         * @param advice an Advice such as a BeforeAdvice
044         * @return whether this adapter understands the given advice object
045         * @see #getInterceptor(org.springframework.aop.Advisor)
046         * @see org.springframework.aop.BeforeAdvice
047         */
048        boolean supportsAdvice(Advice advice);
049
050        /**
051         * Return an AOP Alliance MethodInterceptor exposing the behavior of
052         * the given advice to an interception-based AOP framework.
053         * <p>Don't worry about any Pointcut contained in the Advisor;
054         * the AOP framework will take care of checking the pointcut.
055         * @param advisor the Advisor. The supportsAdvice() method must have
056         * returned true on this object
057         * @return an AOP Alliance interceptor for this Advisor. There's
058         * no need to cache instances for efficiency, as the AOP framework
059         * caches advice chains.
060         */
061        MethodInterceptor getInterceptor(Advisor advisor);
062
063}