This package provides a subsystem for SciJava applications that enables handling of URI-based links via plugins.
It is kept separate from the SciJava Common core classes because it requires Java 11 as a minimum, due to its use of java.awt.Desktop features not present in Java 8.
- Link handling: Register custom handlers for URI schemes through the
LinkHandlerplugin interface - CLI integration: Automatic handling of URI arguments passed on the command line via
ConsoleArgument - OS integration: Automatic registration of URI schemes with the operating system (Windows supported, macOS/Linux planned)
Implement the LinkHandler interface to handle custom URI schemes:
@Plugin(type = LinkHandler.class)
public class MyLinkHandler extends AbstractLinkHandler {
@Override
public boolean supports(URI uri) {
return "myapp".equals(uri.getScheme());
}
@Override
public void handle(URI uri) {
// Handle the URI
System.out.println("Handling: " + uri);
}
@Override
public List<String> getSchemes() {
// Return schemes to register with the OS
return Arrays.asList("myapp");
}
}On Windows, URI schemes returned by LinkHandler.getSchemes() are automatically registered
in the Windows Registry when the LinkService initializes. This allows users to click
links like myapp://action in web browsers or other applications, which will launch your
Java application with the URI as a command-line argument.
The registration uses HKEY_CURRENT_USER and requires no administrator privileges.
See doc/WINDOWS.md for details.
LinkService- Service for routing URIs to appropriate handlersLinkHandler- Plugin interface for implementing custom URI handlersLinkArgument- Console argument plugin that recognizes URIs on the command lineSchemeInstaller- Interface for OS-specific URI scheme registrationWindowsSchemeInstaller- Windows implementation using registry commands
The launcher should set the scijava.app.executable system property to enable URI scheme registration.