1 23 package org.apache.slide.transaction; 24 25 import javax.transaction.Status ; 26 import javax.transaction.Transaction ; 27 28 import java.util.*; 29 30 34 public class ExternalTransactionContext { 35 36 protected static Map transactions = Collections.synchronizedMap(new HashMap()); 37 38 public static void registerContext(Object txId, Transaction transaction) { 39 ExternalTransactionContext context = new ExternalTransactionContext(transaction, txId); 40 context.setStatus(Status.STATUS_ACTIVE); 41 transactions.put(txId, context); 42 } 43 44 public static ExternalTransactionContext lookupContext(Object txId) { 45 return (ExternalTransactionContext) transactions.get(txId); 46 } 47 48 public static void deregisterContext(Object txId) { 49 transactions.remove(txId); 50 } 51 52 protected Transaction transaction; 53 protected Object txId; 54 protected volatile int status; 55 56 protected ExternalTransactionContext(Transaction transaction, Object txId) { 57 this.transaction = transaction; 58 this.txId = txId; 59 } 60 61 64 public int getStatus() { 65 return status; 66 } 67 68 71 public void setStatus(int i) { 72 status = i; 73 } 74 77 public Transaction getTransaction() { 78 return transaction; 79 } 80 81 } 82 | Popular Tags |