diff --git a/.github/build.sh b/.github/build.sh
new file mode 100755
index 000000000..523abeb87
--- /dev/null
+++ b/.github/build.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-build.sh
+sh ci-build.sh
diff --git a/.github/setup.sh b/.github/setup.sh
new file mode 100755
index 000000000..0ebca586f
--- /dev/null
+++ b/.github/setup.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-setup-github-actions.sh
+sh ci-setup-github-actions.sh
+
+# Let the Linux build handle artifact deployment.
+if [ "$(uname)" != Linux ]
+then
+ echo "No deploy -- non-Linux build"
+ echo "NO_DEPLOY=1" >> $GITHUB_ENV
+fi
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 000000000..c0ac58830
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,42 @@
+name: build
+
+on:
+ push:
+ branches:
+ - main
+ tags:
+ - "*-[0-9]+.*"
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ build:
+ name: build-${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, windows-latest, macos-latest]
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Java
+ uses: actions/setup-java@v4
+ with:
+ java-version: '11'
+ distribution: 'zulu'
+ cache: 'maven'
+ - name: Set up CI environment
+ run: .github/setup.sh
+ shell: bash
+ - name: Execute the build
+ run: .github/build.sh
+ shell: bash
+ env:
+ GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
+ GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
+ MAVEN_USER: ${{ secrets.MAVEN_USER }}
+ MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
+ CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
+ CENTRAL_PASS: ${{ secrets.CENTRAL_PASS }}
+ SIGNING_ASC: ${{ secrets.SIGNING_ASC }}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 3bc57c558..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: java
-jdk: openjdk8
-branches:
- only:
- - master
- - "/.*-[0-9]+\\..*/"
-install: true
-script: ".travis/build.sh"
-cache:
- directories:
- - "~/.m2/repository"
-env:
- global:
- - secure: Xkwu2u/v0+kBqW2Mt80FpMS+2NRMnfRaZ6ptiEW44sViKkaENnJegmYVjdSm9RAwAJx9DEp6KYTLH4Hh56JbWp6s8qGcxm2vCbAWBE6ZesOj3oTvv/T4lucxarocZ8hK9NqfY9iCePjl8R10UDePThZgWBFidUQjvPbH+LcXo9g=
- - secure: Jgj204N4hKv+7sUrXGtXMvUoXYuHAerhUvwbHsm0BJFpzUSyHP5QWJH2tHvCUL9Yb4VhNEjc46RLFVmiIXynJwAdAWJodT/VEnOTb5Cf7+0UHK4qCyjyjVHiWq1cf+R8Lr9fuKRqxUAdz9Hw6g0Yt23TX8kCa+wQW9lwchn0IG8=
- - secure: RuGzuPrxyvBRJwsCpSJ10p9PdP2Hzc9lxb29L//Y/Fkc3bJwNMlNa0ST83oGNHJapYc4dWuFk22Ooy/2YioNgsVvR4n5MAslqXQXSY0VDle1Nbf1pudAlPU+quaiYxcAyyysjUUtqc5wADVgpkrDA7GJzAuCOWb4aSwiiIn6u4A=
- - secure: bnsjVlj9MBJto8ahZdMwGpVPjZeyF7r5tZh+t+NhDuZsP0WMlURzGZ9/lJOO4quklgiWCyeVDB5uvDvsdG9BReBe5Q8Q6WZyxhxYtP2iLV0zRWSWsGKk0stGcrmJKk8wbicIJdXD8suiP+2Li5GfxTge/hkhL4CL0OOr6b1JqrM=
diff --git a/.travis/build.sh b/.travis/build.sh
deleted file mode 100755
index 094a570ee..000000000
--- a/.travis/build.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/master/travis-build.sh
-sh travis-build.sh $encrypted_d2fbfc37eea9_key $encrypted_d2fbfc37eea9_iv
diff --git a/.travis/signingkey.asc.enc b/.travis/signingkey.asc.enc
deleted file mode 100644
index 4e4802b46..000000000
Binary files a/.travis/signingkey.asc.enc and /dev/null differ
diff --git a/LICENSE.txt b/LICENSE.txt
index 7d75d811c..55024a7c5 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2009 - 2020, SciJava developers.
+Copyright (c) 2009 - 2026, SciJava developers.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/NOTICE.txt b/NOTICE.txt
index 74385d300..5b605b01d 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,11 +1,12 @@
This project contains code adapted from Apache Commons Lang
(https://commons.apache.org/proper/commons-lang/) version 3.4,
as well as GenTyRef (https://github.com/coekie/gentyref) version 1.1.0,
-both of which are licensed under the Apache 2.0 license, as follows:
+and EventBus (https://github.com/michaelbushe/EventBus) version 1.4,
+each of which is licensed under the Apache 2.0 license, as follows:
Apache License
Version 2.0, January 2004
- http://www.apache.org/licenses/
+ https://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
@@ -197,7 +198,7 @@ both of which are licensed under the Apache 2.0 license, as follows:
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/README.md b/README.md
index 0838f7b7b..ba1f15173 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
-[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.scijava%22%20AND%20a%3A%22scijava-common%22)
-[](https://travis-ci.org/scijava/scijava-common)
-[](https://gitter.im/scijava/scijava-common?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.scijava%22%20AND%20a%3A%22scijava-common%22)
+[](https://github.com/scijava/scijava-common/actions/workflows/build.yml)
+[](https://imagesc.zulipchat.com/#narrow/stream/327237-SciJava)
SciJava Common is a common library for SciJava software. It provides a
plugin framework, with an extensible mechanism for service discovery, backed
by its own annotation processor, so that plugins can be loaded dynamically.
-It is used by both [ImageJ](https://github.com/imagej/imagej) and
+It is used by both [ImageJ2](https://github.com/imagej/imagej2) and
[SCIFIO](https://github.com/scifio/scifio).
diff --git a/pom.xml b/pom.xml
index ed7bd2a5f..771234c9d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,16 +1,16 @@
-
+4.0.0org.scijavapom-scijava
- 28.0.0
+ 44.0.0scijava-common
- 2.83.4-SNAPSHOT
+ 2.100.2-SNAPSHOTSciJava CommonSciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by downstream projects in the SciJava ecosystem, such as ImageJ and SCIFIO.
@@ -31,7 +31,7 @@
ctruedenCurtis Rueden
- https://imagej.net/User:Rueden
+ https://imagej.net/people/ctruedenfounderlead
@@ -46,86 +46,99 @@
Mark Hiner
- https://imagej.net/User:Hinerm
+ https://imagej.net/people/hinermfounderhinermJohannes Schindelin
- https://imagej.net/User:Schindelin
+ https://imagej.net/people/dschodschoChris Allanchris-allan
+
+ Nicolas Chiaruttini
+ https://imagej.net/people/NicoKiaru
+ NicoKiaru
+ Barry DeZonia
- https://imagej.net/User:Bdezonia
+ https://imagej.net/people/bdezoniabdezoniaChristian Dietz
- https://imagej.net/User:Dietzc
+ https://imagej.net/people/dietzcdietzcRichard Domander
- https://imagej.net/User:Rdom
+ https://imagej.net/people/rimadomarimadomaGabriel Einsdorf
- https://imagej.net/User:Gab1one
+ https://imagej.net/people/gab1onegab1oneAivar Grislis
- https://imagej.net/User:Grislis
+ https://imagej.net/people/grislisgrislisJonathan Hale
+ https://imagej.net/people/SquareysSquareysGrant Harris
- https://imagej.net/User:Harris
+ https://imagej.net/people/tnargsirrahtnargsirrahLee Kamentsky
- https://imagej.net/User:Leek
+ https://imagej.net/people/LeeKamentskyLeeKamentskyRick Lentz
- https://imagej.net/User:Lentz
+ https://imagej.net/people/ricklentz
+ ricklentzMelissa Linkert
- https://imagej.net/User:Linkert
+ https://imagej.net/people/melissalinkertmelissalinkertKevin Mader
- https://imagej.net/User:Ksmader
+ https://imagej.net/people/kmaderkmaderHadrien Mary
- https://imagej.net/User:Hadim
+ https://imagej.net/people/hadimhadimAlison Walter
- https://imagej.net/User:Awalter2
+ https://imagej.net/people/awalter17awalter17Jay Warrick
+ https://imagej.net/people/jaywarrickjaywarrick
+
+ Christian Tischer
+ https://imagej.net/people/tischi
+ tischi
+
@@ -139,7 +152,7 @@
- scm:git:git://github.com/scijava/scijava-common
+ scm:git:https://github.com/scijava/scijava-commonscm:git:git@github.com:scijava/scijava-commonHEADhttps://github.com/scijava/scijava-common
@@ -149,18 +162,22 @@
https://github.com/scijava/scijava-common/issues
- Travis CI
- https://travis-ci.org/scijava/scijava-common
+ GitHub Actions
+ https://github.com/scijava/scijava-common/actionsorg.scijava
+ 8
+ 11bsd_2SciJava Common shared library for SciJava software.SciJava developers.
+ **/bushe/**
- 2.0.0
+
+ 2.22.2
@@ -170,13 +187,6 @@
parsington
-
-
- org.bushe
- eventbus
- 1.4
-
-
junit
@@ -187,7 +197,7 @@
org.mockitomockito-coretest
-
+
@@ -215,11 +225,22 @@
exec-maven-plugin
+ index-annotationsprocess-classesjava
+
+ index-test-annotations
+ process-test-classes
+
+ java
+
+
+ test
+
+ org.scijava.annotations.EclipseHelper
diff --git a/src/it/apt-test/pom.xml b/src/it/apt-test/pom.xml
index f250325d7..c416a3860 100644
--- a/src/it/apt-test/pom.xml
+++ b/src/it/apt-test/pom.xml
@@ -3,7 +3,7 @@
#%L
SciJava Common shared library for SciJava software.
%%
- Copyright (C) 2009 - 2020 SciJava developers.
+ Copyright (C) 2009 - 2026 SciJava developers.
%%
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -31,7 +31,7 @@
+ https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0@project.groupId@
diff --git a/src/it/apt-test/setup.bsh b/src/it/apt-test/setup.bsh
index a2a1dab92..30380371c 100644
--- a/src/it/apt-test/setup.bsh
+++ b/src/it/apt-test/setup.bsh
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java b/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java
index d7322e748..2d9e5d420 100644
--- a/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java
+++ b/src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java b/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java
index bf204259b..1b456f1c3 100644
--- a/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java
+++ b/src/it/apt-test/src/main/java/org/scijava/annotation/its/CustomAnnotation.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/it/apt-test/verify.bsh b/src/it/apt-test/verify.bsh
index 66d036d7b..679bbf6ed 100644
--- a/src/it/apt-test/verify.bsh
+++ b/src/it/apt-test/verify.bsh
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/it/settings.xml b/src/it/settings.xml
index d5b5c19c7..b3042e9e1 100644
--- a/src/it/settings.xml
+++ b/src/it/settings.xml
@@ -3,7 +3,7 @@
#%L
SciJava Common shared library for SciJava software.
%%
- Copyright (C) 2009 - 2020 SciJava developers.
+ Copyright (C) 2009 - 2026 SciJava developers.
%%
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/AbstractBasicDetails.java b/src/main/java/org/scijava/AbstractBasicDetails.java
index e8f52a049..75e28c611 100644
--- a/src/main/java/org/scijava/AbstractBasicDetails.java
+++ b/src/main/java/org/scijava/AbstractBasicDetails.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/AbstractContextual.java b/src/main/java/org/scijava/AbstractContextual.java
index 647ea1d97..6d47180bf 100644
--- a/src/main/java/org/scijava/AbstractContextual.java
+++ b/src/main/java/org/scijava/AbstractContextual.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/AbstractGateway.java b/src/main/java/org/scijava/AbstractGateway.java
index 5c3dbd446..14f066a7f 100644
--- a/src/main/java/org/scijava/AbstractGateway.java
+++ b/src/main/java/org/scijava/AbstractGateway.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -42,6 +42,7 @@
import org.scijava.input.InputService;
import org.scijava.io.IOService;
import org.scijava.io.RecentFileService;
+import org.scijava.io.location.LocationService;
import org.scijava.log.LogService;
import org.scijava.main.MainService;
import org.scijava.menu.MenuService;
@@ -190,6 +191,11 @@ public InputService input() {
public IOService io() {
return get(IOService.class);
}
+
+ @Override
+ public LocationService location() {
+ return get(LocationService.class);
+ }
@Override
public LogService log() {
diff --git a/src/main/java/org/scijava/AbstractUIDetails.java b/src/main/java/org/scijava/AbstractUIDetails.java
index 3d86efba7..11476a03a 100644
--- a/src/main/java/org/scijava/AbstractUIDetails.java
+++ b/src/main/java/org/scijava/AbstractUIDetails.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/BasicDetails.java b/src/main/java/org/scijava/BasicDetails.java
index 454929e6b..6c37807e6 100644
--- a/src/main/java/org/scijava/BasicDetails.java
+++ b/src/main/java/org/scijava/BasicDetails.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Cancelable.java b/src/main/java/org/scijava/Cancelable.java
index 968b66586..5bc0fe61c 100644
--- a/src/main/java/org/scijava/Cancelable.java
+++ b/src/main/java/org/scijava/Cancelable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Context.java b/src/main/java/org/scijava/Context.java
index 638230db1..bfb118099 100644
--- a/src/main/java/org/scijava/Context.java
+++ b/src/main/java/org/scijava/Context.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -33,11 +33,15 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.scijava.event.ContextCreatedEvent;
import org.scijava.event.ContextDisposingEvent;
import org.scijava.event.EventHandler;
import org.scijava.event.EventService;
@@ -58,7 +62,7 @@
* @author Curtis Rueden
* @see Service
*/
-public class Context implements Disposable {
+public class Context implements Disposable, AutoCloseable {
// -- Constants --
@@ -72,6 +76,14 @@ public class Context implements Disposable {
*/
public static final String STRICT_PROPERTY = "scijava.context.strict";
+ /** Set of currently active (not disposed) application contexts. */
+ private static final Map CONTEXTS =
+ new ConcurrentHashMap<>(); // NB: ConcurrentHashMap disallows nulls.
+
+ // -- Static fields --
+
+ private static Thread shutdownThread = null;
+
// -- Fields --
/** Index of the application context's services. */
@@ -97,6 +109,12 @@ public class Context implements Disposable {
*/
private boolean strict;
+ /**
+ * False if the context is currently active; true if the context
+ * has already been disposed, or is in the process of being disposed.
+ */
+ private boolean disposed;
+
/**
* Creates a new SciJava application context with all available services.
*
@@ -248,6 +266,13 @@ public Context(final Collection> serviceClasses,
* those of lower priority). See {@link ServiceHelper#loadServices()} for more
* information.
*
+ *
+ * NB: Instiantiation of a Context has an implied requirement of a
+ * corresponding call to {@link Context#dispose()} at the end of the SciJava
+ * applicaton's lifecycle. This cleans up any remaining resources and allows
+ * the JVM to exit gracefully. This is called automatically when constructed as
+ * an {@link AutoCloseable}.
+ *
*
* @param serviceClasses A collection of types that implement the
* {@link Service} interface (e.g., {@code DisplayService.class}).
@@ -277,6 +302,26 @@ public Context(final Collection> serviceClasses,
new ServiceHelper(this, serviceClasses, strict);
serviceHelper.loadServices();
}
+
+ // If JVM shuts down with context still active, clean up after ourselves.
+ if (shutdownThread == null) {
+ synchronized (Context.class) {
+ if (shutdownThread == null) {
+ shutdownThread = new Thread(() -> {
+ final List contexts = new ArrayList<>(CONTEXTS.keySet());
+ for (final Context context : contexts) {
+ context.doDispose(false);
+ }
+ });
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
+ }
+ }
+ }
+ CONTEXTS.put(this, true);
+
+ // Publish an event to indicate that context initialization is complete.
+ final EventService eventService = getService(EventService.class);
+ if (eventService != null) eventService.publish(new ContextCreatedEvent());
}
// -- Context methods --
@@ -411,16 +456,14 @@ public boolean isInjectable(final Class> type) {
@Override
public void dispose() {
- final EventService eventService = getService(EventService.class);
- if (eventService != null) eventService.publish(new ContextDisposingEvent());
+ doDispose(true);
+ }
- // NB: Dispose services in reverse order.
- // This may or may not actually be necessary, but seems safer, since
- // dependent services will be disposed *before* their dependencies.
- final List services = serviceIndex.getAll();
- for (int s = services.size() - 1; s >= 0; s--) {
- services.get(s).dispose();
- }
+ // -- AutoCloseable methods --
+
+ @Override
+ public void close() {
+ dispose();
}
// -- Utility methods --
@@ -445,7 +488,8 @@ public static List> serviceClassList(
* @see ClassLoader#getSystemClassLoader()
*/
public static ClassLoader getClassLoader() {
- final ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextCL = Thread.currentThread()
+ .getContextClassLoader();
return contextCL != null ? contextCL : ClassLoader.getSystemClassLoader();
}
@@ -565,13 +609,31 @@ private String createMissingServiceMessage(
return msg.toString();
}
+ private synchronized void doDispose(final boolean announce) {
+ if (disposed) return;
+ disposed = true;
+ CONTEXTS.remove(this);
+ if (announce) {
+ final EventService eventService = getService(EventService.class);
+ if (eventService != null) eventService.publish(new ContextDisposingEvent());
+ }
+
+ // NB: Dispose services in reverse order.
+ // This may or may not actually be necessary, but seems safer, since
+ // dependent services will be disposed *before* their dependencies.
+ final List services = serviceIndex.getAll();
+ for (int s = services.size() - 1; s >= 0; s--) {
+ services.get(s).dispose();
+ }
+ }
+
private static PluginIndex plugins(final boolean empty) {
return empty ? new PluginIndex(null) : null;
}
private static List> services(final boolean empty) {
- if (empty) return Collections.>emptyList();
- return Arrays.>asList(Service.class);
+ if (empty) return Collections.> emptyList();
+ return Arrays.> asList(Service.class);
}
private static boolean strict() {
diff --git a/src/main/java/org/scijava/Contextual.java b/src/main/java/org/scijava/Contextual.java
index 416f03ff9..f76c7fc0d 100644
--- a/src/main/java/org/scijava/Contextual.java
+++ b/src/main/java/org/scijava/Contextual.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Disposable.java b/src/main/java/org/scijava/Disposable.java
index df22b8ec8..ac72c90b4 100644
--- a/src/main/java/org/scijava/Disposable.java
+++ b/src/main/java/org/scijava/Disposable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Gateway.java b/src/main/java/org/scijava/Gateway.java
index 59fe12810..7cd98413e 100644
--- a/src/main/java/org/scijava/Gateway.java
+++ b/src/main/java/org/scijava/Gateway.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -40,6 +40,7 @@
import org.scijava.input.InputService;
import org.scijava.io.IOService;
import org.scijava.io.RecentFileService;
+import org.scijava.io.location.LocationService;
import org.scijava.log.LogService;
import org.scijava.main.MainService;
import org.scijava.menu.MenuService;
@@ -238,6 +239,13 @@ public interface Gateway extends RichPlugin, Disposable {
*/
IOService io();
+ /**
+ * Gets this application context's {@link LocationService}.
+ *
+ * @return The {@link LocationService} of this application context.
+ */
+ LocationService location();
+
/**
* Gets this application context's {@link LogService}.
*
diff --git a/src/main/java/org/scijava/Identifiable.java b/src/main/java/org/scijava/Identifiable.java
index 512d69b11..53db16039 100644
--- a/src/main/java/org/scijava/Identifiable.java
+++ b/src/main/java/org/scijava/Identifiable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Initializable.java b/src/main/java/org/scijava/Initializable.java
index efa9854ab..56aa725ae 100644
--- a/src/main/java/org/scijava/Initializable.java
+++ b/src/main/java/org/scijava/Initializable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Instantiable.java b/src/main/java/org/scijava/Instantiable.java
index 85480ad34..3edca09a4 100644
--- a/src/main/java/org/scijava/Instantiable.java
+++ b/src/main/java/org/scijava/Instantiable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/InstantiableException.java b/src/main/java/org/scijava/InstantiableException.java
index c3904f7b4..0ad031f7b 100644
--- a/src/main/java/org/scijava/InstantiableException.java
+++ b/src/main/java/org/scijava/InstantiableException.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/ItemIO.java b/src/main/java/org/scijava/ItemIO.java
index eacc23958..fa8b68684 100644
--- a/src/main/java/org/scijava/ItemIO.java
+++ b/src/main/java/org/scijava/ItemIO.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/ItemVisibility.java b/src/main/java/org/scijava/ItemVisibility.java
index 749e91ae3..47897a359 100644
--- a/src/main/java/org/scijava/ItemVisibility.java
+++ b/src/main/java/org/scijava/ItemVisibility.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Locatable.java b/src/main/java/org/scijava/Locatable.java
index e855158ab..a7da30625 100644
--- a/src/main/java/org/scijava/Locatable.java
+++ b/src/main/java/org/scijava/Locatable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/MenuEntry.java b/src/main/java/org/scijava/MenuEntry.java
index d8ca1961a..4a2b33bb9 100644
--- a/src/main/java/org/scijava/MenuEntry.java
+++ b/src/main/java/org/scijava/MenuEntry.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/MenuPath.java b/src/main/java/org/scijava/MenuPath.java
index d18d5045f..533fd2461 100644
--- a/src/main/java/org/scijava/MenuPath.java
+++ b/src/main/java/org/scijava/MenuPath.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Named.java b/src/main/java/org/scijava/Named.java
index b30c410a1..9a381ee3a 100644
--- a/src/main/java/org/scijava/Named.java
+++ b/src/main/java/org/scijava/Named.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/NoSuchServiceException.java b/src/main/java/org/scijava/NoSuchServiceException.java
index e19a58270..d97d95647 100644
--- a/src/main/java/org/scijava/NoSuchServiceException.java
+++ b/src/main/java/org/scijava/NoSuchServiceException.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/NullContextException.java b/src/main/java/org/scijava/NullContextException.java
index e3eb1c731..794926da9 100644
--- a/src/main/java/org/scijava/NullContextException.java
+++ b/src/main/java/org/scijava/NullContextException.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Optional.java b/src/main/java/org/scijava/Optional.java
index 570991bb8..2ab55b3c9 100644
--- a/src/main/java/org/scijava/Optional.java
+++ b/src/main/java/org/scijava/Optional.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Prioritized.java b/src/main/java/org/scijava/Prioritized.java
index a3b9b7223..86bd0691a 100644
--- a/src/main/java/org/scijava/Prioritized.java
+++ b/src/main/java/org/scijava/Prioritized.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Priority.java b/src/main/java/org/scijava/Priority.java
index 61776fff4..69da7767e 100644
--- a/src/main/java/org/scijava/Priority.java
+++ b/src/main/java/org/scijava/Priority.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/SciJava.java b/src/main/java/org/scijava/SciJava.java
index f41be8bbe..81375dcd6 100644
--- a/src/main/java/org/scijava/SciJava.java
+++ b/src/main/java/org/scijava/SciJava.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Typed.java b/src/main/java/org/scijava/Typed.java
index 26d2ef9e2..cfb55d690 100644
--- a/src/main/java/org/scijava/Typed.java
+++ b/src/main/java/org/scijava/Typed.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/UIDetails.java b/src/main/java/org/scijava/UIDetails.java
index 49b508347..ccf12c261 100644
--- a/src/main/java/org/scijava/UIDetails.java
+++ b/src/main/java/org/scijava/UIDetails.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Validated.java b/src/main/java/org/scijava/Validated.java
index cd2c8c04e..11835ba5c 100644
--- a/src/main/java/org/scijava/Validated.java
+++ b/src/main/java/org/scijava/Validated.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/ValidityProblem.java b/src/main/java/org/scijava/ValidityProblem.java
index 9c31dd435..782bcc642 100644
--- a/src/main/java/org/scijava/ValidityProblem.java
+++ b/src/main/java/org/scijava/ValidityProblem.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/Versioned.java b/src/main/java/org/scijava/Versioned.java
index e14786fd2..6e746dad4 100644
--- a/src/main/java/org/scijava/Versioned.java
+++ b/src/main/java/org/scijava/Versioned.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java
index 5d3749e9d..28fe310a5 100644
--- a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java
+++ b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/AnnotationCombiner.java b/src/main/java/org/scijava/annotations/AnnotationCombiner.java
index 3855ed454..9b152b924 100644
--- a/src/main/java/org/scijava/annotations/AnnotationCombiner.java
+++ b/src/main/java/org/scijava/annotations/AnnotationCombiner.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/AnnotationProcessor.java b/src/main/java/org/scijava/annotations/AnnotationProcessor.java
index 5e8c1febc..e17d707a9 100644
--- a/src/main/java/org/scijava/annotations/AnnotationProcessor.java
+++ b/src/main/java/org/scijava/annotations/AnnotationProcessor.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -50,7 +50,6 @@
import javax.annotation.processing.Filer;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@@ -69,16 +68,38 @@
import org.scijava.annotations.AbstractIndexWriter.StreamFactory;
/**
- * The annotation processor for use with Java 8 and earlier.
+ * An annotation processor for indexing {@link Indexable} annotations at
+ * compile time. The design is inspired by
+ * Sezpoz, a compile-time
+ * indexing library by Jesse Glick.
+ *
+ * For each annotated class, this processor writes a JSON record of the
+ * annotation's attributes into {@code META-INF/json/} under a file named after
+ * the annotation type. At runtime, the index can be read to discover annotated
+ * classes and inspect their annotation values without loading (and therefore
+ * initializing) those classes — avoiding the cost and side-effects of a full
+ * classpath scan.
+ *
+ *
+ * For example, SciJava Common's {@link org.scijava.plugin.Plugin} annotation
+ * enables the {@link org.scijava.Context} application container to discover
+ * and prepare the application including all its plugins without needing to
+ * load all of those plugins in advance. Rather, they can be loaded upon first
+ * use in each appropriate context, greatly reducing application startup cost.
+ *
*
* @author Johannes Schindelin
*/
-@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes("*")
public class AnnotationProcessor extends AbstractProcessor {
private RoundEnvironment roundEnv;
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latestSupported();
+ }
+
@Override
public boolean process(final Set extends TypeElement> elements,
final RoundEnvironment env)
diff --git a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java
index 88e4229be..915d9148f 100644
--- a/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java
+++ b/src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/DirectoryIndexer.java b/src/main/java/org/scijava/annotations/DirectoryIndexer.java
index 8b5650e48..ac6be8fcd 100644
--- a/src/main/java/org/scijava/annotations/DirectoryIndexer.java
+++ b/src/main/java/org/scijava/annotations/DirectoryIndexer.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/EclipseHelper.java b/src/main/java/org/scijava/annotations/EclipseHelper.java
index 72c521ead..67f17ff7d 100644
--- a/src/main/java/org/scijava/annotations/EclipseHelper.java
+++ b/src/main/java/org/scijava/annotations/EclipseHelper.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/Index.java b/src/main/java/org/scijava/annotations/Index.java
index 6507152be..244b00d37 100644
--- a/src/main/java/org/scijava/annotations/Index.java
+++ b/src/main/java/org/scijava/annotations/Index.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/IndexItem.java b/src/main/java/org/scijava/annotations/IndexItem.java
index 34956a4f6..e5265fc21 100644
--- a/src/main/java/org/scijava/annotations/IndexItem.java
+++ b/src/main/java/org/scijava/annotations/IndexItem.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/IndexReader.java b/src/main/java/org/scijava/annotations/IndexReader.java
index 32ac714e5..4eab67552 100644
--- a/src/main/java/org/scijava/annotations/IndexReader.java
+++ b/src/main/java/org/scijava/annotations/IndexReader.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/Indexable.java b/src/main/java/org/scijava/annotations/Indexable.java
index 2c72f011c..325739efd 100644
--- a/src/main/java/org/scijava/annotations/Indexable.java
+++ b/src/main/java/org/scijava/annotations/Indexable.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java
index 44aa9dd49..9df62abcc 100644
--- a/src/main/java/org/scijava/annotations/legacy/LegacyReader.java
+++ b/src/main/java/org/scijava/annotations/legacy/LegacyReader.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/AbstractApp.java b/src/main/java/org/scijava/app/AbstractApp.java
index f4d5f9d8e..33ff29ff4 100644
--- a/src/main/java/org/scijava/app/AbstractApp.java
+++ b/src/main/java/org/scijava/app/AbstractApp.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/App.java b/src/main/java/org/scijava/app/App.java
index c4d2515af..95cf249e7 100644
--- a/src/main/java/org/scijava/app/App.java
+++ b/src/main/java/org/scijava/app/App.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -144,7 +144,7 @@ default void quit() {
/**
* Gets the version of the application.
*
*
diff --git a/src/main/java/org/scijava/app/AppService.java b/src/main/java/org/scijava/app/AppService.java
index cdf4bbdf0..2d9c7e3de 100644
--- a/src/main/java/org/scijava/app/AppService.java
+++ b/src/main/java/org/scijava/app/AppService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/DefaultAppService.java b/src/main/java/org/scijava/app/DefaultAppService.java
index 40f7816fa..9c8afc0c3 100644
--- a/src/main/java/org/scijava/app/DefaultAppService.java
+++ b/src/main/java/org/scijava/app/DefaultAppService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/DefaultStatusService.java b/src/main/java/org/scijava/app/DefaultStatusService.java
index 0fab08453..1b68a27ba 100644
--- a/src/main/java/org/scijava/app/DefaultStatusService.java
+++ b/src/main/java/org/scijava/app/DefaultStatusService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/SciJavaApp.java b/src/main/java/org/scijava/app/SciJavaApp.java
index 32bf3f5e2..b7604ca14 100644
--- a/src/main/java/org/scijava/app/SciJavaApp.java
+++ b/src/main/java/org/scijava/app/SciJavaApp.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/StatusService.java b/src/main/java/org/scijava/app/StatusService.java
index 2748361e1..70d0edf75 100644
--- a/src/main/java/org/scijava/app/StatusService.java
+++ b/src/main/java/org/scijava/app/StatusService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/app/event/StatusEvent.java b/src/main/java/org/scijava/app/event/StatusEvent.java
index e94ad4eb1..653aefb8e 100644
--- a/src/main/java/org/scijava/app/event/StatusEvent.java
+++ b/src/main/java/org/scijava/app/event/StatusEvent.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/cache/CacheService.java b/src/main/java/org/scijava/cache/CacheService.java
index 2cae0d038..ca5808918 100644
--- a/src/main/java/org/scijava/cache/CacheService.java
+++ b/src/main/java/org/scijava/cache/CacheService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/cache/DefaultCacheService.java b/src/main/java/org/scijava/cache/DefaultCacheService.java
index 0b4242720..667ffdb30 100644
--- a/src/main/java/org/scijava/cache/DefaultCacheService.java
+++ b/src/main/java/org/scijava/cache/DefaultCacheService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/Command.java b/src/main/java/org/scijava/command/Command.java
index 66c9decca..17a37ebb1 100644
--- a/src/main/java/org/scijava/command/Command.java
+++ b/src/main/java/org/scijava/command/Command.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/CommandInfo.java b/src/main/java/org/scijava/command/CommandInfo.java
index 8d843d457..f25c213db 100644
--- a/src/main/java/org/scijava/command/CommandInfo.java
+++ b/src/main/java/org/scijava/command/CommandInfo.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -52,6 +52,7 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.plugin.PluginInfo;
+import org.scijava.service.Service;
import org.scijava.util.ClassUtils;
import org.scijava.util.StringMaker;
import org.scijava.util.Types;
@@ -460,7 +461,8 @@ private void checkFields(final Class> type) {
}
final String name = f.getName();
- if (inputMap.containsKey(name) || outputMap.containsKey(name)) {
+ if ((inputMap.containsKey(name) || outputMap.containsKey(name))
+ && !Service.class.isAssignableFrom(f.getType())) {
// NB: Shadowed parameters are bad because they are ambiguous.
final String error = "Invalid duplicate parameter: " + f;
problems.add(new ValidityProblem(error));
diff --git a/src/main/java/org/scijava/command/CommandModule.java b/src/main/java/org/scijava/command/CommandModule.java
index 3cff108b9..226edc678 100644
--- a/src/main/java/org/scijava/command/CommandModule.java
+++ b/src/main/java/org/scijava/command/CommandModule.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/CommandModuleItem.java b/src/main/java/org/scijava/command/CommandModuleItem.java
index 7be4d3e9f..079193311 100644
--- a/src/main/java/org/scijava/command/CommandModuleItem.java
+++ b/src/main/java/org/scijava/command/CommandModuleItem.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/CommandService.java b/src/main/java/org/scijava/command/CommandService.java
index 9caa8a956..c1f78460c 100644
--- a/src/main/java/org/scijava/command/CommandService.java
+++ b/src/main/java/org/scijava/command/CommandService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -50,7 +50,7 @@
* A command is a particular type of plugin that is also a
* {@link Module}; i.e., it is {@link Runnable}, with typed inputs and outputs.
*
- * The command service keeps a master index of all commands known to the system.
+ * The command service keeps a central index of all commands known to the system.
* It asks the {@link PluginService} for available commands, then takes care of
* registering them with the {@link ModuleService}.
*
diff --git a/src/main/java/org/scijava/command/ContextCommand.java b/src/main/java/org/scijava/command/ContextCommand.java
index a804b41a5..c40649d53 100644
--- a/src/main/java/org/scijava/command/ContextCommand.java
+++ b/src/main/java/org/scijava/command/ContextCommand.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/DefaultCommandService.java b/src/main/java/org/scijava/command/DefaultCommandService.java
index 86abd98c9..29756debb 100644
--- a/src/main/java/org/scijava/command/DefaultCommandService.java
+++ b/src/main/java/org/scijava/command/DefaultCommandService.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/src/main/java/org/scijava/command/DynamicCommand.java b/src/main/java/org/scijava/command/DynamicCommand.java
index 695969c7d..5cc3ab4b1 100644
--- a/src/main/java/org/scijava/command/DynamicCommand.java
+++ b/src/main/java/org/scijava/command/DynamicCommand.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -60,7 +60,7 @@ public abstract class DynamicCommand extends DefaultMutableModule implements
private CommandService commandService;
@Parameter
- private PluginService pluginService;
+ protected PluginService pluginService;
@Parameter
protected ModuleService moduleService;
@@ -76,7 +76,8 @@ public abstract class DynamicCommand extends DefaultMutableModule implements
public DynamicCommandInfo getInfo() {
if (info == null) {
// NB: Create dynamic metadata lazily.
- final CommandInfo commandInfo = commandService.getCommand(getClass());
+ CommandInfo commandInfo = commandService.getCommand(getClass());
+ if (commandInfo == null) commandInfo = new CommandInfo(getClass());
info = new DynamicCommandInfo(commandInfo, getClass());
}
return info;
@@ -92,7 +93,7 @@ public Object getInput(final String name) {
@Override
public Object getOutput(final String name) {
final Field field = getInfo().getOutputField(name);
- if (field == null) return super.getInput(name);
+ if (field == null) return super.getOutput(name);
return ClassUtils.getValue(field, this);
}
diff --git a/src/main/java/org/scijava/command/DynamicCommandInfo.java b/src/main/java/org/scijava/command/DynamicCommandInfo.java
index 4296ec7e1..06c4a16e7 100644
--- a/src/main/java/org/scijava/command/DynamicCommandInfo.java
+++ b/src/main/java/org/scijava/command/DynamicCommandInfo.java
@@ -2,7 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2020 SciJava developers.
+ * Copyright (C) 2009 - 2026 SciJava developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -48,9 +48,9 @@
* Helper class for maintaining a {@link DynamicCommand}'s associated
* {@link ModuleInfo}.
*
- * The {@link CommandService} has a plain {@link CommandInfo} object in its
- * index, populated from the {@link DynamicCommand}'s @{@link Plugin}
- * annotation. So this class adapts that object, delegating to it for the
+ * This class wraps a plain {@link CommandInfo} object (e.g. from the
+ * {@link CommandService}'s index, present due to an @{@link Plugin} annotation
+ * on the {@link DynamicCommand} class), delegating to it for the
* {@link UIDetails} methods. The plain {@link CommandInfo} cannot be used
* as-is, however, because we need to override the {@link ModuleInfo} methods as
* well as provide metadata manipulation functionality such as
diff --git a/src/main/java/org/scijava/command/Inputs.java b/src/main/java/org/scijava/command/Inputs.java
new file mode 100644
index 000000000..b2f5e4217
--- /dev/null
+++ b/src/main/java/org/scijava/command/Inputs.java
@@ -0,0 +1,102 @@
+/*
+ * #%L
+ * SciJava Common shared library for SciJava software.
+ * %%
+ * Copyright (C) 2009 - 2026 SciJava developers.
+ * %%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * #L%
+ */
+
+package org.scijava.command;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import org.scijava.Context;
+import org.scijava.module.process.PreprocessorPlugin;
+
+/**
+ * A way to build a dynamic set of inputs, whose values are then harvested by
+ * the preprocessing framework.
+ *
+ * The {@link #run()} method of this command does nothing. If you want something
+ * custom to happen during execution, use a normal {@link Command} instead:
+ * either implement {@link Command directly}, or extend {@link ContextCommand}
+ * or {@link DynamicCommand}.
+ *