View Javadoc
1   package com.atlassian.plugin.event.impl;
2   
3   import com.atlassian.plugin.event.PluginEventListener;
4   
5   import java.lang.annotation.Annotation;
6   import java.lang.reflect.Method;
7   
8   /**
9    * Listener method selector that looks for a specific marker annotation
10   */
11  public class AnnotationListenerMethodSelector implements ListenerMethodSelector {
12      private final Class<? extends Annotation> markerAnnotation;
13  
14      public AnnotationListenerMethodSelector() {
15          this(PluginEventListener.class);
16      }
17  
18      public AnnotationListenerMethodSelector(Class<? extends Annotation> markerAnnotation) {
19          this.markerAnnotation = markerAnnotation;
20      }
21  
22      public boolean isListenerMethod(Method method) {
23          return (method.getAnnotation(markerAnnotation) != null);
24      }
25  }