javax.cache
Interface CacheLifecycle

All Known Subinterfaces:
Cache<K,V>

public interface CacheLifecycle

Cache resources may have non-trivial initialisation and disposal procedures. As such it is unrealistic to expect them to be avaiable for service after object creation.

This interface defines a lifecycle for these resources and associates a CacheStatus with each.

The CacheStatus of a newly created resource is CacheStatus.UNINITIALISED.

Since:
1.0
Author:
Greg Luck

Method Summary
 CacheStatus getStatus()
          Returns the cache status.
 void start()
          Notifies providers to start themselves.
 void stop()
          Providers may be doing all sorts of exotic things and need to be able to clean up on stop.
 

Method Detail

start

void start()
           throws CacheException
Notifies providers to start themselves.

This method is called during the resource's start method after it has changed it's status to alive. Cache operations are legal in this method. At the completion of this method invocation getStatus() must return CacheStatus.STARTED.

Throws:
CacheException

stop

void stop()
          throws CacheException
Providers may be doing all sorts of exotic things and need to be able to clean up on stop.

Cache operations are illegal after this method is called. A IllegalStateException will be thrown if an operation is performed on CacheManager or any contained Cache while they are stopping or are a stopped.

Resources will change status to CacheStatus.STOPPING when this method is called. Once they are stopped they will change status to CacheStatus.STOPPED.

Throws:
CacheException

getStatus

CacheStatus getStatus()
Returns the cache status.

Returns:
one of CacheStatus


Copyright © 2011. All Rights Reserved.