Package org.apache.sis.internal.system
Class OptionalDependency
java.lang.Object
org.apache.sis.internal.system.SystemListener
org.apache.sis.internal.system.OptionalDependency
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
MetadataServices,ReferencingServices
Base class of internal hooks for accessing optional dependencies.
This is used for example for allowing the
"sis-metadata" module to access some
services of the "sis-referencing" module if the latter is present on the classpath.- Since:
- 0.6
- Version:
- 0.6
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe name of the optional module on which we depend. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOptionalDependency(String module, String dependency) Creates a new optional dependency. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidInvoked when the classpath is likely to have changed.protected static <T extends OptionalDependency>
TgetInstance(Class<T> type, String module, String dependency, String implementation) Returns the optional dependency, ornullif not found.protected final UnsupportedOperationExceptionReturns the exception to throw when a method requiring the optional dependency is invoked but that module is not on the classpath.Methods inherited from class org.apache.sis.internal.system.SystemListener
add, databaseChanged, fireClasspathChanged, remove, removeModule
-
Field Details
-
dependency
The name of the optional module on which we depend.
-
-
Constructor Details
-
Method Details
-
classpathChanged
protected void classpathChanged()Invoked when the classpath is likely to have changed. Subclasses must override like below:- Specified by:
classpathChangedin classSystemListener
-
getInstance
protected static <T extends OptionalDependency> T getInstance(Class<T> type, String module, String dependency, String implementation) Returns the optional dependency, ornullif not found. This is a helper method for implementation ofgetInstance()static method in subclasses.- Type Parameters:
T- compile-time type of thetypeargument.- Parameters:
type- the subclass type.module- same argument value than the one given to the constructor.dependency- same argument value than the one given to the constructor.implementation- the fully-qualified name of the class to instantiate by reflection.- Returns:
- an instance of the
implementationclass, ornullif not found.
-
moduleNotFound
Returns the exception to throw when a method requiring the optional dependency is invoked but that module is not on the classpath.- Returns:
- the exception to throw.
-