1 19 20 21 package org.netbeans.mdr.storagemodel.transientimpl; 22 23 import java.util.Stack ; 24 import org.netbeans.mdr.persistence.Index; 25 import org.netbeans.mdr.persistence.StorageException; 26 import org.netbeans.mdr.util.Logger; 27 28 32 public abstract class TransactionalIndex implements Index { 33 34 protected Stack txlog; 36 37 38 public TransactionalIndex() { 39 this.txlog = new Stack (); 40 } 41 42 45 public void commit() { 46 this.txlog.clear(); 47 } 48 49 52 public void rollBack() { 53 while (!txlog.empty()) { 54 try { 55 CompensatingTransaction ctx = (CompensatingTransaction) txlog.pop(); 56 ctx.perform(this); 57 } catch (StorageException se) { 58 Logger.getDefault().notify(Logger.INFORMATIONAL, se); 59 } 60 } 61 } 62 63 protected abstract void addNoTx(Object key, Object value) throws StorageException; 64 65 protected abstract Object removeNoTx(Object key, Object value) throws StorageException; 66 67 } 68 | Popular Tags |