org.jboss.cache
Class LifecycleManager

java.lang.Object
  extended by org.jboss.cache.LifecycleManager

public class LifecycleManager
extends Object

Added in 2.2.0 to handle the lifecycle of the cache. I.e., to control the starting and stopping process, as defined by the Cache.start() and Cache.stop() API methods.

This class also acts as a container for the ComponentRegistry, which it constructs in its constructor as a place to hold all components of a given cache instance.

It also holds the status of the cache, which can be queried.

Since:
2.2
Author:
Mircea.Markus@jboss.com

Constructor Summary
LifecycleManager(Configuration configuration)
          Constructs a new instance, also constructs a ComponentRegistry instance which can then be retrieved using getComponentRegistry().
 
Method Summary
 void create()
          Creates the components needed by a cache instance and sets the cache status to CacheStatus.CREATED when it is done.
 void destroy()
          Destroys the cache and frees up any resources.
 CacheStatus getCacheStatus()
           
 ComponentRegistry getComponentRegistry()
           
 void initialize(Configuration configuration, Notifier notifier, RegionManager regionManager, NodeFactory nodeFactory, DataContainer cacheData, BuddyManager buddyManager, RPCManager rpcManager, ComponentRegistry componentRegistry)
           
 boolean invocationsAllowed(boolean originLocal)
          Asserts whether invocations are allowed on the cache or not.
 void setCacheStatus(CacheStatus cacheStatus)
           
 void start()
          Starts the components needed by a cache instance, and then starts the cache instance itself.
 void stop()
          Stops the cache and sets the cache status to CacheStatus.STOPPED once it is done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleManager

public LifecycleManager(Configuration configuration)
Constructs a new instance, also constructs a ComponentRegistry instance which can then be retrieved using getComponentRegistry(). When constructed, the cache status is set to CacheStatus.INSTANTIATED.

Parameters:
configuration - with which to create this class.
Method Detail

initialize

public void initialize(Configuration configuration,
                       Notifier notifier,
                       RegionManager regionManager,
                       NodeFactory nodeFactory,
                       DataContainer cacheData,
                       BuddyManager buddyManager,
                       RPCManager rpcManager,
                       ComponentRegistry componentRegistry)

create

public void create()
            throws CacheException
Creates the components needed by a cache instance and sets the cache status to CacheStatus.CREATED when it is done.

Throws:
CacheException - if there is a problem with construction.

start

public void start()
           throws CacheException
Starts the components needed by a cache instance, and then starts the cache instance itself. Sets the cache status to CacheStatus.STARTED once it is done.

If the cache status is not CacheStatus.CREATED when this is called, it will first call create() to create the cache.

Throws:
CacheException - if there is a problem with starting the cache.

destroy

public void destroy()
Destroys the cache and frees up any resources. Sets the cache status to CacheStatus.DESTROYED when it is done.

If the cache is in CacheStatus.STARTED when this method is called, it will first call stop() to stop the cache.


stop

public void stop()
Stops the cache and sets the cache status to CacheStatus.STOPPED once it is done. If the cache is not in the CacheStatus.STARTED state, this is a no-op.


invocationsAllowed

public boolean invocationsAllowed(boolean originLocal)
Asserts whether invocations are allowed on the cache or not. Returns true if invocations are to be allowed, false otherwise. If the origin of the call is remote and the cache status is CacheStatus.STARTING, this method will block for up to Configuration.getStateRetrievalTimeout() millis, checking for a valid state.

Parameters:
originLocal - true if the call originates locally (i.e., from the CacheInvocationDelegate or false if it originates remotely, i.e., from the CommandAwareRpcDispatcher.
Returns:
true if invocations are allowed, false otherwise.

getCacheStatus

public CacheStatus getCacheStatus()

getComponentRegistry

public ComponentRegistry getComponentRegistry()

setCacheStatus

public void setCacheStatus(CacheStatus cacheStatus)


Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.