org.eclipse.osgi.internal.baseadaptor
Class StateManager

java.lang.Object
  extended by org.eclipse.osgi.internal.baseadaptor.StateManager
All Implemented Interfaces:
java.lang.Runnable, PlatformAdmin

public class StateManager
extends java.lang.Object
implements PlatformAdmin, java.lang.Runnable

The StateManager manages the system state for the framework. It also provides the implementation to the PlatformAdmin service.

Clients may extend this class.

Since:
3.1

Field Summary
static boolean DEBUG
          General debug flag
static boolean DEBUG_PLATFORM_ADMIN
          PlatformAdmin debug flag
static boolean DEBUG_PLATFORM_ADMIN_RESOLVER
          PlatformAdmin resolver debug flag
static boolean DEBUG_READER
          Reader debug flag
static boolean MONITOR_PLATFORM_ADMIN
          Monitor PlatformAdmin debug flag
static java.lang.String PROP_LAZY_UNLOADING_TIME
          System property used to specify to amount time before lazy data can be flushed from memory
static java.lang.String PROP_NO_LAZY_LOADING
          System property used to disable lazy state loading
 
Constructor Summary
StateManager(java.io.File stateFile, java.io.File lazyFile, BundleContext context)
          Constructs a StateManager using the specified files and context
StateManager(java.io.File stateFile, java.io.File lazyFile, BundleContext context, long expectedTimeStamp)
          Constructs a StateManager using the specified files and context
 
Method Summary
 void addDisabledInfo(DisabledInfo disabledInfo)
          Adds the disabled info to the state managed by this platform admin.
 void commit(State state)
          Commit the differences between the current state and the given state.
 Resolver createResolver()
          Creates a new Resolver that is not associated with any State.
 State createSystemState()
          Creates a new State used by the system.
 long getCachedTimeStamp()
          Returns the cached time stamp of the system State.
 StateObjectFactory getFactory()
          Returns a factory that knows how to create state objects, such as bundle descriptions and the different types of version constraints.
 Resolver getResolver()
          Deprecated.  
 State getState()
          Returns a mutable state representing the current system.
 State getState(boolean mutable)
          Returns a state representing the current system.
 StateHelper getStateHelper()
          Returns a state helper object.
 State getSystemState()
          Returns the State used by the system.
 State readSystemState()
          Reads the State used by the system.
 void removeDisabledInfo(DisabledInfo disabledInfo)
          Removes the disabled info from the state managed by this platform admin.
 void run()
           
 boolean saveNeeded()
           
 void shutdown(java.io.File saveStateFile, java.io.File saveLazyFile)
          Shutsdown the state manager.
 void stopDataManager()
          Stops the active data manager thread which is used to unload unused state objects from memory.
 void update(java.io.File updateStateFile, java.io.File updateLazyFile)
          Update the given target files with the state data in memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
General debug flag


DEBUG_READER

public static boolean DEBUG_READER
Reader debug flag


DEBUG_PLATFORM_ADMIN

public static boolean DEBUG_PLATFORM_ADMIN
PlatformAdmin debug flag


DEBUG_PLATFORM_ADMIN_RESOLVER

public static boolean DEBUG_PLATFORM_ADMIN_RESOLVER
PlatformAdmin resolver debug flag


MONITOR_PLATFORM_ADMIN

public static boolean MONITOR_PLATFORM_ADMIN
Monitor PlatformAdmin debug flag


PROP_NO_LAZY_LOADING

public static java.lang.String PROP_NO_LAZY_LOADING
System property used to disable lazy state loading


PROP_LAZY_UNLOADING_TIME

public static java.lang.String PROP_LAZY_UNLOADING_TIME
System property used to specify to amount time before lazy data can be flushed from memory

Constructor Detail

StateManager

public StateManager(java.io.File stateFile,
                    java.io.File lazyFile,
                    BundleContext context)
Constructs a StateManager using the specified files and context

Parameters:
stateFile - a file with the data required to persist in memory
lazyFile - a file with the data that may be lazy loaded and can be flushed from memory
context - the bundle context of the system bundle

StateManager

public StateManager(java.io.File stateFile,
                    java.io.File lazyFile,
                    BundleContext context,
                    long expectedTimeStamp)
Constructs a StateManager using the specified files and context

Parameters:
stateFile - a file with the data required to persist in memory
lazyFile - a file with the data that may be lazy loaded and can be flushed from memory
context - the bundle context of the system bundle
expectedTimeStamp - the expected timestamp of the persisted system state. A negative value indicates that no timestamp checking is done
Method Detail

shutdown

public void shutdown(java.io.File saveStateFile,
                     java.io.File saveLazyFile)
              throws java.io.IOException
