[jboss-cvs] JBossAS SVN: r112454 - branches/JBPAPP_5_1_0_Final_JBPAPP-7468/connector/src/main/org/jboss/resource/adapter/jdbc/xa.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 15 07:30:26 EST 2011
Author: jbertram at redhat.com
Date: 2011-11-15 07:30:26 -0500 (Tue, 15 Nov 2011)
New Revision: 112454
Modified:
branches/JBPAPP_5_1_0_Final_JBPAPP-7468/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnectionFactory.java
Log:
JBPAPP-7468
Modified: branches/JBPAPP_5_1_0_Final_JBPAPP-7468/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnectionFactory.java
===================================================================
--- branches/JBPAPP_5_1_0_Final_JBPAPP-7468/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnectionFactory.java 2011-11-14 18:57:07 UTC (rev 112453)
+++ branches/JBPAPP_5_1_0_Final_JBPAPP-7468/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnectionFactory.java 2011-11-15 12:30:26 UTC (rev 112454)
@@ -34,7 +34,10 @@
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -59,7 +62,7 @@
private String xaDataSourceProperties;
- protected final Properties xaProps = new Properties();
+ protected final Map<String, String> xaProps = Collections.synchronizedMap(new HashMap<String , String>());
private Boolean isSameRMOverrideValue;
@@ -90,7 +93,7 @@
{
if(urlProperty != null && urlProperty.length() > 0)
{
- String urlsStr = xaProps.getProperty(urlProperty);
+ String urlsStr = xaProps.get(urlProperty);
if(urlsStr != null && urlsStr.trim().length() > 0 && urlDelimiter != null && urlDelimiter.trim().length() > 0)
{
List xaDataList = new ArrayList();
@@ -99,10 +102,9 @@
// ctor doesn't work because iteration won't include defaults
// Properties xaPropsCopy = new Properties(xaProps);
Properties xaPropsCopy = new Properties();
- for(Iterator i = xaProps.keySet().iterator(); i.hasNext();)
+ for(Map.Entry<String, String> entry : xaProps.entrySet())
{
- Object key = i.next();
- xaPropsCopy.put(key, xaProps.get(key));
+ xaPropsCopy.put(entry.getKey(), entry.getValue());
}
int urlStart = 0;
@@ -140,7 +142,7 @@
}
}
- private XADataSource createXaDataSource(Properties xaProps)
+ private XADataSource createXaDataSource(Properties p)
throws JBossResourceException
{
if(getXADataSourceClass() == null)
@@ -154,10 +156,10 @@
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getXADataSourceClass());
xads = (XADataSource)clazz.newInstance();
Class[] NOCLASSES = new Class[]{};
- for(Iterator i = xaProps.keySet().iterator(); i.hasNext();)
+ for(Iterator i = p.keySet().iterator(); i.hasNext();)
{
String name = (String)i.next();
- String value = xaProps.getProperty(name);
+ String value = p.getProperty(name);
char firstCharName = Character.toUpperCase(name.charAt(0));
if (name.length() > 1)
name = firstCharName+name.substring(1);
@@ -176,7 +178,16 @@
}
catch(NoSuchMethodException e)
{
- type = String.class;
+ try
+ {
+ //HACK for now until we can rethink the XADataSourceProperties variable and pass type information
+ Method isMethod = clazz.getMethod("is" + name, NOCLASSES);
+ type = isMethod.getReturnType();
+ }
+ catch(NoSuchMethodException nsme)
+ {
+ type = String.class;
+ }
} // end of try-catch
Method setter = clazz.getMethod("set" + name, new Class[]{type});
@@ -371,7 +382,13 @@
InputStream is = new ByteArrayInputStream(xaDataSourceProperties.getBytes());
try
{
- xaProps.load(is);
+ Properties p = new Properties();
+ p.load(is);
+
+ for (Map.Entry<Object, Object> entry: p.entrySet())
+ {
+ xaProps.put((String)entry.getKey(), (String)entry.getValue());
+ }
}
catch (IOException ioe)
{
@@ -544,10 +561,10 @@
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(xaDataSourceClass);
xads = (XADataSource) clazz.newInstance();
Class[] NOCLASSES = new Class[] {};
- for (Iterator i = xaProps.keySet().iterator(); i.hasNext();)
+ for (Map.Entry<String, String> entry : xaProps.entrySet())
{
- String name = (String) i.next();
- String value = xaProps.getProperty(name);
+ String name = entry.getKey();
+ String value = entry.getValue();
char firstCharName = Character.toUpperCase(name.charAt(0));
if (name.length() > 1)
name = firstCharName+name.substring(1);
@@ -566,7 +583,17 @@
}
catch (NoSuchMethodException e)
{
- type = String.class;
+ try
+ {
+ //HACK for now until we can rethink the XADataSourceProperties variable and pass type information
+ Method isMethod = clazz.getMethod("is" + name, NOCLASSES);
+ type = isMethod.getReturnType();
+
+ }
+ catch(NoSuchMethodException nsme)
+ {
+ type = String.class;
+ }
}
Method setter = clazz.getMethod("set" + name, new Class[] { type });
@@ -604,9 +631,5 @@
}
return xads;
}
+}
- protected Properties getXaProps()
- {
- return xaProps;
- }
-}
More information about the jboss-cvs-commits
mailing list