Skip to content

Commit cdf8788

Browse files
committed
Service: switch method declaration order
We do this mainly so the next commit is cleaner & easier to understand.
1 parent e5d37f0 commit cdf8788

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/main/java/org/scijava/service/Service.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,30 @@
5252
public interface Service extends RichPlugin, Disposable {
5353

5454
/**
55-
* Performs any needed initialization when the service is first loaded.
55+
* Registers the service's event handler methods.
5656
* <p>
5757
* NB: This method is not intended to be called directly. It is called by
5858
* the service framework itself (specifically by the {@link ServiceHelper})
5959
* when initializing the service. It should not be called a second time.
6060
* </p>
6161
*/
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);
6468
}
6569

6670
/**
67-
* Registers the service's event handler methods.
71+
* Performs any needed initialization when the service is first loaded.
6872
* <p>
6973
* NB: This method is not intended to be called directly. It is called by
7074
* the service framework itself (specifically by the {@link ServiceHelper})
7175
* when initializing the service. It should not be called a second time.
7276
* </p>
7377
*/
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.
8080
}
81-
8281
}

0 commit comments

Comments
 (0)