Interface ExtensionManager

All Known Implementing Classes:
DefaultExtensionManager

public interface ExtensionManager
An ExtensionManager implementation is exactly what it sounds like: it manages Extensions 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 Details

    • loadExtension

      ExtensionManager loadExtension(@Nonnull Extension extension)
      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

      ExtensionManager unloadExtension(@Nonnull Extension extension)
      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

      @Nonnull Set<Extension> matchingExtensions(@Nonnull String regex)
      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

      @Nullable default <T extends Extension> T extension(@Nonnull Class<T> extensionClass)
      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 using matchingExtensions(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

      @Nonnull Set<Extension> 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()