1 package com.atlassian.event.api;
2
3 import java.lang.annotation.Documented;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.Target;
6 import java.util.Optional;
7
8 import static java.lang.annotation.ElementType.METHOD;
9 import static java.lang.annotation.RetentionPolicy.RUNTIME;
10
11 /**
12 * Used to annotate event listener methods. Methods should be public and take
13 * one parameter which is the event to be handled.
14 * <p>
15 * For example, the following class implements a simple event listener:
16 * <pre><tt> public class TestListener {
17 * @EventListener
18 * public void onEvent(SampleEvent event) {
19 * System.out.println("Handled an event: " + event);
20 * }
21 * }
22 * </tt></pre>
23 *
24 * @see com.atlassian.event.internal.AnnotatedMethodsListenerHandler
25 * @since 2.0
26 */
27 @Retention(RUNTIME)
28 @Target(METHOD)
29 @Documented
30 public @interface EventListener {
31 String scope() default "";
32 }