[jboss-svn-commits] JBL Code SVN: r26419 - in labs/jbosstm/trunk/ArjunaJTA: jdbc/bin and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu May 7 11:48:28 EDT 2009
Author: jhalliday
Date: 2009-05-07 11:48:28 -0400 (Thu, 07 May 2009)
New Revision: 26419
Added:
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/PropertyFileDynamicClass.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/XADataSourceReflectionWrapper.java
Modified:
labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.odt
labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.pdf
labs/jbosstm/trunk/ArjunaJTA/jdbc/bin/JNDIManager.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/DynamicClass.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_8_1.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_9_0.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_jndi.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/sqlserver_jndi.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/oracle_8_1_6.java
Log:
Deprecated obsolete JNDI code. Added new generic DynamicClass impl. JBTM-546
Modified: labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbosstm/trunk/ArjunaJTA/docs/user_guide/ProgrammersGuide.pdf
===================================================================
(Binary files differ)
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/bin/JNDIManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/bin/JNDIManager.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/bin/JNDIManager.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -1,20 +1,20 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
* See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
- *
+ *
* (C) 2005-2006,
* @author JBoss Inc.
*/
@@ -24,8 +24,8 @@
* Arjuna Solutions Limited,
* Newcastle upon Tyne,
* Tyne and Wear,
- * UK.
- *
+ * UK.
+ *
* $Id: JNDIManager.java 2342 2006-03-30 13:06:17Z $
*/
@@ -38,6 +38,9 @@
import javax.transaction.xa.*;
import javax.naming.*;
+/**
+ * @deprecated
+ */
public class JNDIManager
{
@@ -45,7 +48,7 @@
{
String url = "jdbc:arjuna:oracle:thin:@reshend.ncl.ac.uk:1521:JDBCTest";
String dynamicClass = "com.arjuna.JDBC2.drivers.oracle_8_1_6";
-
+
for (int i = 0; i < args.length; i++)
{
if (args[i].equals("-help"))
@@ -67,11 +70,11 @@
Hashtable env = new Hashtable();
String initialCtx = PropertyManager.getProperty("Context.INITIAL_CONTEXT_FACTORY");
-
+
env.put(Context.INITIAL_CONTEXT_FACTORY, initialCtx);
InitialContext ctx = new InitialContext(env);
-
+
ctx.bind("/tmp/foo", ds);
System.out.println("Ready");
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -138,9 +138,9 @@
{
if (jdbcLogger.logger.isErrorEnabled())
{
- jdbcLogger.logger.error(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+exception.toString());
+ jdbcLogger.logger.error(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+" "+e.toString());
}
- SQLException sqlException = new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+exception.toString());
+ SQLException sqlException = new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+" "+e.toString());
sqlException.initCause(e);
throw sqlException;
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/DynamicClass.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/DynamicClass.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/DynamicClass.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -1,20 +1,20 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
* See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
- *
+ *
* (C) 2005-2006,
* @author JBoss Inc.
*/
@@ -24,7 +24,7 @@
* Arjuna Solutions Limited,
* Newcastle upon Tyne,
* Tyne and Wear,
- * UK.
+ * UK.
*
* $Id: DynamicClass.java 2342 2006-03-30 13:06:17Z $
*/
@@ -51,7 +51,15 @@
{
public XADataSource getDataSource (String dbName) throws SQLException;
+
+ /**
+ * @deprecated
+ */
public XADataSource getDataSource (String dbName, boolean create) throws SQLException;
+
+ /**
+ * @deprecated
+ */
public void shutdownDataSource (XADataSource ds) throws SQLException;
-
+
}
Added: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/PropertyFileDynamicClass.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/PropertyFileDynamicClass.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/PropertyFileDynamicClass.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package com.arjuna.ats.internal.jdbc.drivers;
+
+import com.arjuna.ats.internal.jdbc.DynamicClass;
+
+import javax.sql.XADataSource;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * A dynamic class that reads from a properties file and uses the information to
+ * instantiate and configure an XADataSource.
+ *
+ * The properties in the file must be as follows:
+ * xaDataSourceClassName : The name of the driver class that implements XADataSource
+ * All other properties in the file are read and a matching setter method called
+ * on the XADataSource. This allows for implementations that require non standard configuration.
+ * e.g.
+ * serverName=foo
+ * results in the method call
+ * setServerName("foo");
+ * in accordance with JavaBeans naming conventions.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+public class PropertyFileDynamicClass implements DynamicClass
+{
+ private static final String xaDataSourceClassNameProperty = "xaDataSourceClassName";
+
+ public XADataSource getDataSource(String propertyFileName) throws SQLException {
+ // read some system properties and use reflection to load and configure the datasource.
+
+ Properties properties = new Properties();
+
+ FileInputStream propertiesFileInputStream = null;
+ try {
+ propertiesFileInputStream = new FileInputStream(propertyFileName);
+ properties.load(propertiesFileInputStream);
+ propertiesFileInputStream.close();
+ } catch(IOException e) {
+ SQLException sqlException = new SQLException("failed to locate properties file");
+ sqlException.initCause(e);
+ throw sqlException;
+ } finally {
+ if(propertiesFileInputStream != null) {
+ try {
+ propertiesFileInputStream.close();
+ } catch(IOException e) {}
+ }
+ }
+
+ String xaDataSourceClassName = properties.getProperty(xaDataSourceClassNameProperty);
+
+ XADataSourceReflectionWrapper xaDataSourceReflectionWrapper = new XADataSourceReflectionWrapper(xaDataSourceClassName);
+
+ Enumeration enumeration = properties.propertyNames();
+ while(enumeration.hasMoreElements()) {
+ String propertyName = (String)enumeration.nextElement();
+ if(xaDataSourceClassNameProperty.equals(propertyName)) {
+ continue;
+ }
+ String propertyValue = (String)properties.get(propertyName);
+ try {
+ xaDataSourceReflectionWrapper.setProperty(propertyName, propertyValue);
+ } catch(Exception e) {
+ SQLException sqlException = new SQLException("failed to configure XADataSource");
+ sqlException.initCause(e);
+ throw sqlException;
+ }
+ }
+
+ return xaDataSourceReflectionWrapper.getWrappedXADataSource();
+ }
+
+ /**
+ * @deprecated
+ */
+ public XADataSource getDataSource(String dbName, boolean create) throws SQLException {
+ return null;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void shutdownDataSource(XADataSource ds) throws SQLException {
+ }
+}
Added: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/XADataSourceReflectionWrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/XADataSourceReflectionWrapper.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/XADataSourceReflectionWrapper.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package com.arjuna.ats.internal.jdbc.drivers;
+
+import javax.sql.XADataSource;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * A simple wrapper class that uses reflection to load and configure an XADataSource.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+public class XADataSourceReflectionWrapper
+{
+ private XADataSource xaDataSource;
+
+ XADataSourceReflectionWrapper(String classname)
+ {
+ try
+ {
+ xaDataSource = (XADataSource)Class.forName(classname).newInstance();
+ }
+ catch(Exception e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ public void setProperty(String name, String value)
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
+ {
+ name = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+
+ Method[] methods = xaDataSource.getClass().getMethods();
+ Method matchingMethod = null;
+ for(Method method : methods) {
+ if(method.getName().equals(name) && method.getParameterTypes().length == 1) {
+ // ignores overloading, just takes the first match it finds.
+ matchingMethod = method;
+ break;
+ }
+ }
+
+ if(matchingMethod == null) {
+ throw new NoSuchMethodException("Could not match "+name);
+ }
+
+ Class type = matchingMethod.getParameterTypes()[0];
+ Object argument = value;
+
+ if(type == Integer.TYPE) {
+ argument = new Integer(value);
+ }
+ if(type == Boolean.TYPE) {
+ argument = new Boolean(value);
+ }
+
+ matchingMethod.invoke(xaDataSource, argument);
+ }
+
+ public XADataSource getWrappedXADataSource()
+ {
+ return xaDataSource;
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_8_1.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_8_1.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_8_1.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -44,13 +44,14 @@
import java.sql.SQLException;
-/*
+/**
* This is a stateless class to allow us to get round
* problems in Oracle. For example, they can't work with
* an arbitrary implementation of Xid - it has to be their
* own implementation!
+ *
+ * @deprecated
*/
-
public class oracle_8_1 implements XAModifier, ConnectionModifier
{
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_9_0.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_9_0.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_9_0.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -44,13 +44,14 @@
import java.sql.SQLException;
-/*
+/**
* This is a stateless class to allow us to get round
* problems in Oracle. For example, they can't work with
* an arbitrary implementation of Xid - it has to be their
* own implementation!
+ *
+ * @deprecated
*/
-
public class oracle_9_0 implements XAModifier, ConnectionModifier
{
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_jndi.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_jndi.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/oracle_jndi.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -45,13 +45,14 @@
import java.sql.SQLException;
-/*
+/**
* This is a stateless class to allow us to get round
* problems in Oracle. For example, they can't work with
* an arbitrary implementation of Xid - it has to be their
* own implementation!
+ *
+ * @deprecated
*/
-
public class oracle_jndi implements XAModifier, ConnectionModifier
{
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/sqlserver_jndi.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/sqlserver_jndi.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/sqlserver_jndi.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -1,20 +1,20 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
* See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
- *
+ *
* (C) 2005-2006,
* @author JBoss Inc.
*/
@@ -24,7 +24,7 @@
* Arjuna Technologies Limited,
* Newcastle upon Tyne,
* Tyne and Wear,
- * UK.
+ * UK.
*
* $Id: sqlserver_jndi.java 2342 2006-03-30 13:06:17Z $
*/
@@ -44,9 +44,11 @@
import java.sql.SQLException;
-/*
+/**
* This is a stateless class to allow us to get round
- * problems in MSQ Server.
+ * problems in MSSQLServer.
+ *
+ * @deprecated
*/
public class sqlserver_jndi implements XAModifier, ConnectionModifier
@@ -56,7 +58,7 @@
{
return dbName;
}
-
+
public Xid createXid (XidImple xid) throws SQLException, NotImplementedException
{
return xid;
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/oracle_8_1_6.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/oracle_8_1_6.java 2009-05-07 12:32:42 UTC (rev 26418)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/oracle_8_1_6.java 2009-05-07 15:48:28 UTC (rev 26419)
@@ -46,12 +46,13 @@
import java.sql.SQLException;
-/*
+/**
* This is a stateless class to allow us access to the Oracle
* specific API without hardwiring the code into the generic
* JDBC2 driver.
+ *
+ * @deprecated
*/
-
public class oracle_8_1_6 implements DynamicClass
{
More information about the jboss-svn-commits
mailing list