001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.shiro.event.support;
020
021import java.util.List;
022
023/**
024 * An {@code EventListenerResolver} knows how to resolve (either create or lookup) {@link EventListener} instances
025 * as a result of inspecting a subscriber object, mostly likely a
026 * {@link org.apache.shiro.event.Subscribe Subscribe}-annotated object instance.
027 * <p/>
028 * This interface exists primarily as a support concept for the {@link DefaultEventBus} implementation.  Custom
029 * implementations of this interface can be configured on a {@link DefaultEventBus} instance to determine exactly
030 * how a subscriber receives events.
031 * <p/>
032 * For example, the {@link AnnotationEventListenerResolver AnnotationEventListenerResolver} will inspect a runtime
033 * object for {@link org.apache.shiro.event.Subscribe Subscribe}-annotated methods, and for each method found, return
034 * an {@link EventListener} instance representing the method to invoke.
035 *
036 * @see AnnotationEventListenerResolver
037 * @see SingleArgumentMethodEventListener
038 * @since 1.3
039 */
040public interface EventListenerResolver {
041
042    /**
043     * Returns {@link EventListener} instances as a result of inspecting a subscriber object, mostly likely with
044     * {@link org.apache.shiro.event.Subscribe Subscribe}-annotated methods.
045     *
046     * @param instance the subscriber instance for which EventListener instances should be acquired.
047     * @return {@link EventListener} instances as a result of inspecting a subscriber object.
048     */
049    List<EventListener> getEventListeners(Object instance);
050}