Shutsdown the state manager. If the timestamp of the system state has changed

Parameters:
saveStateFile -
saveLazyFile -
Throws:
java.io.IOException

update

public void update(java.io.File updateStateFile,
                   java.io.File updateLazyFile)
            throws java.io.IOException
Update the given target files with the state data in memory.

Parameters:
updateStateFile -
updateLazyFile -
Throws:
java.io.IOException

stopDataManager

public void stopDataManager()
Stops the active data manager thread which is used to unload unused state objects from memory.


createSystemState

public State createSystemState()
Creates a new State used by the system. If the system State already exists then a new system State is not created.

Returns:
the State used by the system.

readSystemState

public State readSystemState()
Reads the State used by the system. If the system State already exists then the system State is not read from a cache. If the State could not be read from a cache then null is returned.

Returns:
the State used by the system or null if the State could not be read from a cache.

getSystemState

public State getSystemState()
Returns the State used by the system. If the system State does not exist then null is returned.

Returns:
the State used by the system or null if one does not exist.

getCachedTimeStamp

public long getCachedTimeStamp()
Returns the cached time stamp of the system State. This value is the original time stamp of the system state when it was created or read from a cache.

Returns:
the cached time stamp of the system State
See Also:
State.getTimeStamp()

saveNeeded

public boolean saveNeeded()

getState

public State getState(boolean mutable)
Description copied from interface: PlatformAdmin
Returns a state representing the current system. If there is need to make changes to the returned state, a mutable state must be requested. Otherwise, an immutable state should be requested. In this case, invoking any of the operations that could cause the state to be changed will throw an java.lang.UnsupportedOperationException.

If a mutable state is requested, the resulting state will not be resolved and the user objects from the system state bundle descriptions will not be copied.

Specified by:
getState in interface PlatformAdmin
Parameters:
mutable - whether the returned state should mutable
Returns:
a state representing the current framework.
See Also:
PlatformAdmin.getState(boolean)

getState

public State getState()
Description copied from interface: PlatformAdmin
Returns a mutable state representing the current system.

This is a convenience method, fully equivalent to getState(true).

Specified by:
getState in interface PlatformAdmin
Returns:
a state representing the current framework.
See Also:
PlatformAdmin.getState()

getFactory

public StateObjectFactory getFactory()
Description copied from interface: PlatformAdmin
Returns a factory that knows how to create state objects, such as bundle descriptions and the different types of version constraints.

Specified by:
getFactory in interface PlatformAdmin
Returns:
a state object factory
See Also:
PlatformAdmin.getFactory()

commit

public void commit(State state)
            throws BundleException
Description copied from interface: PlatformAdmin
Commit the differences between the current state and the given state. The given state must return true from State.isResolved() or an exception is thrown. The resolved state is committed verbatim, as-is.

Specified by:
commit in interface PlatformAdmin
Parameters:
state - the future state of the framework
Throws:
BundleException
See Also:
PlatformAdmin.commit(State)

getResolver

public Resolver getResolver()
Deprecated. 

Description copied from interface: PlatformAdmin
Returns a resolver supplied by the system. The returned resolver will not be associated with any state.

Specified by:
getResolver in interface PlatformAdmin
Returns:
a system resolver
See Also:
PlatformAdmin.getResolver()

createResolver

public Resolver createResolver()
Description copied from interface: PlatformAdmin
Creates a new Resolver that is not associated with any State.

Specified by:
createResolver in interface PlatformAdmin
Returns:
the new Resolver.
See Also:
PlatformAdmin.createResolver()

getStateHelper

public StateHelper getStateHelper()
Description copied from interface: PlatformAdmin
Returns a state helper object. State helpers provide convenience methods for manipulating states.

A possible implementation for this method would provide the same single StateHelper instance to all clients.

Specified by:
getStateHelper in interface PlatformAdmin
Returns:
a state helper
See Also:
PlatformAdmin.getStateHelper()

run

public void run()
Specified by:
run in interface java.lang.Runnable

addDisabledInfo

public void addDisabledInfo(DisabledInfo disabledInfo)
Description copied from interface: PlatformAdmin
Adds the disabled info to the state managed by this platform admin. If a disable info already exists for the specified policy and the specified bundle then it is replaced with the given disabled info.

Specified by:
addDisabledInfo in interface PlatformAdmin
Parameters:
disabledInfo - the disabled info to add.

removeDisabledInfo

public void removeDisabledInfo(DisabledInfo disabledInfo)
Description copied from interface: PlatformAdmin
Removes the disabled info from the state managed by this platform admin.

Specified by:
removeDisabledInfo in interface PlatformAdmin
Parameters:
disabledInfo - the disabled info to remove


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.