List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:December 20 2007 2:23am
Subject:Rev 382: * Initial work on JTA Transaction support for better integration. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel

------------------------------------------------------------
revno: 382
revision-id:mtaylor@stripped
parent: monty@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Thu 2007-12-20 00:23:51 -0200
message:
  * Initial work on JTA Transaction support for better integration.
  * Fixed a place in NdbOperationResultsImpl where I really should have been
    using abstract methods.
added:
  java/com/mysql/cluster/ndbj/NdbJtaTransaction.java
ndbjtatransaction.ja-20071220020348-va7lrb65xv544s7l-1
  java/com/mysql/cluster/ndbj/NdbTransactionManager.java
ndbtransactionmanage-20071220020348-va7lrb65xv544s7l-2
modified:
  debian/changelog               changelog-20071219024048-xwcgy5oe2wb2dk64-2
  java/.classpath                classpath-20071116042946-npnq9g3hwm24x1ga-1
  java/Makefile.am               makefile.am-20070415032352-9dpe6aurqcnuwcrd-1
  java/com/mysql/cluster/ndbj/Ndb.java ndb.java-20070517181935-98huwjarzuh25b30-2
  java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java
ndbeventoperationres-20071028000322-kkhsnc2sdm53xm0q-1
  java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java
ndboperationresultsi-20071011074824-qn692jc6vcd81pxb-1
  java/com/mysql/cluster/ndbj/NdbTransaction.java
ndbtransaction.java-20070517181935-98huwjarzuh25b30-27
  java/swig/Ndb.i                ndb.i-20071220010513-amjnzrb6ece4xkbc-1
  java/swig/NdbTransaction.i     ndbtransaction.i-20071220010513-amjnzrb6ece4xkbc-13
=== added file 'java/com/mysql/cluster/ndbj/NdbJtaTransaction.java'
--- a/java/com/mysql/cluster/ndbj/NdbJtaTransaction.java	1970-01-01 00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbJtaTransaction.java	2007-12-20 02:23:51 +0000
@@ -0,0 +1,67 @@
+package com.mysql.cluster.ndbj;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAResource;
+
+public class NdbJtaTransaction implements Transaction {
+
+	public void commit() throws RollbackException, HeuristicMixedException,
+			HeuristicRollbackException, SecurityException,
+			IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("commit");
+
+	}
+
+	public boolean delistResource(XAResource arg0, int arg1)
+			throws IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// return false;
+		throw new NotImplementedException("delistResource");
+
+	}
+
+	public boolean enlistResource(XAResource arg0) throws RollbackException,
+			IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// return false;
+		throw new NotImplementedException("enlistResource");
+
+	}
+
+	public int getStatus() throws SystemException {
+		// TODO Auto-generated method stub
+		// return 0;
+		throw new NotImplementedException("getStatus");
+
+	}
+
+	public void registerSynchronization(Synchronization arg0)
+			throws RollbackException, IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("registerSynchronization");
+
+	}
+
+	public void rollback() throws IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("rollback");
+
+	}
+
+	public void setRollbackOnly() throws IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("setRollbackOnly");
+
+	}
+
+}

=== added file 'java/com/mysql/cluster/ndbj/NdbTransactionManager.java'
--- a/java/com/mysql/cluster/ndbj/NdbTransactionManager.java	1970-01-01 00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbTransactionManager.java	2007-12-20 02:23:51 +0000
@@ -0,0 +1,90 @@
+package com.mysql.cluster.ndbj;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+public abstract class NdbTransactionManager implements TransactionManager {
+
+	private final ThreadLocal<NdbTransaction> context = new
ThreadLocal<NdbTransaction>();
+	
+	public void begin() throws NotSupportedException, SystemException {
+
+		NdbTransaction transaction;
+		try {
+		transaction = startTransaction();
+		} catch (NdbApiException e) { 
+			throw new SystemException(e.message);
+		}
+		context.set(transaction);
+
+	}
+
+	public void commit() throws RollbackException, HeuristicMixedException,
+			HeuristicRollbackException, SecurityException,
+			IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("commit");
+
+	}
+
+	public int getStatus() throws SystemException {
+		// TODO Auto-generated method stub
+		// return 0;
+		throw new NotImplementedException("getStatus");
+
+	}
+
+	public Transaction getTransaction() throws SystemException {
+		// TODO Auto-generated method stub
+		// return null;
+		throw new NotImplementedException("getTransaction");
+
+	}
+
+	public void resume(Transaction arg0) throws InvalidTransactionException,
+			IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("resume");
+
+	}
+
+	public void rollback() throws IllegalStateException, SecurityException,
+			SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("rollback");
+
+	}
+
+	public void setRollbackOnly() throws IllegalStateException, SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("setRollbackOnly");
+
+	}
+
+	public void setTransactionTimeout(int arg0) throws SystemException {
+		// TODO Auto-generated method stub
+		// 
+		throw new NotImplementedException("setTransactionTimeout");
+
+	}
+
+	public Transaction suspend() throws SystemException {
+		// TODO Auto-generated method stub
+		// return null;
+		throw new NotImplementedException("suspend");
+
+	}
+
+	public abstract NdbTransaction startTransaction() throws NdbApiException;
+
+}

