001/*
002 * Copyright 2002-2017 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 * @author Juergen Hoeller
035 */
036public interface Advisor {
037
038        /**
039         * Common placeholder for an empty {@code Advice} to be returned from
040         * {@link #getAdvice()} if no proper advice has been configured (yet).
041         * @since 5.0
042         */
043        Advice EMPTY_ADVICE = new Advice() {};
044
045
046        /**
047         * Return the advice part of this aspect. An advice may be an
048         * interceptor, a before advice, a throws advice, etc.
049         * @return the advice that should apply if the pointcut matches
050         * @see org.aopalliance.intercept.MethodInterceptor
051         * @see BeforeAdvice
052         * @see ThrowsAdvice
053         * @see AfterReturningAdvice
054         */
055        Advice getAdvice();
056
057        /**
058         * Return whether this advice is associated with a particular instance
059         * (for example, creating a mixin) or shared with all instances of
060         * the advised class obtained from the same Spring bean factory.
061         * <p><b>Note that this method is not currently used by the framework.</b>
062         * Typical Advisor implementations always return {@code true}.
063         * Use singleton/prototype bean definitions or appropriate programmatic
064         * proxy creation to ensure that Advisors have the correct lifecycle model.
065         * @return whether this advice is associated with a particular target instance
066         */
067        boolean isPerInstance();
068
069}