File tree 1 file changed +15
-1
lines changed
src/main/java/org/scijava
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 58
58
* @author Curtis Rueden
59
59
* @see Service
60
60
*/
61
- public class Context implements Disposable {
61
+ public class Context implements Disposable , AutoCloseable {
62
62
63
63
// -- Constants --
64
64
@@ -248,6 +248,13 @@ public Context(final Collection<Class<? extends Service>> serviceClasses,
248
248
* those of lower priority). See {@link ServiceHelper#loadServices()} for more
249
249
* information.
250
250
* </p>
251
+ * <p>
252
+ * NB: Instiantiation of a Context has an implied requirement of a
253
+ * corresponding call to {@link Context#dispose()} at the end of the SciJava
254
+ * applicaton's lifecycle. This cleans up any remaining resources and allows
255
+ * the JVM to exit gracefully. This is called automatically when constructed as
256
+ * an {@link AutoCloseable}.
257
+ * </p>
251
258
*
252
259
* @param serviceClasses A collection of types that implement the
253
260
* {@link Service} interface (e.g., {@code DisplayService.class}).
@@ -423,6 +430,13 @@ public void dispose() {
423
430
}
424
431
}
425
432
433
+ // -- AutoCloseable methods --
434
+
435
+ @ Override
436
+ public void close () throws Exception {
437
+ dispose ();
438
+ }
439
+
426
440
// -- Utility methods --
427
441
428
442
/**
You can’t perform that action at this time.
0 commit comments