コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 protected Cache getCache() {
   if (manager == null
       || Status.STATUS_SHUTDOWN.equals(manager.getStatus())
       || cache == null
       || !Status.STATUS_ALIVE.equals(cache.getStatus())) {
     cache = createCache();
   } else {
     cache = getManager().getCache(cacheId);
   }
   return cache;
 }
コード例 #3
0
 /**
  * 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;
 }