1 22 package org.jboss.tm.remoting.client; 23 24 import org.jboss.tm.TransactionPropagationContextUtil; 25 import org.jboss.tm.usertx.client.ServerVMClientUserTransaction; 26 27 import java.util.Hashtable ; 28 29 import javax.naming.Context ; 30 import javax.naming.InitialContext ; 31 import javax.naming.Reference ; 32 import javax.naming.Name ; 33 import javax.naming.NamingException ; 34 import javax.naming.spi.ObjectFactory ; 35 36 import javax.transaction.UserTransaction ; 37 38 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 |