Package javax.cache

Interface CacheLifecycle

  • All Known Subinterfaces:
    Cache<K,​V>
    All Known Implementing Classes:
    CacheImpl

    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 Status with each.

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

    Since:
    1.0
    Author:
    Greg Luck
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Status 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()
        Notifies providers to start themselves.

        This method is called during the resource's start method after it has changed its status to alive. Cache operations are legal in this method.

        At the completion of this method invocation getStatus() must return Status.STARTED.

        Throws:
        CacheException - if ????? TODO describe when
      • stop

        void stop()
        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

        Resources will change status to Status.STOPPED when this method completes.

        Stop must free any JVM resources used.

        Throws:
        CacheException - if ????? TODO describe when
        IllegalStateException - thrown if an operation is performed on a cache unless it is started.
      • getStatus

        Status getStatus()
        Returns the cache status.

        This method blocks while the state is changing

        Returns:
        one of Status