com.atlassian.confluence.plugin.module
Class PluginModuleHolder<T>

java.lang.Object
  extended by com.atlassian.confluence.plugin.module.PluginModuleHolder<T>

public class PluginModuleHolder<T>
extends java.lang.Object

Manages the lifecycle of a plugin module of type T that is constructed when the module is first requested via 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.


Method Summary
 void disabled()
           
 void enabled(java.lang.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()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstanceWithDefaultFactory

public static <T> PluginModuleHolder<T> getInstanceWithDefaultFactory(com.atlassian.plugin.ModuleDescriptor<? extends T> moduleDescriptor)
Creates a PluginModuleHolder for the given module descriptor with the default factory.

See Also:
DefaultPluginModuleFactory

getInstance

public static <T> PluginModuleHolder<T> getInstance(PluginModuleFactory<? extends T> pluginModuleFactory)
Creates a PluginModuleHolder with a custom module factory.


enabled

public void enabled(java.lang.Class<T> moduleClass)
Changes the state of the module to 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!

Parameters:
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).
Throws:
java.lang.ClassCastException - if passed moduleClass is StateAware but the module type is not.

disabled

public void disabled()

isEnabled

public boolean isEnabled()

getModule

public T getModule()
            throws java.lang.IllegalStateException
Returns the held module.

Throws:
java.lang.IllegalStateException - if the module is not enabled

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2014 Atlassian. All Rights Reserved.