Coverage Report - org.mule.module.jboss.transaction.JBossArjunaTransactionManagerFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
JBossArjunaTransactionManagerFactory
0%
0/20
0%
0/8
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.jboss.transaction;
 8  
 
 9  
 import org.mule.api.config.MuleConfiguration;
 10  
 import org.mule.api.transaction.TransactionManagerFactory;
 11  
 
 12  
 import com.arjuna.ats.arjuna.common.Environment;
 13  
 import com.arjuna.ats.arjuna.common.arjPropertyManager;
 14  
 
 15  
 import java.net.InetAddress;
 16  
 import java.net.UnknownHostException;
 17  
 import java.text.MessageFormat;
 18  
 import java.util.HashMap;
 19  
 import java.util.Map;
 20  
 
 21  
 import javax.transaction.TransactionManager;
 22  
 
 23  
 public class JBossArjunaTransactionManagerFactory implements TransactionManagerFactory
 24  
 {
 25  
 
 26  0
     private Map<String, String> properties = new HashMap<String, String>();
 27  
 
 28  
     //static
 29  
     //{
 30  
     //arjPropertyManager.propertyManager.setProperty(LogFactory.LOGGER_PROPERTY, "log4j_releveler");
 31  
     //arjPropertyManager.propertyManager.setProperty(LogFactory.LOGGER_PROPERTY, "jakarta");
 32  
     //arjPropertyManager.propertyManager.setProperty(LogFactory.DEBUG_LEVEL, String.valueOf(DebugLevel.FULL_DEBUGGING));
 33  
     //commonPropertyManager.propertyManager.setProperty(LogFactory.LOGGER_PROPERTY, "jakarta");
 34  
     //commonPropertyManager.propertyManager.setProperty(LogFactory.DEBUG_LEVEL, String.valueOf(DebugLevel.FULL_DEBUGGING));
 35  
     //}
 36  
 
 37  
     private TransactionManager tm;
 38  
 
 39  
     public JBossArjunaTransactionManagerFactory()
 40  0
     {
 41  
         //arjPropertyManager.propertyManager.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreType", "ShadowNoFileLockStore");
 42  
         //arjPropertyManager.propertyManager.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_JDBCStore().stringForm());
 43  0
     }
 44  
 
 45  
     public synchronized TransactionManager create(MuleConfiguration config) throws Exception
 46  
     {
 47  0
         if (tm == null)
 48  
         {
 49  
             // let the user override those in the config
 50  0
             if (!properties.containsKey(Environment.OBJECTSTORE_DIR))
 51  
             {
 52  0
                 final String muleInternalDir = config.getWorkingDirectory();
 53  0
                 arjPropertyManager.propertyManager.setProperty(Environment.OBJECTSTORE_DIR, muleInternalDir + "/transaction-log");
 54  
             }
 55  
 
 56  0
             if (!properties.containsKey(Environment.XA_NODE_IDENTIFIER))
 57  
             {
 58  
                 try
 59  
                 {
 60  0
                     InetAddress address = InetAddress.getLocalHost();
 61  0
                     final String xaNodeId = MessageFormat.format("Mule[{0}/{1}]",
 62  
                                                                  address.getHostName(), address.getHostAddress());
 63  0
                     properties.put(Environment.XA_NODE_IDENTIFIER, xaNodeId);
 64  
                 }
 65  0
                 catch (UnknownHostException e)
 66  
                 {
 67  
                     // ignore, let the defaults be generated
 68  0
                 }
 69  
             }
 70  
 
 71  
 
 72  0
             for (Map.Entry<String, String> entry : properties.entrySet())
 73  
             {
 74  0
                 arjPropertyManager.propertyManager.setProperty(entry.getKey(), entry.getValue());
 75  
             }
 76  0
             tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
 77  
 
 78  
         }
 79  0
         return tm;
 80  
     }
 81  
 
 82  
     public Map<String, String> getProperties()
 83  
     {
 84  0
         return properties;
 85  
     }
 86  
 
 87  
     public void setProperties(Map<String, String> properties)
 88  
     {
 89  0
         this.properties = properties;
 90  0
     }
 91  
 }