public class PluginModuleHolder<T> extends Object
getModule()
method. However if module type is StateAware
module is created and enabled once enabled()
is called.
This class does not have any synchronisation or thread-safety guarantees. It relies on the plugin manager initialising and enabling plugin modules in single-threaded mode to ensure thread safety.
Modifier and Type | Method and Description |
---|---|
void |
disabled() |
void |
enabled(Class<T> moduleClass)
Changes the state of the module to
enabled . |
static <T> PluginModuleHolder<T> |
getInstance(PluginModuleFactory<? extends T> pluginModuleFactory)
Creates a PluginModuleHolder with a custom module factory.
|
static <T> PluginModuleHolder<T> |
getInstanceWithDefaultFactory(com.atlassian.plugin.ModuleDescriptor<? extends T> moduleDescriptor)
Creates a PluginModuleHolder for the given module descriptor with the default factory.
|
T |
getModule()
Returns the held module.
|
boolean |
isEnabled() |
String |
toString() |
public static <T> PluginModuleHolder<T> getInstanceWithDefaultFactory(com.atlassian.plugin.ModuleDescriptor<? extends T> moduleDescriptor)
DefaultPluginModuleFactory
public static <T> PluginModuleHolder<T> getInstance(PluginModuleFactory<? extends T> pluginModuleFactory)
public void enabled(Class<T> moduleClass)
enabled
.
If module class is StateAware
the module instance will
be created if it does not exist yet and then enabled()
method on the
instance will be called.
However if it is not StateAware
module, its instance will not be created and
creation will be deferred until the first time it is used!moduleClass
- a type of the module that this holder holds.
We cannot use the type parameter of this class because of java implementation of generics(erasure).ClassCastException
- if passed moduleClass
is StateAware
but the module type is not.public void disabled()
public boolean isEnabled()
public T getModule() throws IllegalStateException
IllegalStateException
- if the module is not enabledCopyright © 2003–2021 Atlassian. All rights reserved.