001/*
002 * Copyright 2002-2015 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.messaging.handler;
018
019import org.springframework.core.Ordered;
020
021/**
022 * Represents a Spring-managed bean with cross-cutting functionality to be
023 * applied to one or more Spring beans with annotation-based message
024 * handling methods.
025 *
026 * <p>Component stereotypes such as
027 * {@link org.springframework.stereotype.Controller @Controller} with annotation
028 * handler methods often need cross-cutting functionality across all or a subset
029 * of such annotated components. A primary example of this is the need for "global"
030 * annotated exception handler methods but the concept applies more generally.
031 *
032 * @author Rossen Stoyanchev
033 * @since 4.2
034 */
035public interface MessagingAdviceBean extends Ordered {
036
037        /**
038         * Return the type of the contained advice bean.
039         * <p>If the bean type is a CGLIB-generated class, the original user-defined
040         * class is returned.
041         */
042        Class<?> getBeanType();
043
044        /**
045         * Return the advice bean instance, if necessary resolving a bean specified
046         * by name through the BeanFactory.
047         */
048        Object resolveBean();
049
050        /**
051         * Whether this {@link MessagingAdviceBean} applies to the given bean type.
052         * @param beanType the type of the bean to check
053         */
054        boolean isApplicableToBeanType(Class<?> beanType);
055
056}