=== modified file 'debian/changelog'
--- a/debian/changelog	2007-12-20 01:16:46 +0000
+++ b/debian/changelog	2007-12-20 02:23:51 +0000
@@ -1,8 +1,11 @@
 ndb-connectors (0.5.1.22.19-1) gutsy; urgency=low
 
   * Split ndbj.i into a whole bunch of smaller files for easy of brain.
+  * Initial work on JTA Transaction support for better integration.
+  * Fixed a place in NdbOperationResultsImpl where I really should have been
+    using abstract methods.
 
- -- Monty Taylor <monty@stripped>  Wed, 19 Dec 2007 23:16:07 -0200
+ -- Monty Taylor <monty@stripped>  Thu, 20 Dec 2007 00:23:05 -0200
 
 ndb-connectors (0.5.1.22.18-1) gutsy; urgency=low
 

=== modified file 'java/.classpath'
--- a/java/.classpath	2007-12-12 13:10:28 +0000
+++ b/java/.classpath	2007-12-20 02:23:51 +0000
@@ -8,5 +8,6 @@
 	<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
 	<classpathentry kind="lib" path="lib/junit.jar"/>
 	<classpathentry kind="lib" path="/usr/lib/jvm/java-6-sun/jre/lib/rt.jar"/>
+	<classpathentry kind="lib" path="lib/jta-spec1_0_1.jar"/>
 	<classpathentry kind="output" path=""/>
 </classpath>

=== modified file 'java/Makefile.am'
--- a/java/Makefile.am	2007-12-20 01:17:13 +0000
+++ b/java/Makefile.am	2007-12-20 02:23:51 +0000
@@ -1,6 +1,6 @@
 package_namespace=com/mysql/cluster
 builddir=.
-classpath=$(srcdir):$(builddir):$(srcdir)/lib/mysql-connector-java-5.1.5-bin.jar:$(srcdir)/lib/junit.jar
+classpath=$(srcdir):$(builddir):$(srcdir)/lib/mysql-connector-java-5.1.5-bin.jar:$(srcdir)/lib/junit.jar:$(srcdir)/lib/jta-spec1_0_1.jar
 package_builddir=$(builddir)/$(package_namespace)
 package_srcdir=$(srcdir)/$(package_namespace)
 ndbapi_examples_dir=$(package_namespace)/ndbapi/examples
@@ -166,6 +166,8 @@
 	${package_srcdir}/ndbj/NdbScanFilterImpl.java \
 	${package_srcdir}/ndbj/NdbScanOperation.java \
 	${package_srcdir}/ndbj/NdbTransaction.java \
+	${package_srcdir}/ndbj/NdbJtaTransaction.java \
+	${package_srcdir}/ndbj/NdbTransactionManager.java \
 	${package_srcdir}/ndbj/NoSuchColumnException.java \
 	${package_srcdir}/ndbj/NoSuchIndexException.java \
 	${package_srcdir}/ndbj/NoSuchTableException.java \
@@ -250,6 +252,8 @@
 	${package_builddir}/ndbj/NdbScanFilterImpl.class \
 	${package_builddir}/ndbj/NdbScanOperation.class \
 	${package_builddir}/ndbj/NdbTransaction.class \
+	${package_builddir}/ndbj/NdbJtaTransaction.class \
+	${package_builddir}/ndbj/NdbTransactionManager.class \
 	${package_builddir}/ndbj/NoSuchColumnException.class \
 	${package_builddir}/ndbj/NoSuchIndexException.class \
 	${package_builddir}/ndbj/NoSuchTableException.class \

=== modified file 'java/com/mysql/cluster/ndbj/Ndb.java'
--- a/java/com/mysql/cluster/ndbj/Ndb.java	2007-12-10 07:39:46 +0000
+++ b/java/com/mysql/cluster/ndbj/Ndb.java	2007-12-20 02:23:51 +0000
@@ -1,6 +1,7 @@
 package com.mysql.cluster.ndbj;
 
 import java.math.BigInteger;
+import javax.transaction.TransactionManager;
 
 /**
  *
@@ -37,7 +38,7 @@
  * @see      NdbClusterConnection
  * @see      NdbTransaction
  */
