Example #1
0
 public Object read(Object key) throws CacheException {
   try {
     return cache.get(new Fqn(regionFqn, key), ITEM);
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #2
0
 public void update(Object key, Object value) throws CacheException {
   try {
     cache.put(new Fqn(regionFqn, key), ITEM, value);
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #3
0
 public void clear() throws CacheException {
   try {
     cache.remove(regionFqn);
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #4
0
 public void remove(Object key) throws CacheException {
   try {
     cache.remove(new Fqn(regionFqn, key));
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #5
0
 @SuppressWarnings("unchecked")
 public Map toMap() {
   try {
     Map result = new HashMap();
     Set childrenNames = cache.getChildrenNames(regionFqn);
     if (childrenNames != null) {
       Iterator iter = childrenNames.iterator();
       while (iter.hasNext()) {
         Object key = iter.next();
         result.put(key, cache.get(new Fqn(regionFqn, key), ITEM));
       }
     }
     return result;
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #6
0
 public long getElementCountInMemory() {
   try {
     Set children = cache.getChildrenNames(regionFqn);
     return children == null ? 0 : children.size();
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }
Example #7
0
  @SuppressWarnings("deprecation")
  public void put(Object key, Object value) throws CacheException {
    Transaction tx = suspend();
    try {
      // Workaround for JBCACHE-785
      cache.getInvocationContext().setTransaction(null);
      cache.getInvocationContext().setGlobalTransaction(null);

      // do the failfast put outside the scope of the JTA txn
      cache.putFailFast(new Fqn(regionFqn, key), ITEM, value, 0);
    } catch (TimeoutException te) {
      // ignore!
      log.debug("ignoring write lock acquisition failure");
    } catch (Exception e) {
      throw new CacheException(e);
    } finally {
      resume(tx);
    }
  }
Example #8
0
 public void destroy() throws CacheException {
   try {
     // NOTE : evict() operates locally only (i.e., does not propogate
     // to any other nodes in the potential cluster).  This is
     // exactly what is needed when we destroy() here; destroy() is used
     // as part of the process of shutting down a SessionFactory; thus
     // these removals should not be propogated
     cache.evict(regionFqn);
   } catch (Exception e) {
     throw new CacheException(e);
   }
 }