Ejemplo n.º 1
0
 @Override
 public void remove(K id) {
   try (Batch batch = this.manager.getBatcher().createBatch()) {
     try {
       Bean<K, V> bean = this.manager.findBean(id);
       if (bean != null) {
         bean.remove(this.listener);
       }
     } catch (RuntimeException | Error e) {
       batch.discard();
       throw e;
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public void discard(V value) {
   try (BatchContext context = this.manager.getBatcher().resumeBatch(value.getCacheContext())) {
     try (Batch batch = value.getCacheContext()) {
       try {
         Bean<K, V> bean = this.manager.findBean(value.getId());
         if (bean != null) {
           bean.remove(null);
         }
       } catch (RuntimeException | Error e) {
         batch.discard();
         throw e;
       }
     }
   }
 }
Ejemplo n.º 3
0
 @Override
 public V get(K id) {
   // Batch is not closed here - it will be closed during release(...) or discard(...)
   @SuppressWarnings("resource")
   Batch batch = this.manager.getBatcher().createBatch();
   try {
     Bean<K, V> bean = this.manager.findBean(id);
     if (bean == null) {
       batch.close();
       return null;
     }
     V result = bean.acquire();
     result.setCacheContext(batch);
     return result;
   } catch (RuntimeException | Error e) {
     batch.discard();
     batch.close();
     throw e;
   }
 }