|
From: <pe...@us...> - 2003-12-01 17:11:04
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv9746/org/neuclear/ledger
Modified Files:
Ledger.java PostedTransaction.java UnPostedTransaction.java
Log Message:
Added initial Support for entityengine (OFBiz)
Index: Ledger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Ledger.java 21 Nov 2003 04:43:20 -0000 1.7
--- Ledger.java 1 Dec 2003 17:11:01 -0000 1.8
***************
*** 4,7 ****
--- 4,10 ----
* $Id$
* $Log$
+ * Revision 1.8 2003/12/01 17:11:01 pelle
+ * Added initial Support for entityengine (OFBiz)
+ *
* Revision 1.7 2003/11/21 04:43:20 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 102,106 ****
--- 105,112 ----
import org.neuclear.commons.configuration.Configuration;
import org.neuclear.commons.configuration.ConfigurationException;
+ import org.neuclear.commons.sql.SQLTools;
+ import javax.transaction.*;
+ import javax.naming.NamingException;
import java.util.Date;
import java.util.Iterator;
***************
*** 226,255 ****
/**
- * Use this to indicate to the underlying system that we want to start a database transaction.
- * If implementing ledger supports Transactions in the database layer this implements it.
- */
- public abstract void beginLinkedTransaction();
-
- /**
- * Use this to indicate to the underlying system that we want to end a database transaction.
- * If implementing ledger supports Transactions in the database layer this implements it.
- */
- public abstract void endLinkedTransactions();
-
- /**
- * Ledger Implementations use this to create Transactions.
- * The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
- * other implementations.
- * @param comment
- * @param transactionTime
- * @param expiryTime
- * @param xid
- * @return PostedTransaction
- */
- /* protected final PostedTransaction createTransaction(String comment,Date transactionTime, Date expiryTime,String xid) throws TransactionException {
- return new PostedTransaction(this,comment,transactionTime,expiryTime,xid);
- }
- */
- /**
* Ledger Implementations use this to create Transactions.
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
--- 232,235 ----
***************
*** 285,289 ****
try {
- beginLinkedTransaction();
//PostedTransaction rev=hold.reverse(comment); // We dont need to reverse this
final UnPostedTransaction tran = new UnPostedTransaction(this, comment, time);
--- 265,268 ----
***************
*** 296,302 ****
tran.addItem(item.getBook(), -amount);
}
! endLinkedTransactions();
! return tran.post();
} catch (UnBalancedTransactionException e) {
throw new LowlevelLedgerException(this, e);
}
--- 275,282 ----
tran.addItem(item.getBook(), -amount);
}
! final PostedTransaction postedTransaction = tran.post();
! return postedTransaction;
} catch (UnBalancedTransactionException e) {
+ rollbackUT();
throw new LowlevelLedgerException(this, e);
}
***************
*** 341,344 ****
--- 321,389 ----
public static Ledger getInstance() throws ConfigurationException {
return (Ledger) Configuration.getComponent(Ledger.class, "neuclear-ledger");
+ }
+
+ /**
+ * Begins a JTA UserTransaction on the ledger. Not to be confused with a Ledger Transaction.
+ *
+ * @throws LowlevelLedgerException
+ */
+
+ public UserTransaction beginUT() throws LowlevelLedgerException {
+ try {
+ UserTransaction ut=SQLTools.getUserTransaction();
+ if (ut.getStatus()==Status.STATUS_NO_TRANSACTION)
+ ut.begin();
+ return ut;
+ } catch (NamingException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (SystemException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (NotSupportedException e) {
+ throw new LowlevelLedgerException(this, e);
+ }
+ }
+
+ /**
+ * Commits a JTA UserTransaction on the ledger. Not to be confused with a Ledger Transaction.
+ *
+ * @param ut
+ * @throws LowlevelLedgerException
+ */
+ public void commitUT(UserTransaction ut) throws LowlevelLedgerException {
+ try {
+ ut.commit();
+ } catch (RollbackException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (HeuristicMixedException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (HeuristicRollbackException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (SystemException e) {
+ throw new LowlevelLedgerException(this, e);
+ }
+ }
+
+ /**
+ * Rolls back a JTA UserTransaction on the ledger. Not to be confused with a Ledger Transaction.
+ *
+ * @param ut
+ * @throws LowlevelLedgerException
+ */
+ public void rollbackUT(UserTransaction ut) throws LowlevelLedgerException {
+ try {
+ ut.rollback();
+ } catch (SystemException e) {
+ throw new LowlevelLedgerException(this, e);
+ }
+ }
+
+ public void rollbackUT() throws LowlevelLedgerException {
+ try {
+ rollbackUT(SQLTools.getUserTransaction());
+ } catch (NamingException e) {
+ throw new LowlevelLedgerException(this, e);
+ } catch (SystemException e) {
+ throw new LowlevelLedgerException(this, e);
+ }
}
}
Index: PostedTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/PostedTransaction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PostedTransaction.java 21 Nov 2003 04:43:20 -0000 1.4
--- PostedTransaction.java 1 Dec 2003 17:11:01 -0000 1.5
***************
*** 7,10 ****
--- 7,13 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/12/01 17:11:01 pelle
+ * Added initial Support for entityengine (OFBiz)
+ *
* Revision 1.4 2003/11/21 04:43:20 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 49,52 ****
--- 52,56 ----
*/
+ import javax.transaction.UserTransaction;
import java.util.Date;
import java.util.Iterator;
***************
*** 114,118 ****
*/
final PostedTransaction revise(final Date transactionTime, final String comment) throws InvalidTransactionException, UnBalancedTransactionException, LowlevelLedgerException {
- getLedger().beginLinkedTransaction();
final PostedTransaction rev=reverse(comment);
final UnPostedTransaction tran=new UnPostedTransaction(getLedger(),comment,transactionTime,false);
--- 118,121 ----
***************
*** 122,126 ****
tran.addItem(item.getBook(),item.getAmount());
}
- getLedger().endLinkedTransactions();
return tran.post();
}
--- 125,128 ----
***************
*** 132,139 ****
*/
final PostedTransaction revise(final UnPostedTransaction revised) throws InvalidTransactionException, UnBalancedTransactionException, LowlevelLedgerException {
- getLedger().beginLinkedTransaction();
reverse("REVERSE"+revised.getComment());
final PostedTransaction tran=revised.post();
- getLedger().endLinkedTransactions();
return tran;
}
--- 134,139 ----
Index: UnPostedTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/UnPostedTransaction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** UnPostedTransaction.java 21 Nov 2003 04:43:20 -0000 1.6
--- UnPostedTransaction.java 1 Dec 2003 17:11:01 -0000 1.7
***************
*** 8,11 ****
--- 8,14 ----
* $Id$
* $Log$
+ * Revision 1.7 2003/12/01 17:11:01 pelle
+ * Added initial Support for entityengine (OFBiz)
+ *
* Revision 1.6 2003/11/21 04:43:20 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 106,112 ****
PostedTransaction postTransaction = null;
if (isBalanced()) {
- getLedger().beginLinkedTransaction();
postTransaction = postTransaction();
- getLedger().endLinkedTransactions();
} else
throw new UnBalancedTransactionException(getLedger(), this);
--- 109,113 ----
|