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