Interface ExtensionManager
- All Known Implementing Classes:
DefaultExtensionManager
public interface ExtensionManager
An
ExtensionManager
implementation is exactly what it sounds like:
it manages Extension
s and takes care of lifecycle hooks, injecting
Catnip
instances, and so on. Proper implementations of this class
will, among other things, pay attention to the caveats mentioned in the
Extension
docs, to ensure compatibility with the
DefaultExtensionManager
.- Since:
- 9/6/18
- Author:
- amy
-
Method Summary
Modifier and TypeMethodDescriptioncatnip()
default <T extends Extension>
TReturn a single extension by class.Get all loaded extensions.loadExtension
(Extension extension) Load the given extension instance.matchingExtensions
(Class<T> extensionClass) Get all loaded extensions that are instantiated from the given class.matchingExtensions
(String regex) Get all loaded extensions whose names match the specified regex.void
shutdown()
Shuts down the extension manager and unloads all extensions.unloadExtension
(Extension extension) Unload the given extension instance.
-
Method Details
-
loadExtension
Load the given extension instance. Note than an extension may not be loaded more than once, and attempting to load an extension multiple times will no-op.- Parameters:
extension
- The extension to load.
-
unloadExtension
Unload the given extension instance. If the extension is not already loaded, this method will be a no-op.- Parameters:
extension
- The extension to unload.
-
matchingExtensions
Get all loaded extensions whose names match the specified regex. This method will only return extensions loaded by the current instance.- Parameters:
regex
- The regex to match extension names against.- Returns:
- A possibly-empty set of extensions that have names matching the supplied regex.
-
matchingExtensions
@Nonnull <T extends Extension> Set<? extends T> matchingExtensions(@Nonnull Class<T> extensionClass) Get all loaded extensions that are instantiated from the given class. This method will only return extensions loaded by the current instance.- Type Parameters:
T
- Type of the extension.- Parameters:
extensionClass
- The extension class to find instances of.- Returns:
- A possibly-empty set of extensions that are instances of the supplied class.
-
extension
Return a single extension by class. If multiple extensions are loaded from the same class, there is no guarantee which extension instance will be returned, in which case you should be usingmatchingExtensions(Class)
.- Type Parameters:
T
- Type of the extension.- Parameters:
extensionClass
- The extension class to find instances of- Returns:
- A possibly-
null
instance of the passed extension class.
-
extensions
Get all loaded extensions. This method will only return extensions loaded by the current instance.- Returns:
- A possibly-empty set of extensions.
-
shutdown
void shutdown()Shuts down the extension manager and unloads all extensions. -
catnip
Catnip catnip()
-