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; 018 019import org.aopalliance.aop.Advice; 020 021/** 022 * Base interface holding AOP <b>advice</b> (action to take at a joinpoint) 023 * and a filter determining the applicability of the advice (such as 024 * a pointcut). <i>This interface is not for use by Spring users, but to 025 * allow for commonality in support for different types of advice.</i> 026 * 027 * <p>Spring AOP is based around <b>around advice</b> delivered via method 028 * <b>interception</b>, compliant with the AOP Alliance interception API. 029 * The Advisor interface allows support for different types of advice, 030 * such as <b>before</b> and <b>after</b> advice, which need not be 031 * implemented using interception. 032 * 033 * @author Rod Johnson 034 */ 035public interface Advisor { 036 037 /** 038 * Return the advice part of this aspect. An advice may be an 039 * interceptor, a before advice, a throws advice, etc. 040 * @return the advice that should apply if the pointcut matches 041 * @see org.aopalliance.intercept.MethodInterceptor 042 * @see BeforeAdvice 043 * @see ThrowsAdvice 044 * @see AfterReturningAdvice 045 */ 046 Advice getAdvice(); 047 048 /** 049 * Return whether this advice is associated with a particular instance 050 * (for example, creating a mixin) or shared with all instances of 051 * the advised class obtained from the same Spring bean factory. 052 * <p><b>Note that this method is not currently used by the framework.</b> 053 * Typical Advisor implementations always return {@code true}. 054 * Use singleton/prototype bean definitions or appropriate programmatic 055 * proxy creation to ensure that Advisors have the correct lifecycle model. 056 * @return whether this advice is associated with a particular target instance 057 */ 058 boolean isPerInstance(); 059 060}