1 package org.jboss.cache.transaction; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 6 import javax.naming.Context ; 7 import javax.naming.InitialContext ; 8 import javax.naming.NamingException ; 9 import java.util.Properties ; 10 11 17 public class DummyTransactionManager extends DummyBaseTransactionManager 18 { 19 static DummyTransactionManager instance = null; 20 21 static Log log = LogFactory.getLog(DummyTransactionManager.class); 22 23 private static final long serialVersionUID = 4396695354693176535L; 24 25 public DummyTransactionManager() 26 { 27 } 28 29 public static DummyTransactionManager getInstance() 30 { 31 if (instance == null) 32 { 33 instance = new DummyTransactionManager(); 34 try 35 { 36 Properties p = new Properties (); 37 p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory"); 38 Context ctx = new InitialContext (p); 39 ctx.bind("java:/TransactionManager", instance); 40 ctx.bind("UserTransaction", new DummyUserTransaction(instance)); 41 } 42 catch (NamingException e) 43 { 44 log.error("binding of DummyTransactionManager failed", e); 45 } 46 } 47 return instance; 48 } 49 50 public static void destroy() 51 { 52 if (instance == null) 53 return; 54 try 55 { 56 Properties p = new Properties (); 57 p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory"); 58 Context ctx = new InitialContext (p); 59 ctx.unbind("java:/TransactionManager"); 60 ctx.unbind("UserTransaction"); 61 } 62 catch (NamingException e) 63 { 64 log.error("unbinding of DummyTransactionManager failed", e); 65 } 66 instance.setTransaction(null); 67 instance = null; 68 } 69 70 } 71 | Popular Tags |