File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/main/java/org/scijava Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 5858 * @author Curtis Rueden
5959 * @see Service
6060 */
61- public class Context implements Disposable {
61+ public class Context implements Disposable , AutoCloseable {
6262
6363 // -- Constants --
6464
@@ -248,6 +248,13 @@ public Context(final Collection<Class<? extends Service>> serviceClasses,
248248 * those of lower priority). See {@link ServiceHelper#loadServices()} for more
249249 * information.
250250 * </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>
251258 *
252259 * @param serviceClasses A collection of types that implement the
253260 * {@link Service} interface (e.g., {@code DisplayService.class}).
@@ -423,6 +430,13 @@ public void dispose() {
423430 }
424431 }
425432
433+ // -- AutoCloseable methods --
434+
435+ @ Override
436+ public void close () throws Exception {
437+ dispose ();
438+ }
439+
426440 // -- Utility methods --
427441
428442 /**
You can’t perform that action at this time.
0 commit comments