From 20851907c2971f377cd99236aea5376a5af81780 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 25 Jan 2005 15:59:14 +0000 Subject: [PATCH] Implement res.commit() and res.abort() methods. res.commit() commits all changes to DB and starts a new transaction. res.abort() aborts the current transaction and request. --- src/helma/framework/ResponseBean.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/helma/framework/ResponseBean.java b/src/helma/framework/ResponseBean.java index f79c57db..5c369abc 100644 --- a/src/helma/framework/ResponseBean.java +++ b/src/helma/framework/ResponseBean.java @@ -16,6 +16,8 @@ package helma.framework; +import helma.objectmodel.db.Transactor; + import java.io.Serializable; import java.util.Date; import java.util.Map; @@ -436,4 +438,28 @@ public class ResponseBean implements Serializable { return res.popStringBuffer(); } + /** + * Commit changes made during the course of the current transaction + * and start a new one + * + * @throws Exception + */ + public void commit() throws Exception { + if (Thread.currentThread() instanceof Transactor) { + Transactor tx = (Transactor) Thread.currentThread(); + String tname = tx.getTransactionName(); + tx.commit(); + tx.begin(tname); + } + } + + /** + * Abort the current transaction by throwing an Error + * + * @throws AbortException + */ + public void abort() throws AbortException { + throw new AbortException(); + } + }