comparison src/org/dancres/blitz/txn/PrepCommitCommand.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.txn;
2
3 import java.io.Serializable;
4
5 import net.jini.core.transaction.server.TransactionConstants;
6
7 import org.prevayler.Command;
8 import org.prevayler.PrevalentSystem;
9
10 /**
11 Command to issue atomic prepare and commit triggered as result of
12 a transaction manager (or the SpaceImpl) invoking prepareAndCommit()
13 as opposed to the normal prepared() followed by commit()
14 */
15 class PrepCommitCommand implements Command {
16 static final long serialVersionUID = 9131472819768078508L;
17
18 private TxnState theTxn;
19
20 PrepCommitCommand(TxnState aTxn) {
21 theTxn = aTxn;
22 }
23
24 public Serializable execute(PrevalentSystem aSystem) throws Exception {
25 TxnManagerState mySystem = (TxnManagerState) aSystem;
26
27 int myResult = mySystem.prepare(theTxn);
28
29 if (myResult == TransactionConstants.PREPARED) {
30 mySystem.commit(theTxn.getId());
31 return new Integer(TransactionConstants.COMMITTED);
32 } else
33 return new Integer(myResult);
34 }
35
36 public String toString() {
37 StringBuffer myString = new StringBuffer();
38
39 myString.append(theTxn.toString());
40 myString.append("- : PC : " + theTxn.getId());
41
42 return myString.toString();
43 }
44 }