1 22 package org.jboss.tm.usertx.client; 23 24 import org.jboss.tm.TransactionPropagationContextUtil; 25 26 import java.util.Hashtable ; 27 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.naming.Reference ; 31 import javax.naming.Name ; 32 import javax.naming.NamingException ; 33 import javax.naming.spi.ObjectFactory ; 34 35 import javax.transaction.UserTransaction ; 36 37 45 public class ClientUserTransactionObjectFactory 46 implements ObjectFactory 47 { 48 52 static private UserTransaction userTransaction = null; 53 54 58 static private UserTransaction getUserTransaction() 59 { 60 if (userTransaction == null) { 61 try { 63 new InitialContext ().lookup("java:/TransactionManager"); 64 65 userTransaction = ServerVMClientUserTransaction.getSingleton(); 67 } catch (NamingException ex) { 68 ClientUserTransaction cut = ClientUserTransaction.getSingleton(); 70 71 TransactionPropagationContextUtil.setTPCFactory(cut); 74 userTransaction = cut; 75 } 76 } 77 return userTransaction; 78 } 79 80 public Object getObjectInstance(Object obj, Name name, 81 Context nameCtx, Hashtable environment) 82 throws Exception 83 { 84 Reference ref = (Reference )obj; 85 86 if (!ref.getClassName().equals(ClientUserTransaction.class.getName())) 87 return null; 88 89 return getUserTransaction(); 90 } 91 } 92 93 | Popular Tags |