View Javadoc

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