com.atlassian.plugin.manager
Class DefaultPluginPersistentState

java.lang.Object
  extended by com.atlassian.plugin.manager.DefaultPluginPersistentState
All Implemented Interfaces:
PluginPersistentState, java.io.Serializable

public class DefaultPluginPersistentState
extends java.lang.Object
implements java.io.Serializable, PluginPersistentState

The state stored in this object represents only the differences between the desired state and the default state configured in the plugin. So if "getPluginState()" or "getPluginModuleState()" return null, then the manager should assume that the default state applies instead.

Please note that this class is not threadsafe. Access to instances should be synchronised.

See Also:
Serialized Form

Constructor Summary
DefaultPluginPersistentState()
           
DefaultPluginPersistentState(java.util.Map<java.lang.String,java.lang.Boolean> map)
           
DefaultPluginPersistentState(PluginPersistentState state)
           
 
Method Summary
 void addState(java.util.Map<java.lang.String,java.lang.Boolean> state)
          Add the plugin state.
 void clearPluginRestartState()
           
 java.util.Map<java.lang.String,java.lang.Boolean> getMap()
          Get the map of all states.
 PluginRestartState getPluginRestartState(java.lang.String pluginKey)
          Gets whether the plugin is expected to be upgraded, installed, or removed on next restart
 java.util.Map<java.lang.String,java.lang.Boolean> getPluginStateMap(Plugin plugin)
          Get state map of the given plugin and its modules
 java.lang.Boolean getState(java.lang.String key)
           
 boolean isEnabled(ModuleDescriptor<?> pluginModule)
          Whether or not a given plugin module is enabled in this state, calculated from it's current state AND default state.
 boolean isEnabled(Plugin plugin)
          Whether or not a plugin is enabled, calculated from it's current state AND default state.
 void removeState(java.lang.String key)
          Remove a plugin's state.
 void setEnabled(ModuleDescriptor<?> pluginModule, boolean isEnabled)
           
 void setEnabled(Plugin plugin, boolean isEnabled)
           
 void setPluginRestartState(java.lang.String pluginKey, PluginRestartState state)
           
 void setState(PluginPersistentState state)
          reset all plugin's state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPluginPersistentState

public DefaultPluginPersistentState()

DefaultPluginPersistentState

public DefaultPluginPersistentState(java.util.Map<java.lang.String,java.lang.Boolean> map)

DefaultPluginPersistentState

public DefaultPluginPersistentState(PluginPersistentState state)
Method Detail

getState

public java.lang.Boolean getState(java.lang.String key)

getMap

public java.util.Map<java.lang.String,java.lang.Boolean> getMap()
Description copied from interface: PluginPersistentState
Get the map of all states.

Specified by:
getMap in interface PluginPersistentState
Returns:
The map that maps plugins and modules' keys to a state (Boolean.True/Boolean.False). State stored in this map represents only the differences between the current state and the default state configured in the plugin(module).

isEnabled

public boolean isEnabled(Plugin plugin)
Description copied from interface: PluginPersistentState
Whether or not a plugin is enabled, calculated from it's current state AND default state.

Specified by:
isEnabled in interface PluginPersistentState

isEnabled

public boolean isEnabled(ModuleDescriptor<?> pluginModule)
Description copied from interface: PluginPersistentState
Whether or not a given plugin module is enabled in this state, calculated from it's current state AND default state.

Specified by:
isEnabled in interface PluginPersistentState

setEnabled

public void setEnabled(ModuleDescriptor<?> pluginModule,
                       boolean isEnabled)

setEnabled

public void setEnabled(Plugin plugin,
                       boolean isEnabled)

setState

public void setState(PluginPersistentState state)
reset all plugin's state.


addState

public void addState(java.util.Map<java.lang.String,java.lang.Boolean> state)
Add the plugin state.


removeState

public void removeState(java.lang.String key)
Remove a plugin's state.


getPluginStateMap

public java.util.Map<java.lang.String,java.lang.Boolean> getPluginStateMap(Plugin plugin)
Description copied from interface: PluginPersistentState
Get state map of the given plugin and its modules

Specified by:
getPluginStateMap in interface PluginPersistentState
Returns:
The map that maps the plugin and its modules' keys to plugin state (Boolean.TRUE/Boolean.FALSE). State stored in this map represents only the differences between the current state and the default state configured in the plugin(module).

getPluginRestartState

public PluginRestartState getPluginRestartState(java.lang.String pluginKey)
Description copied from interface: PluginPersistentState
Gets whether the plugin is expected to be upgraded, installed, or removed on next restart

Specified by:
getPluginRestartState in interface PluginPersistentState
Parameters:
pluginKey - The plugin to query
Returns:
The state of the plugin on restart

setPluginRestartState

public void setPluginRestartState(java.lang.String pluginKey,
                                  PluginRestartState state)

clearPluginRestartState

public void clearPluginRestartState()


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.