You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/14 23:36:45 UTC
git commit: ISIS-838: simpler API for AbstractIsisSessionTemplate.
Repository: isis
Updated Branches:
refs/heads/master 877e7eddf -> 27e2596c4
ISIS-838: simpler API for AbstractIsisSessionTemplate.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/27e2596c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/27e2596c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/27e2596c
Branch: refs/heads/master
Commit: 27e2596c475ee380c78c3a17e9cd8cb33f968f6e
Parents: 877e7ed
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Jul 14 22:17:20 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jul 14 22:17:20 2014 +0100
----------------------------------------------------------------------
.../AbstractIsisSessionTemplate.java | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/27e2596c/core/runtime/src/main/java/org/apache/isis/core/runtime/sessiontemplate/AbstractIsisSessionTemplate.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/sessiontemplate/AbstractIsisSessionTemplate.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/sessiontemplate/AbstractIsisSessionTemplate.java
index eba6543..9d5fb2a 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/sessiontemplate/AbstractIsisSessionTemplate.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/sessiontemplate/AbstractIsisSessionTemplate.java
@@ -24,6 +24,7 @@ import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.session.IsisSession;
import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosureAbstract;
public abstract class AbstractIsisSessionTemplate {
@@ -41,12 +42,41 @@ public abstract class AbstractIsisSessionTemplate {
}
}
+
// //////////////////////////////////////
/**
- * Mandatory hook.
+ * Either override {@link #doExecute(Object)} (this method) or alternatively override
+ * {@link #doExecuteWithTransaction(Object)}.
+ *
+ * <p>
+ * This method is called within a current {@link org.apache.isis.core.runtime.system.session.IsisSession session},
+ * but with no current transaction. The default implementation sets up a
+ * {@link org.apache.isis.core.runtime.system.transaction.IsisTransaction transaction}
+ * and then calls {@link #doExecuteWithTransaction(Object)}. Override if you require more sophisticated
+ * transaction handling.
+ */
+ protected void doExecute(final Object context) {
+ final PersistenceSession persistenceSession = getPersistenceSession();
+ final IsisTransactionManager transactionManager = getTransactionManager(persistenceSession);
+ transactionManager.executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ doExecuteWithTransaction(context);
+ }
+ });
+ }
+
+ /**
+ * Either override {@link #doExecuteWithTransaction(Object)} (this method) or alternatively override
+ * {@link #doExecuteWithTransaction(Object)}.
+ *
+ * <p>
+ * This method is called within a current
+ * {@link org.apache.isis.core.runtime.system.transaction.IsisTransaction transaction}, by the default
+ * implementation of {@link #doExecute(Object)}.
*/
- protected abstract void doExecute(Object context);
+ protected void doExecuteWithTransaction(final Object context) {}
// //////////////////////////////////////