1 7 package org.jboss.cache.interceptors; 8 9 import org.jboss.cache.CacheException; 10 import org.jboss.cache.CacheSPI; 11 import org.jboss.cache.Fqn; 12 import org.jboss.cache.GlobalTransaction; 13 import org.jboss.cache.NodeSPI; 14 import org.jboss.cache.OptimisticTransactionEntry; 15 import org.jboss.cache.TransactionTable; 16 import org.jboss.cache.optimistic.TransactionWorkspace; 17 18 import javax.transaction.TransactionManager ; 19 import java.util.List ; 20 21 26 public class OptimisticInterceptor extends Interceptor 27 { 28 protected TransactionManager txManager = null; 29 protected TransactionTable txTable = null; 30 31 public void setCache(CacheSPI cache) 32 { 33 super.setCache(cache); 34 txManager = cache.getTransactionManager(); 35 txTable = cache.getTransactionTable(); 36 } 37 38 protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException 39 { 40 OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) txTable.get(gtx); 41 42 if (transactionEntry == null) 43 { 44 throw new CacheException("unable to map global transaction " + gtx + " to transaction entry"); 45 } 46 47 return transactionEntry.getTransactionWorkSpace(); 49 } 50 51 57 protected void greedyGetFqns(List <Fqn> list, NodeSPI n, Fqn newBase) 58 { 59 list.add(n.getFqn()); 60 Fqn newFqn = new Fqn(newBase, n.getFqn().getLastElement()); 61 list.add(newFqn); 62 63 for (NodeSPI child : n.getChildrenDirect()) 64 { 65 greedyGetFqns(list, child, newFqn); 66 } 67 } 68 69 70 } 71 | Popular Tags |