/**
  * Creates a {@link EhCacheCache} instance.
  *
  * @param ehcache backing Ehcache instance
  */
 public EhCacheCache(Ehcache ehcache) {
   Assert.notNull(ehcache, "non null ehcache required");
   Status status = ehcache.getStatus();
   Assert.isTrue(
       Status.STATUS_ALIVE.equals(status),
       "an 'alive' ehcache is required - current cache is " + status.toString());
   this.cache = ehcache;
 }
  protected boolean isStatusAlive() {
    Status status = _ehcache.getStatus();

    if (status.equals(Status.STATUS_ALIVE)) {
      return true;
    } else {
      return false;
    }
  }
 /**
  * Adapt the {@link net.sf.ehcache.Status} to the matching {@link Status}
  *
  * @param status the status to adapt
  * @return a Status that matches the lifecycle phase of the ehcache-specific status
  */
 public static Status adaptStatus(net.sf.ehcache.Status status) {
   if (status.intValue() == net.sf.ehcache.Status.STATUS_ALIVE.intValue()) {
     return Status.STARTED;
   }
   if (status.intValue() == net.sf.ehcache.Status.STATUS_UNINITIALISED.intValue()) {
     return Status.UNINITIALISED;
   }
   if (status.intValue() == net.sf.ehcache.Status.STATUS_SHUTDOWN.intValue()) {
     return Status.STOPPED;
   }
   return Status.UNINITIALISED;
 }
Esempio n. 4
0
  /** Prepares for shutdown. */
  public final synchronized void dispose() {
    if (status.equals(Status.STATUS_SHUTDOWN)) {
      return;
    }
    status = Status.STATUS_SHUTDOWN;
    flush();

    // release reference to cache
    cache = null;
    map = null;
    keyArray = null;
    keySamplePointer = null;
  }