1 22 package org.jboss.ejb; 23 24 import java.util.HashMap ; 25 import javax.transaction.Transaction ; 26 import javax.transaction.RollbackException ; 27 import javax.transaction.SystemException ; 28 29 import org.jboss.tm.TransactionLocal; 30 31 32 56 public class TxEntityMap 57 { 58 protected TransactionLocal m_map = new TransactionLocal(); 59 60 63 public void associate(Transaction tx, EntityEnterpriseContext entity) 64 throws RollbackException , SystemException 65 { 66 HashMap entityMap = (HashMap ) m_map.get(tx); 67 if(entityMap == null) 68 { 69 entityMap = new HashMap (); 70 m_map.set(tx, entityMap); 71 } 72 entityMap.put(entity.getCacheKey(), entity); 74 } 75 76 public EntityEnterpriseContext getCtx(Transaction tx, Object key) 77 { 78 HashMap entityMap = (HashMap ) m_map.get(tx); 79 if(entityMap == null) return null; 80 return (EntityEnterpriseContext) entityMap.get(key); 81 } 82 83 public EntityEnterpriseContext getCtx(Object key) 84 { 85 HashMap entityMap = (HashMap ) m_map.get(); 86 if(entityMap == null) return null; 87 return (EntityEnterpriseContext) entityMap.get(key); 88 } 89 } 90 | Popular Tags |