ozeigermann 2003/12/18 06:14:48
Modified: src/stores/org/apache/slide/store/impl/rdbms
AbstractRDBMSStore.java J2EEStore.java
Log:
You can now configure whether the TM commits / rolls
back the transaction or if this has to be done by the store. Default is
the store does it as this is the way Slide's TM handles it. This is needed to
make it work with external TMs like the the one from JBoss
Revision Changes Path
1.2 +23 -15
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
Index: AbstractRDBMSStore.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractRDBMSStore.java 3 Dec 2003 12:00:46 -0000 1.1
+++ AbstractRDBMSStore.java 18 Dec 2003 14:14:48 -0000 1.2
@@ -118,7 +118,6 @@
extends AbstractXAService
implements LockStore, NodeStore, RevisionDescriptorsStore,
RevisionDescriptorStore, SecurityStore, ContentStore {
- // FIXED needs a log channel of its own
protected String LOG_CHANNEL = this.getClass().getName();
protected static final int TX_IDLE = 0;
@@ -134,6 +133,13 @@
protected boolean alreadyInitialized = false;
/**
+ * Indicates whether the transaction manager will commit / rollback
+ * the transaction or the store is in charge of it. Slide's internal
+ * TM does not commit / rollback, but TMs more aligned to the spec (e.g. JBoss'
TM) do.
+ */
+ protected boolean tmCommits = false;
+
+ /**
* Initializes the data source with a set of parameters.
*
* @param parameters Hashtable containing the parameters' name
@@ -162,7 +168,6 @@
}
}
- // FIXED: pass parameters to adapters as well
if (adapter != null) {
adapter.setParameters(parameters);
}
@@ -342,14 +347,15 @@
}
try {
- if (id.rollbackOnly) {
+ if (!tmCommits) {
+ if (id.rollbackOnly) {
- conn.rollback();
- } else {
- conn.commit();
+ conn.rollback();
+ } else {
+ conn.commit();
+ }
}
activeTransactionContext.set(null);
-
} catch (Exception e) {
throw new XAException(XAException.XA_RBCOMMFAIL);
} finally {
@@ -390,9 +396,12 @@
}
try {
- conn.rollback();
+ if (!tmCommits) {
+ conn.rollback();
+ }
activeTransactionContext.set(null);
- } catch (SQLException e) {
+
+ } catch (Exception e) {
throw new XAException(XAException.XA_HEURCOM);
} finally {
try {
@@ -821,11 +830,10 @@
} catch (SQLException e) {
throw new ServiceAccessException(this, e);
} finally {
- // has to be done in adapter or upon closing of stream
+ // will be done in adapter or upon closing of stream
/*
if (connection != null) {
try {
- // FIXME this really should not work, as we might have a
stream not yet closed when compression if turned off
connection.close();
} catch (SQLException e) {
getLogger().log(e, LOG_CHANNEL, Logger.WARNING);
1.10 +9 -4
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/J2EEStore.java
Index: J2EEStore.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/J2EEStore.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- J2EEStore.java 3 Dec 2003 12:00:46 -0000 1.9
+++ J2EEStore.java 18 Dec 2003 14:14:48 -0000 1.10
@@ -131,6 +131,11 @@
}
datasource = value;
+ value = (String) parameters.get("tm-commits");
+ if (value != null) {
+ tmCommits = "true".equals(value);
+ }
+
super.setParameters(parameters);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]