-public interface Ndb {
+public interface Ndb extends TransactionManager {
 
 	/**
 	 * init is deprecated. Please specify max transaction in the
NdbClusterConnection.createNdb()

=== modified file 'java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java'
--- a/java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java	2007-10-28 00:05:03
+0000
+++ b/java/com/mysql/cluster/ndbj/NdbEventOperationResultsImpl.java	2007-12-20 02:23:51
+0000
@@ -5,6 +5,42 @@
 
 public class NdbEventOperationResultsImpl extends NdbOperationResultsImpl implements
NdbEventOperationResults {
 
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbOperationResultsImpl#getBlobHandle(long)
+	 */
+	@Override
+	public NdbBlob getBlobHandle(long columnId) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbOperationResultsImpl#getBlobHandle(java.lang.String)
+	 */
+	@Override
+	public NdbBlob getBlobHandle(String columnName) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbOperationResultsImpl#realGetValue(long)
+	 */
+	@Override
+	protected NdbRecAttr realGetValue(long columnId) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+	/* (non-Javadoc)
+	 * @see
com.mysql.cluster.ndbj.NdbOperationResultsImpl#realGetValue(com.mysql.cluster.ndbj.NdbColumn)
+	 */
+	@Override
+	protected NdbRecAttr realGetValue(NdbColumn theColumn) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+	/* (non-Javadoc)
+	 * @see com.mysql.cluster.ndbj.NdbOperationResultsImpl#realGetValue(java.lang.String)
+	 */
+	@Override
+	protected NdbRecAttr realGetValue(String columnName) throws NdbApiException {
+		throw new RuntimeException("undefined class");
+	}
+
 	protected Map<String,NdbRecAttr> preResultSet;
 	protected Map<String,NdbBlob> preBlobResultSet;
 	protected NdbRecAttr realGetPreValue(long columnId) throws NdbApiException {

=== modified file 'java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java'
--- a/java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java	2007-12-14 18:13:30 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbOperationResultsImpl.java	2007-12-20 02:23:51 +0000
@@ -3,31 +3,20 @@
 import java.util.Map;
 import java.util.HashMap;
 
-public class NdbOperationResultsImpl implements NdbOperationResults {
+public abstract class NdbOperationResultsImpl implements NdbOperationResults {
 
 
 	protected NdbResultSet theResultSet; 
 	protected Map<String,NdbRecAttr> resultSet;
 	protected Map<String,NdbBlob> blobResultSet;
 
-	protected NdbRecAttr realGetValue(long columnId) throws NdbApiException {
-		throw new RuntimeException("undefined class");
-	}
-	protected NdbRecAttr realGetValue(String columnName) throws NdbApiException { 
-		throw new RuntimeException("undefined class");
-	}
-	protected NdbRecAttr realGetValue(NdbColumn theColumn) throws NdbApiException {
-		throw new RuntimeException("undefined class");
-	}
-	public NdbBlob getBlobHandle(long columnId)
-	throws NdbApiException { 
-		throw new RuntimeException("undefined class");
-	}
-
-	public NdbBlob getBlobHandle(String columnName)
-	throws NdbApiException{ 
-		throw new RuntimeException("undefined class");
-	}
+	protected abstract NdbRecAttr realGetValue(long columnId) throws NdbApiException; 
+	protected abstract NdbRecAttr realGetValue(String columnName) throws NdbApiException;
+	protected abstract NdbRecAttr realGetValue(NdbColumn theColumn) throws NdbApiException;
+	
+	public abstract NdbBlob getBlobHandle(long columnId) throws NdbApiException;
+	public abstract NdbBlob getBlobHandle(String columnName) throws NdbApiException;
+	
 	
 	public NdbOperationResultsImpl() { 
 		super();

=== modified file 'java/com/mysql/cluster/ndbj/NdbTransaction.java'
--- a/java/com/mysql/cluster/ndbj/NdbTransaction.java	2007-12-10 07:39:46 +0000
+++ b/java/com/mysql/cluster/ndbj/NdbTransaction.java	2007-12-20 02:23:51 +0000
@@ -1,6 +1,7 @@
 package com.mysql.cluster.ndbj;
 
 import java.math.BigInteger;
+import javax.transaction.Transaction;
 
 /**
  * A transaction (represented by an NdbTransaction object) 
@@ -73,7 +74,7 @@
  * @see com.mysql.cluster.ndbj.NdbIndexScanOperation
  * 
  */
-public interface NdbTransaction {
+public interface NdbTransaction extends Transaction {
 
 	
 

=== modified file 'java/swig/Ndb.i'
--- a/java/swig/Ndb.i	2007-12-20 01:16:46 +0000
+++ b/java/swig/Ndb.i	2007-12-20 02:23:51 +0000
@@ -18,6 +18,7 @@
 */
 
 %typemap(javainterfaces) Ndb "Ndb"; 
+%typemap(javabase) Ndb "NdbTransactionManager";
 
 %javamethodmodifiers Ndb::closeTransaction "protected";
 

=== modified file 'java/swig/NdbTransaction.i'
--- a/java/swig/NdbTransaction.i	2007-12-20 01:16:46 +0000
+++ b/java/swig/NdbTransaction.i	2007-12-20 02:23:51 +0000
@@ -18,6 +18,7 @@
 */
 
 %typemap(javainterfaces) NdbTransaction "NdbTransaction";
+%typemap(javabase) NdbTransaction "NdbJtaTransaction";
 
 %rename(realClose) NdbTransaction::close;
 %typemap(javacode) NdbTransaction %{

Thread
Rev 382: * Initial work on JTA Transaction support for better integration. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/develMonty Taylor20 Dec