|
52 | 52 | public interface Service extends RichPlugin, Disposable { |
53 | 53 |
|
54 | 54 | /** |
55 | | - * Performs any needed initialization when the service is first loaded. |
| 55 | + * Registers the service's event handler methods. |
56 | 56 | * <p> |
57 | 57 | * NB: This method is not intended to be called directly. It is called by |
58 | 58 | * the service framework itself (specifically by the {@link ServiceHelper}) |
59 | 59 | * when initializing the service. It should not be called a second time. |
60 | 60 | * </p> |
61 | 61 | */ |
62 | | - default void initialize() { |
63 | | - // NB: Do nothing by default. |
| 62 | + default void registerEventHandlers() { |
| 63 | + // TODO: Consider removing this method in scijava-common 3.0.0. |
| 64 | + // Instead, the ServiceHelper could just invoke the lines below directly, |
| 65 | + // and there would be one less boilerplate Service method to implement. |
| 66 | + final EventService eventService = context().getService(EventService.class); |
| 67 | + if (eventService != null) eventService.subscribe(this); |
64 | 68 | } |
65 | 69 |
|
66 | 70 | /** |
67 | | - * Registers the service's event handler methods. |
| 71 | + * Performs any needed initialization when the service is first loaded. |
68 | 72 | * <p> |
69 | 73 | * NB: This method is not intended to be called directly. It is called by |
70 | 74 | * the service framework itself (specifically by the {@link ServiceHelper}) |
71 | 75 | * when initializing the service. It should not be called a second time. |
72 | 76 | * </p> |
73 | 77 | */ |
74 | | - default void registerEventHandlers() { |
75 | | - // TODO: Consider removing this method in scijava-common 3.0.0. |
76 | | - // Instead, the ServiceHelper could just invoke the lines below directly, |
77 | | - // and there would be one less boilerplate Service method to implement. |
78 | | - final EventService eventService = context().getService(EventService.class); |
79 | | - if (eventService != null) eventService.subscribe(this); |
| 78 | + default void initialize() { |
| 79 | + // NB: Do nothing by default. |
80 | 80 | } |
81 | | - |
82 | 81 | } |
0 commit comments