[Mulgara-svn] r523 - branches/nw-interface/src/jar/query/java/org/mulgara/query/operation
pag at mulgara.org
pag at mulgara.org
Tue Nov 6 21:57:04 UTC 2007
Author: pag
Date: 2007-11-06 15:57:04 -0600 (Tue, 06 Nov 2007)
New Revision: 523
Modified:
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
Log:
Defined local operations more carefully, making commit and rollback local. Also added a flag for indicating locality for commands.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -27,7 +27,15 @@
public interface Command {
/**
+ * Indicates that the command modifies the state in a transaction.
+ * @return <code>true</code> If the transaction state is to be modified.
+ */
+ boolean isTxOperation();
+
+ /**
* Indicates if an AST element is an operation for a local client.
+ * Local operations do not create a connection to a server, though they
+ * can modify the state of existing connections.
* @return <code>true</code> if the operation is only relevant to a client.
*/
boolean isLocalOperation();
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Commit.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -15,6 +15,7 @@
import org.mulgara.connection.Connection;
import org.mulgara.query.QueryException;
+import org.mulgara.server.Session;
/**
@@ -33,8 +34,14 @@
* @throws QueryException There was a server error commiting the transaction.
*/
public Object execute(Connection conn) throws QueryException {
- conn.getSession().commit();
- return setResultMessage("Successfully committed transaction");
+ Session session = conn.getSession();
+ if (session != null) {
+ session.commit();
+ return setResultMessage("Successfully committed transaction");
+ } else {
+ assert conn instanceof org.mulgara.connection.DummyConnection;
+ return setResultMessage("Skipped commit for internal connection");
+ }
}
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -28,6 +28,14 @@
private String resultMessage = "";
/**
+ * Indicates that the command modifies the state in a transaction.
+ * @return <code>true</code> If the transaction state is to be modified.
+ */
+ public boolean isTxOperation() {
+ return false;
+ }
+
+ /**
* Indicates that this operation is local.
* @return Always <code>true</code> to indicate this command is local.
*/
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -54,6 +54,15 @@
/**
+ * Indicates that the command modifies the state in a transaction.
+ * @return <code>true</code> If the transaction state is to be modified.
+ */
+ public boolean isTxOperation() {
+ return false;
+ }
+
+
+ /**
* Indicates that this operation is not local.
* @return Always <code>false</code> to indicate this command is not local.
*/
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -22,7 +22,7 @@
*/
public class SetAutoCommit extends BooleanSetCommand {
- private static final String MESSAGE = "Autocommit has been set: ";
+ private static final String MESSAGE = "Auto commit is ";
/**
* Create a command to set autocommit on or off.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java 2007-11-06 21:55:22 UTC (rev 522)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java 2007-11-06 21:57:04 UTC (rev 523)
@@ -15,26 +15,29 @@
import java.net.URI;
/**
- * An AST element for controlling transactions.
+ * An AST element for controlling transactions. These commands are considered
+ * local, as they do not establish a new connection to a server. However, if
+ * there are any known connections in the current transaction, then the
+ * command will update them.
*
* @created 2007-08-09
* @author Paul Gearon
* @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
* @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
*/
-public abstract class TransactionCommand implements Command {
+public abstract class TransactionCommand extends LocalCommand {
/** An optional message that can be returned to a UI after execution. */
private String resultMessage = "";
/**
- * Indicates that this operation may require network access.
- * @return <code>false</code> as network access may be needed.
+ * Indicates that the command modifies the state in a transaction.
+ * @return <code>true</code> If the transaction state is to be modified.
*/
- public boolean isLocalOperation() {
- return false;
+ public final boolean isTxOperation() {
+ return true;
}
-
+
/**
* Indicates that this operation is not specific to a UI.
* @return <code>false</code> as operation is not specific to UIs.
More information about the Mulgara-svn
mailing list