Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.0.2"
version = "1.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import javafx.beans.property.SimpleObjectProperty;
import javafx.stage.Stage;
import qupath.ext.extensionmanager.core.ExtensionCatalogManager;
import qupath.ext.extensionmanager.core.savedentities.Registry;
import qupath.ext.extensionmanager.core.savedentities.SavedCatalog;
import qupath.ext.extensionmanager.core.catalog.DefaultCatalog;
import qupath.ext.extensionmanager.gui.ExtensionManager;

import java.io.IOException;
Expand All @@ -15,9 +14,8 @@
import java.util.List;

/**
* An application that launches a {@link ExtensionManager}. A temporary directory (with
* an empty extension JAR file inside) is used as the extension directory.
* This <a href="https://github.com/qupath/qupath-catalog">catalog</a> is used.
* An application that launches a {@link ExtensionManager}. A temporary directory (with an empty extension JAR file inside)
* is used as the extension directory. This <a href="https://github.com/qupath/qupath-catalog">catalog</a> is used.
*/
public class ExtensionManagerApp extends Application {

Expand All @@ -38,13 +36,12 @@ public void start(Stage stage) throws IOException {
new SimpleObjectProperty<>(createExtensionDirectory()),
ExtensionManagerApp.class.getClassLoader(),
"v0.6.0",
new Registry(List.of(new SavedCatalog(
List.of(new DefaultCatalog(
"QuPath catalog",
"Extensions maintained by the QuPath team",
URI.create("https://github.com/qupath/qupath-catalog"),
URI.create("https://raw.githubusercontent.com/qupath/qupath-catalog/refs/heads/main/catalog.json"),
false
)))
URI.create("https://raw.githubusercontent.com/qupath/qupath-catalog/refs/heads/main/catalog.json")
))
);

new ExtensionManager(extensionCatalogManager, () -> {}).show();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/**
* This package contains an application to start an
* {@link qupath.ext.extensionmanager.gui.ExtensionManager ExtensionManager}.
* This package contains an application to start an {@link qupath.ext.extensionmanager.gui.ExtensionManager ExtensionManager}.
*/
package qupath.ext.extensionmanager.app;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import qupath.ext.extensionmanager.core.tools.FileTools;

import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -21,15 +22,13 @@
class ExtensionClassLoader extends URLClassLoader {

private static final Logger logger = LoggerFactory.getLogger(ExtensionClassLoader.class);
private final Set<String> filenamesAdded = new HashSet<>();
private final Set<String> addedJars = new HashSet<>();
private final List<Runnable> runnables = new ArrayList<>();

/**
* Create the extension class loader.
*
* @param parent the class loader that should be the parent of this
* class loader
* @throws SecurityException if the user doesn't have enough rights to create the class loader
* @param parent the class loader that should be the parent of this class loader
*/
public ExtensionClassLoader(ClassLoader parent) {
super(new URL[0], parent);
Expand All @@ -39,9 +38,7 @@ public ExtensionClassLoader(ClassLoader parent) {
* Load a JAR file located on the provided path.
*
* @param jarPath the path of the JAR file to load
* @throws java.io.IOError if an I/O error occurs while obtaining the absolute path of the
* provided path
* @throws SecurityException if the user doesn't have read rights on the provided path
* @throws java.io.IOError if an I/O error occurs while obtaining the absolute path of the provided path
* @throws MalformedURLException if an error occurred while converting the provided path to a URL
* @throws NullPointerException if the provided path is null
*/
Expand All @@ -50,15 +47,16 @@ public void addJar(Path jarPath) throws MalformedURLException {
addURL(jarPath.toUri().toURL());
logger.debug("File {} loaded by extension class loader", jarPath);

String filename = jarPath.getFileName().toString();
if (filenamesAdded.contains(filename)) {
String jarName = jarPath.getFileName().toString();
String nameWithoutVersion = FileTools.stripVersionFromFileName(jarName);
if (addedJars.contains(nameWithoutVersion)) {
logger.warn(
"A JAR file with the same file name ({}) was already added to this class loader. {} will probably not be loaded",
filename,
jarPath
"A JAR file with the same name ({}) was already added to this class loader. {} will probably not be loaded",
nameWithoutVersion,
jarName
);
}
filenamesAdded.add(filename);
addedJars.add(nameWithoutVersion);
}

List<Runnable> runnables;
Expand All @@ -76,21 +74,7 @@ public void addJar(Path jarPath) throws MalformedURLException {
}

/**
* Indicate that a JAR file should be unloaded.
* While this function doesn't currently unload the JAR, it is recommended
* to call it when a JAR file given to {@link #addJar(Path)} should not be
* loaded anymore. A future implementation may actually unload the JAR
*
* @param jarPath the path of the JAR file to unload
* @throws NullPointerException if the provided path is null
*/
public synchronized void removeJar(Path jarPath) {
filenamesAdded.remove(jarPath.getFileName().toString());
}

/**
* Set a runnable to be called each time a JAR file is loaded by this class loader. The call may
* happen from any thread.
* Set a runnable to be called each time a JAR file is loaded by this class loader. The call may happen from any thread.
*
* @param runnable the runnable to run when a JAR file is loaded
* @throws NullPointerException if the provided path is null
Expand Down
Loading
Loading