[Mulgara-svn] r135 - branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver
andrae at mulgara.org
andrae at mulgara.org
Mon Nov 20 07:41:04 UTC 2006
Author: andrae
Date: 2006-11-20 01:41:04 -0600 (Mon, 20 Nov 2006)
New Revision: 135
Modified:
branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java
branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java
Log:
All the jxunit-tests pass, resolver-test passes, the itql-test's pass.
I believe this finishes the core xafix. It does need some explicit unit-tests
to be written and run, but this commit should be considered an alpha-release of
the new transaction architecture.
In other words, please test this extensively.
Modified: branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java 2006-11-17 07:27:22 UTC (rev 134)
+++ branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java 2006-11-20 07:41:04 UTC (rev 135)
@@ -897,11 +897,7 @@
return systemResolver;
}
- void setSystemResolver(SystemResolver systemResolver) {
- this.systemResolver = systemResolver;
- }
-
/**
* Clear the cache of temporary models.
*/
Modified: branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2006-11-17 07:27:22 UTC (rev 134)
+++ branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2006-11-20 07:41:04 UTC (rev 135)
@@ -107,8 +107,6 @@
private final DatabaseMetadata metadata;
- private DatabaseOperationContext operationContext;
-
/** Security adapters this instance should enforce. */
private final List securityAdapterList;
@@ -139,8 +137,6 @@
/** The temporary model type-URI. */
private final URI temporaryModelTypeURI;
- private boolean autoCommit;
-
/**
* Construct a database session.
*
@@ -242,7 +238,6 @@
this.temporaryModelTypeURI = temporaryModelTypeURI;
this.ruleLoaderClassName = ruleLoaderClassName;
- this.operationContext = null;
if (logger.isDebugEnabled()) {
logger.debug("Constructed DatabaseSession");
}
@@ -389,14 +384,12 @@
logger.info("QUERY: " + query);
}
- // Evaluate the query
QueryOperation queryOperation = new QueryOperation(query, this);
execute(queryOperation, "Query failed");
return queryOperation.getAnswer();
}
public List query(List queryList) throws QueryException {
-
if (logger.isInfoEnabled()) {
StringBuffer log = new StringBuffer("QUERYING LIST: ");
for (int i = 0; i < queryList.size(); i++) {
@@ -472,8 +465,7 @@
// Validate parameters
if (destinationModelURI == null) {
throw new IllegalArgumentException("Null 'destinationModelURI' parameter");
- }
- if (modelExpression == null) {
+ } else if (modelExpression == null) {
throw new IllegalArgumentException("Null 'modelExpression' parameter");
}
@@ -532,7 +524,6 @@
}
try {
transactionManager.setAutoCommit(this, autoCommit);
- this.autoCommit = autoCommit;
} catch (MulgaraTransactionException em) {
throw new QueryException("Error setting autocommit", em);
}
@@ -593,13 +584,11 @@
* @param destinationURI Option URI of the file to backup into.
* @throws QueryException if the backup cannot be completed.
*/
- private synchronized void backup(OutputStream outputStream,
- URI serverURI,
- URI destinationURI) throws QueryException {
+ private synchronized void backup(OutputStream outputStream, URI serverURI, URI destinationURI)
+ throws QueryException {
execute(
new BackupOperation(outputStream, serverURI, destinationURI),
- "Unable to backup to " + destinationURI
- );
+ "Unable to backup to " + destinationURI);
}
//
@@ -637,12 +626,6 @@
private void execute(Operation operation, String errorString) throws QueryException
{
try {
- // Clear previous transaction. FIXME: This won't be necessary once we
- // support overlapping transactions.
- if (autoCommit) {
- newOperationContext(operation.isWriteOperation());
- }
-
MulgaraTransaction transaction =
transactionManager.getTransaction(this, operation.isWriteOperation());
transaction.execute(operation, resolverSessionFactory, metadata);
@@ -652,24 +635,17 @@
}
}
- // !!FIXME: needs to be updated to 1-N
public DatabaseOperationContext newOperationContext(boolean writing) throws QueryException {
- if (operationContext != null) {
- operationContext.clear();
- }
-
- operationContext = new DatabaseOperationContext(
- cachedResolverFactorySet,
- externalResolverFactoryMap,
- internalResolverFactoryMap,
- metadata,
- securityAdapterList,
- temporaryModelTypeURI,
- temporaryResolverFactory,
- symbolicTransformationList,
- systemResolverFactory,
- writing
- );
- return operationContext;
+ return new DatabaseOperationContext(
+ cachedResolverFactorySet,
+ externalResolverFactoryMap,
+ internalResolverFactoryMap,
+ metadata,
+ securityAdapterList,
+ temporaryModelTypeURI,
+ temporaryResolverFactory,
+ symbolicTransformationList,
+ systemResolverFactory,
+ writing);
}
}
Modified: branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java
===================================================================
--- branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java 2006-11-17 07:27:22 UTC (rev 134)
+++ branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java 2006-11-20 07:41:04 UTC (rev 135)
@@ -83,7 +83,6 @@
public MulgaraTransaction(MulgaraTransactionManager manager, DatabaseOperationContext context)
throws Exception {
report("Creating Transaction");
-// errorReport("Creating Transaction");
try {
if (manager == null) {
throw new IllegalArgumentException("Manager null in MulgaraTransaction");
@@ -98,10 +97,6 @@
rollback = NO_ROLLBACK;
rollbackCause = null;
-
- // FIXME: need this added to context. Allows context to cleanup caches at end of transaction.
- // this.transaction.enlistResource(context.getXAResource());
- // logger.warn("Created Transaction from: ", new Throwable());
} finally {
report("Created Transaction");
}
@@ -142,10 +137,6 @@
}
}
-
- // FIXME: Not yet certain I have the error handling right here.
- // Need to clarify semantics and ensure the error conditions are
- // properly handled.
private synchronized void deactivate() throws MulgaraTransactionException {
report("Deactivating transaction");
try {
@@ -168,8 +159,8 @@
}
}
- // Note: The transaction is often not be activated when this is called.
- // This occurs when setting autocommit off, as this creates and
+ // Note: The transaction is often not activated when these are called.
+ // This occurs when setting autocommit, as this creates and
// references a transaction object that won't be started/activated
// until it is first used.
void reference() throws MulgaraTransactionException {
@@ -206,9 +197,6 @@
resolverSessionFactory,
metadata);
} catch (Throwable th) {
- // This exception will be replaced by the exception thrown by deactivate().
- // We still throw this exception as it will abort any outer operations
- // should we be in a nested operation.
throw implicitRollback(th);
} finally {
deactivate();
@@ -266,9 +254,6 @@
}
try {
- // Not sure if this is correct - we may already be deactivated due to an
- // inner operation failing - if we are then we don't want to overwrite the
- // rollbackCause as that will most likely be the root cause of the problem.
checkActivated();
rollback = IMPLICIT_ROLLBACK;
rollbackCause = cause;
Modified: branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java
===================================================================
--- branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java 2006-11-17 07:27:22 UTC (rev 134)
+++ branches/xafix-impl/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java 2006-11-20 07:41:04 UTC (rev 135)
@@ -122,24 +122,13 @@
return userTransaction;
}
- // FIXME: Remove this once we go to 1-N.
- if (sessions.containsValue(session)) {
- throw new MulgaraTransactionException("Multiple Transactions started per session");
- }
-
try {
- if (write) {
- // Note: obtainWriteLock initiates a new transaction and stores it in userTransaction.
- sessions.put(obtainWriteLock(session), session);
- return userTransaction;
- } else {
-// FIXME: Need to finish 1-N DS-OC and provide this method - should really be newOperationContext.
- MulgaraTransaction transaction =
- new MulgaraTransaction(this, session.newOperationContext(false));
- sessions.put(transaction, session);
+ MulgaraTransaction transaction = write ?
+ obtainWriteLock(session) :
+ new MulgaraTransaction(this, session.newOperationContext(false));
+ sessions.put(transaction, session);
- return transaction;
- }
+ return transaction;
} catch (MulgaraTransactionException em) {
throw em;
} catch (Exception e) {
@@ -228,7 +217,8 @@
public synchronized void setAutoCommit(DatabaseSession session, boolean autoCommit)
throws MulgaraTransactionException {
if (session == currentWritingSession && failedSessions.contains(session)) {
- // CRITICAL ERROR - transaction failed, but we did not finalise it.
+ userTransaction.abortTransaction("Session failed and transaction not finalized",
+ new MulgaraTransactionException("Failed Session in setAutoCommit"));
}
if (session == currentWritingSession || failedSessions.contains(session)) {
@@ -300,8 +290,6 @@
}
}
- // Do we need to finish here by calling abort() on the transaction?
-
if (error != null) {
if (error instanceof MulgaraTransactionException) {
throw (MulgaraTransactionException)error;
More information about the Mulgara-svn
mailing list