Package org.apache.shiro.event.support
Class AnnotationEventListenerResolver
- java.lang.Object
-
- org.apache.shiro.event.support.AnnotationEventListenerResolver
-
- All Implemented Interfaces:
EventListenerResolver
public class AnnotationEventListenerResolver extends Object implements EventListenerResolver
Inspects an object for annotated methods of interest and creates anEventListener
instance for each method discovered. An event bus will call the resulting listeners as relevant events arrive. The defaultannotationClass
isSubscribe
, indicating eachSubscribe
-annotated method will be represented as an EventListener.- Since:
- 1.3
- See Also:
SingleArgumentMethodEventListener
-
-
Constructor Summary
Constructors Constructor Description AnnotationEventListenerResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<? extends Annotation>
getAnnotationClass()
Returns the type of annotation that indicates a method that should be represented as anEventListener
, defaults toSubscribe
.List<EventListener>
getEventListeners(Object instance)
Returns a new collection ofEventListener
instances, each instance corresponding to an annotated method discovered on the specifiedinstance
argument.void
setAnnotationClass(Class<? extends Annotation> annotationClass)
Sets the type of annotation that indicates a method that should be represented as anEventListener
.
-
-
-
Constructor Detail
-
AnnotationEventListenerResolver
public AnnotationEventListenerResolver()
-
-
Method Detail
-
getEventListeners
public List<EventListener> getEventListeners(Object instance)
Returns a new collection ofEventListener
instances, each instance corresponding to an annotated method discovered on the specifiedinstance
argument.- Specified by:
getEventListeners
in interfaceEventListenerResolver
- Parameters:
instance
- the instance to inspect for annotated event handler methods.- Returns:
- a new collection of
EventListener
instances, each instance corresponding to an annotated method discovered on the specifiedinstance
argument.
-
getAnnotationClass
public Class<? extends Annotation> getAnnotationClass()
Returns the type of annotation that indicates a method that should be represented as anEventListener
, defaults toSubscribe
.- Returns:
- the type of annotation that indicates a method that should be represented as an
EventListener
, defaults toSubscribe
.
-
setAnnotationClass
public void setAnnotationClass(Class<? extends Annotation> annotationClass)
Sets the type of annotation that indicates a method that should be represented as anEventListener
. The default value isSubscribe
.- Parameters:
annotationClass
- the type of annotation that indicates a method that should be represented as anEventListener
. The default value isSubscribe
.
-
-