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/.gitignore b/.gitignore
index 54e060e75..436cdc7f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,13 @@
*.swp
+
+# Maven #
+/target/
+
+# Eclipse #
/.classpath
/.project
/.settings/
-/target/
+
+# IntelliJ #
+/*.iml
+/.idea/
diff --git a/.mailmap b/.mailmap
index 902cb036c..5157cbbe1 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1,5 +1,16 @@
Barry DeZonia S get(final Class serviceClass) {
return context().service(serviceClass);
@@ -152,12 +191,22 @@ public InputService input() {
public IOService io() {
return get(IOService.class);
}
+
+ @Override
+ public LocationService location() {
+ return get(LocationService.class);
+ }
@Override
public LogService log() {
return get(LogService.class);
}
+ @Override
+ public MainService main() {
+ return get(MainService.class);
+ }
+
@Override
public MenuService menu() {
return get(MenuService.class);
@@ -202,6 +251,11 @@ public ScriptService script() {
return get(ScriptService.class);
}
+ @Override
+ public StartupService startup() {
+ return get(StartupService.class);
+ }
+
@Override
public StatusService status() {
return get(StatusService.class);
@@ -222,6 +276,11 @@ public ToolService tool() {
return get(ToolService.class);
}
+ @Override
+ public UIService ui() {
+ return get(UIService.class);
+ }
+
@Override
public WidgetService widget() {
return get(WidgetService.class);
@@ -240,13 +299,15 @@ public String getTitle() {
}
@Override
- public String getVersion() {
- return getApp().getVersion();
+ public String getInfo(final boolean mem) {
+ return getApp().getInfo(mem);
}
+ // -- Versioned methods --
+
@Override
- public String getInfo(final boolean mem) {
- return getApp().getInfo(mem);
+ public String getVersion() {
+ return getApp().getVersion();
}
}
diff --git a/src/main/java/org/scijava/AbstractUIDetails.java b/src/main/java/org/scijava/AbstractUIDetails.java
index 409dcefd6..11476a03a 100644
--- a/src/main/java/org/scijava/AbstractUIDetails.java
+++ b/src/main/java/org/scijava/AbstractUIDetails.java
@@ -2,9 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2015 Board of Regents of the University of
- * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
- * Institute of Molecular Cell Biology and Genetics.
+ * 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,8 +29,6 @@
package org.scijava;
-import org.scijava.util.ClassUtils;
-import org.scijava.util.MiscUtils;
import org.scijava.util.StringMaker;
/**
@@ -52,7 +48,7 @@ public abstract class AbstractUIDetails extends AbstractBasicDetails implements
private String iconPath;
/** Sort priority of the object. */
- private double priority = Priority.NORMAL_PRIORITY;
+ private double priority = Priority.NORMAL;
/** Whether the object can be selected in the user interface. */
private boolean selectable;
@@ -88,31 +84,6 @@ public String toString() {
// -- UIDetails methods --
- @Override
- public String getTitle() {
- // use object label, if available
- if (getLabel() != null && !getLabel().isEmpty()) return getLabel();
-
- // use name of leaf menu item, if available
- if (menuPath != null && menuPath.size() > 0) {
- final MenuEntry menuLeaf = menuPath.getLeaf();
- final String menuName = menuLeaf.getName();
- if (menuName != null && !menuName.isEmpty()) return menuName;
- }
-
- // use object name, if available
- if (getName() != null && !getName().isEmpty()) return getName();
-
- // use the unique identifier, if available
- if (this instanceof Identifiable) {
- final String id = ((Identifiable) this).getIdentifier();
- if (id != null) return id;
- }
-
- // use class name as a last resort
- return getClass().getSimpleName();
- }
-
@Override
public MenuPath getMenuPath() {
return menuPath;
@@ -209,34 +180,4 @@ public double getPriority() {
public void setPriority(final double priority) {
this.priority = priority;
}
-
- // -- Comparable methods --
-
- @Override
- public int compareTo(final Prioritized that) {
- if (that == null) return 1;
-
- // compare priorities
- final int priorityCompare = Priority.compare(this, that);
- if (priorityCompare != 0) return priorityCompare;
-
- // compare classes
- final int classCompare = ClassUtils.compare(getClass(), that.getClass());
- if (classCompare != 0) return classCompare;
-
- if (!(that instanceof UIDetails)) return 1;
- final UIDetails uiDetails = (UIDetails) that;
-
- // compare names
- final String thisName = getName();
- final String thatName = uiDetails.getName();
- final int nameCompare = MiscUtils.compare(thisName, thatName);
- if (nameCompare != 0) return nameCompare;
-
- // compare titles
- final String thisTitle = getTitle();
- final String thatTitle = uiDetails.getTitle();
- return MiscUtils.compare(thisTitle, thatTitle);
- }
-
}
diff --git a/src/main/java/org/scijava/BasicDetails.java b/src/main/java/org/scijava/BasicDetails.java
index 4294428fc..6c37807e6 100644
--- a/src/main/java/org/scijava/BasicDetails.java
+++ b/src/main/java/org/scijava/BasicDetails.java
@@ -2,9 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2015 Board of Regents of the University of
- * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
- * Institute of Molecular Cell Biology and Genetics.
+ * 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 9ce0ed337..5bc0fe61c 100644
--- a/src/main/java/org/scijava/Cancelable.java
+++ b/src/main/java/org/scijava/Cancelable.java
@@ -2,9 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2015 Board of Regents of the University of
- * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
- * Institute of Molecular Cell Biology and Genetics.
+ * 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 a533f3858..bfb118099 100644
--- a/src/main/java/org/scijava/Context.java
+++ b/src/main/java/org/scijava/Context.java
@@ -2,9 +2,7 @@
* #%L
* SciJava Common shared library for SciJava software.
* %%
- * Copyright (C) 2009 - 2015 Board of Regents of the University of
- * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
- * Institute of Molecular Cell Biology and Genetics.
+ * 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:
@@ -35,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;
@@ -51,15 +53,16 @@
import org.scijava.service.ServiceIndex;
import org.scijava.util.ClassUtils;
import org.scijava.util.Query;
+import org.scijava.util.Types;
/**
* Top-level SciJava application context, which initializes and maintains a list
* of services.
- *
+ *
* @author Curtis Rueden
* @see Service
*/
-public class Context implements Disposable {
+public class Context implements Disposable, AutoCloseable {
// -- Constants --
@@ -73,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
Type safety: A generic array of Class extends Service> is - * created for a varargs parameter+ *
Type safety: A generic array of + * {@code Class extends Service>} is created for a varargs + * parameter*
* To avoid this, we have opted to use raw types and suppress the relevant * warnings here instead. *
- * + * * @param serviceClasses A list of types that implement the {@link Service} * interface (e.g., {@code DisplayService.class}). Compatible - * services will be loaded in the order given, - * regardless of their relative priorities. + * services will be loaded in the order given, regardless of + * their relative priorities. * @see #Context(Collection, PluginIndex, boolean) * @throws ClassCastException If any of the given arguments do not implement * the {@link Service} interface. @@ -152,7 +181,7 @@ public Context(@SuppressWarnings("rawtypes") final Class... serviceClasses) { /** * Creates a new SciJava application context with the specified services (and * any required service dependencies). - * + * * @param serviceClasses A collection of types that implement the * {@link Service} interface (e.g., {@code DisplayService.class}). * Compatible services will be loaded according to the order of the @@ -166,13 +195,13 @@ public Context(final Collection+ * 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}). * Compatible services will be loaded according to the order of the @@ -249,8 +284,8 @@ public Context(final Collection+ * This method is notably useful for downstream code to discern between + * {@link Parameter} fields whose values would be injected, versus those whose + * values would not, without needing to hardcode type comparison checks + * against the {@link Service} and {@link Context} types. + *
+ * + * @param type The type of the @{@link Parameter}-annotated field. + * @return True iff a member field of the given type would have its value + * assigned. + */ + public boolean isInjectable(final Class> type) { + if (Service.class.isAssignableFrom(type)) return true; + return Context.class.isAssignableFrom(type) && type.isInstance(this); + } + // -- Disposable methods -- @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+ * Typical operations might include: + *
+ ** In this way, objects themselves do not need to be {@link Serializable}, nor * do multiple potentially equivalent objects need to be synthesized and then - * compared using {@link #equals}. + * compared using {@link Object#equals}. *
* * @author Curtis Rueden diff --git a/src/main/java/org/scijava/Initializable.java b/src/main/java/org/scijava/Initializable.java new file mode 100644 index 000000000..56aa725ae --- /dev/null +++ b/src/main/java/org/scijava/Initializable.java @@ -0,0 +1,43 @@ +/* + * #%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; + +/** + * Interface for objects which can be initialized. + * + * @author Curtis Rueden + */ +public interface Initializable { + + /** Initializes the object. */ + default void initialize() { + // NB: Do nothing by default. + } +} diff --git a/src/main/java/org/scijava/Instantiable.java b/src/main/java/org/scijava/Instantiable.java index 867f29ea2..3edca09a4 100644 --- a/src/main/java/org/scijava/Instantiable.java +++ b/src/main/java/org/scijava/Instantiable.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 43d976e1c..0ad031f7b 100644 --- a/src/main/java/org/scijava/InstantiableException.java +++ b/src/main/java/org/scijava/InstantiableException.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 6f79e2791..fa8b68684 100644 --- a/src/main/java/org/scijava/ItemIO.java +++ b/src/main/java/org/scijava/ItemIO.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 a5ebdfc9c..47897a359 100644 --- a/src/main/java/org/scijava/ItemVisibility.java +++ b/src/main/java/org/scijava/ItemVisibility.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 6cf85f384..a7da30625 100644 --- a/src/main/java/org/scijava/Locatable.java +++ b/src/main/java/org/scijava/Locatable.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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,6 +29,10 @@ package org.scijava; +import java.net.URL; + +import org.scijava.util.Types; + /** * An object whose location is defined by a URL string. * @@ -39,6 +41,9 @@ public interface Locatable { /** Gets the URL string defining the object's location. */ - String getLocation(); + default String getLocation() { + final URL location = Types.location(getClass()); + return location == null ? null : location.toExternalForm(); + } } diff --git a/src/main/java/org/scijava/MenuEntry.java b/src/main/java/org/scijava/MenuEntry.java index 8d37b10a8..4a2b33bb9 100644 --- a/src/main/java/org/scijava/MenuEntry.java +++ b/src/main/java/org/scijava/MenuEntry.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 e44b86899..533fd2461 100644 --- a/src/main/java/org/scijava/MenuPath.java +++ b/src/main/java/org/scijava/MenuPath.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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: @@ -56,20 +54,38 @@ public MenuPath() { * the argument will make a copy. */ public MenuPath(final Collection extends MenuEntry> menuEntries) { - addAll(menuEntries); + if (menuEntries != null) addAll(menuEntries); } /** * Creates a menu path with entries parsed from the given string. Assumes - * ">" as the separator (e.g., "File>New>Image"). + * {@code >} as the separator (e.g., {@code File>New>Image}). * * @see #PATH_SEPARATOR */ public MenuPath(final String path) { + this(path, PATH_SEPARATOR); + } + + /** + * Creates a menu path with entries parsed from the given string, splitting on + * the specified separator. + */ + public MenuPath(final String path, final String separator) { + this(path, separator, true); + } + + /** + * Creates a menu path with entries parsed from the given string, splitting on + * the specified separator, and trimming whitespace if indicated. + */ + public MenuPath(final String path, final String separator, + final boolean trim) + { if (path != null && !path.isEmpty()) { - final String[] tokens = path.split(PATH_SEPARATOR); + final String[] tokens = path.split(separator); for (final String token : tokens) { - add(new MenuEntry(token.trim())); + add(new MenuEntry(trim ? token.trim() : token)); } } } diff --git a/src/main/java/org/scijava/Named.java b/src/main/java/org/scijava/Named.java index 2f7cac60d..9a381ee3a 100644 --- a/src/main/java/org/scijava/Named.java +++ b/src/main/java/org/scijava/Named.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 225f6242e..d97d95647 100644 --- a/src/main/java/org/scijava/NoSuchServiceException.java +++ b/src/main/java/org/scijava/NoSuchServiceException.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 71a3d344d..794926da9 100644 --- a/src/main/java/org/scijava/NullContextException.java +++ b/src/main/java/org/scijava/NullContextException.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 16ef8e8b3..2ab55b3c9 100644 --- a/src/main/java/org/scijava/Optional.java +++ b/src/main/java/org/scijava/Optional.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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 57dd7a943..86bd0691a 100644 --- a/src/main/java/org/scijava/Prioritized.java +++ b/src/main/java/org/scijava/Prioritized.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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,6 +29,8 @@ package org.scijava; +import org.scijava.util.ClassUtils; + /** * An object that can be sorted according to priority. * @@ -52,4 +52,18 @@ public interface Prioritized extends Comparable+ * Note that it is still possible to prioritize something earlier + * than this value (e.g., for testing purposes), although doing so strongly + * discouraged in production. + *
+ */ + public static final double FIRST = +1e300; + + /** Priority for items that very strongly prefer to be sorted early. */ + public static final double EXTREMELY_HIGH = +1000000; /** Priority for items that strongly prefer to be sorted early. */ - public static final double VERY_HIGH_PRIORITY = +10000; + public static final double VERY_HIGH = +10000; /** Priority for items that prefer to be sorted earlier. */ - public static final double HIGH_PRIORITY = +100; + public static final double HIGH = +100; /** Default priority for items. */ - public static final double NORMAL_PRIORITY = 0; + public static final double NORMAL = 0; /** Priority for items that prefer to be sorted later. */ - public static final double LOW_PRIORITY = -100; + public static final double LOW = -100; /** Priority for items that strongly prefer to be sorted late. */ - public static final double VERY_LOW_PRIORITY = -10000; + public static final double VERY_LOW = -10000; - /** Priority for items that must be sorted last. */ - public static final double LAST_PRIORITY = Double.NEGATIVE_INFINITY; + /** Priority for items that very strongly prefer to be sorted late. */ + public static final double EXTREMELY_LOW = -1000000; + + /** Priority for items that must be sorted last. + *+ * Note that it is still possible to prioritize something later + * than this value (e.g., for testing purposes), although doing so strongly + * discouraged in production. + *
+ */ + public static final double LAST = -1e300; /** * Compares two {@link Prioritized} objects. @@ -108,4 +125,33 @@ public static boolean inject(final Object o, final double priority) { return true; } + // -- Deprecated -- + + /** @deprecated Use {@link #FIRST} instead. */ + @Deprecated + public static final double FIRST_PRIORITY = Double.POSITIVE_INFINITY; + + /** @deprecated Use {@link #VERY_HIGH} instead. */ + @Deprecated + public static final double VERY_HIGH_PRIORITY = +10000; + + /** @deprecated Use {@link #HIGH} instead. */ + @Deprecated + public static final double HIGH_PRIORITY = +100; + + /** @deprecated Use {@link #NORMAL} instead. */ + @Deprecated + public static final double NORMAL_PRIORITY = 0; + + /** @deprecated Use {@link #LOW} instead. */ + @Deprecated + public static final double LOW_PRIORITY = -100; + + /** @deprecated Use {@link #VERY_LOW} instead. */ + @Deprecated + public static final double VERY_LOW_PRIORITY = -10000; + + /** @deprecated Use {@link #LAST} instead. */ + @Deprecated + public static final double LAST_PRIORITY = Double.NEGATIVE_INFINITY; } diff --git a/src/main/java/org/scijava/SciJava.java b/src/main/java/org/scijava/SciJava.java index ee7a94eaf..81375dcd6 100644 --- a/src/main/java/org/scijava/SciJava.java +++ b/src/main/java/org/scijava/SciJava.java @@ -2,9 +2,7 @@ * #%L * SciJava Common shared library for SciJava software. * %% - * Copyright (C) 2009 - 2015 Board of Regents of the University of - * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck - * Institute of Molecular Cell Biology and Genetics. + * 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: @@ -44,7 +42,7 @@ * * @author Curtis Rueden */ -@Plugin(type = Gateway.class) +@Plugin(type = Gateway.class, name = "sj") public class SciJava extends AbstractGateway { // -- Constructors -- @@ -74,8 +72,9 @@ public SciJava(final boolean empty) { * {@code new SciJava(LogService.class)}) yield the potentially confusing * warning: * - *Type safety: A generic array of Class extends Service> is - * created for a varargs parameter+ *
Type safety: A generic array of + * {@code Class extends Service>} is created for a varargs + * parameter*
* To avoid this, we have opted to use raw types and suppress the relevant
* warning here instead.
@@ -111,5 +110,4 @@ public SciJava(final Collection
- * By default, this method will return {@code true} always, since the type is
- * known to be compatible. But individual implementations may have other
- * requirements beyond class assignability.
+ * By default, this method will return {@code true} iff the data is assignable
+ * to the associated type given by {@link #getType()}. But individual
+ * implementations may have other requirements beyond class assignability.
*
+ * 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.
+ *