This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch ISIS-1976-rethink-object-adapters
in repository https://gitbox.apache.org/repos/asf/isis.git

commit f1e233be8e53ae344af56ff3dd9d764eb3338243
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Mon Sep 10 12:08:43 2018 +0200

    ISIS-1976: removing TransactionalClosures
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
 ...ctionInvocationFacetForDomainEventAbstract.java |  17 +---
 ...tySetterOrClearFacetForDomainEventAbstract.java |  14 +--
 .../PersistenceSessionServiceInternal.java         |  10 +-
 .../PersistenceSessionServiceInternalNoop.java     |  15 ++-
 .../system/transaction/TransactionalClosure.java   |  25 -----
 .../system/persistence/PersistenceSession4.java    |  41 ++------
 .../system/persistence/PersistenceSession5.java    |  35 +------
 .../PersistenceSessionServiceInternalDefault.java  |  14 ++-
 .../AbstractIsisSessionTemplate.java               |  10 +-
 .../system/persistence/PersistenceSession.java     | 113 +++++++++++----------
 .../system/transaction/IsisTransactionManager.java |  24 +++--
 .../transaction/TransactionalClosureAbstract.java  |  30 ------
 .../TransactionalClosureWithReturn.java            |  25 -----
 .../TransactionalClosureWithReturnAbstract.java    |  30 ------
 .../ui/pages/accmngt/register/RegisterPanel.java   |   6 +-
 15 files changed, 128 insertions(+), 281 deletions(-)

diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 997ef69..11ec2ef 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -83,7 +83,6 @@ import 
org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.Contributed;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.metamodel.specloader.specimpl.MixedInMember2;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 import org.apache.isis.schema.ixn.v1.ActionInvocationDto;
 
 public abstract class ActionInvocationFacetForDomainEventAbstract
@@ -159,18 +158,10 @@ implements ImperativeFacet {
             final ObjectAdapter[] argumentAdapters,
             final InteractionInitiatedBy interactionInitiatedBy) {
 
-        final ObjectAdapter[] holder = new ObjectAdapter[1];
-
-        getPersistenceSessionServiceInternal().executeWithinTransaction(
-                new TransactionalClosure(){
-                    @Override
-                    public void execute() {
-                        holder[0] = doInvoke(owningAction, targetAdapter, 
mixedInAdapter, argumentAdapters, interactionInitiatedBy);
-
-                    }
-                }
-                );
-        return holder[0];
+        final ObjectAdapter holder = 
+                
getPersistenceSessionServiceInternal().executeWithinTransaction(()->
+                    doInvoke(owningAction, targetAdapter, mixedInAdapter, 
argumentAdapters, interactionInitiatedBy));
+        return holder;
     }
 
     ObjectAdapter doInvoke(
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
index 84b5ee1..bb2df98 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/property/modify/PropertySetterOrClearFacetForDomainEventAbstract.java
@@ -48,7 +48,6 @@ import 
org.apache.isis.core.metamodel.services.ixn.InteractionDtoServiceInternal
 import 
org.apache.isis.core.metamodel.services.persistsession.PersistenceSessionServiceInternal;
 import 
org.apache.isis.core.metamodel.services.publishing.PublishingServiceInternal;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 import org.apache.isis.schema.ixn.v1.PropertyEditDto;
 
 public abstract class PropertySetterOrClearFacetForDomainEventAbstract
@@ -161,16 +160,9 @@ extends SingleValueFacetAbstract<Class<? extends 
PropertyDomainEvent<?,?>>> {
             final ObjectAdapter newValueAdapter,
             final InteractionInitiatedBy interactionInitiatedBy) {
 
-        getPersistenceSessionServiceInternal().executeWithinTransaction(
-                new TransactionalClosure(){
-                    @Override
-                    public void execute() {
-                        doSetOrClearProperty(style, owningProperty, 
targetAdapter, newValueAdapter, interactionInitiatedBy);
-                    }
-                }
-                );
-
-
+        getPersistenceSessionServiceInternal().executeWithinTransaction(()->{
+            doSetOrClearProperty(style, owningProperty, targetAdapter, 
newValueAdapter, interactionInitiatedBy);
+        });
 
     }
 
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternal.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternal.java
index 506ca6e..65509a9 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternal.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternal.java
@@ -18,6 +18,7 @@ package 
org.apache.isis.core.metamodel.services.persistsession;
 
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.function.Supplier;
 
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.query.Query;
@@ -29,7 +30,6 @@ import org.apache.isis.applib.services.xactn.TransactionState;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapterProvider;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 
 public interface PersistenceSessionServiceInternal extends 
ObjectAdapterProvider.Delegating {
     
@@ -148,8 +148,6 @@ public interface PersistenceSessionServiceInternal extends 
ObjectAdapterProvider
     @Programmatic
     void remove(ObjectAdapter adapter);
 
-
-
     // -- allMatchingQuery, firstMatchingQuery
     /**
      * Provided by <tt>PersistenceSession</tt> when used by framework.
@@ -170,6 +168,10 @@ public interface PersistenceSessionServiceInternal extends 
ObjectAdapterProvider
     @Programmatic
     <T> ObjectAdapter firstMatchingQuery(Query<T> query);
 
-    void executeWithinTransaction(TransactionalClosure transactionalClosure);
+    @Programmatic
+    void executeWithinTransaction(Runnable task);
+    
+    @Programmatic
+    <T> T executeWithinTransaction(Supplier<T> task);
 
 }
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternalNoop.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternalNoop.java
index 86dfefb..3bc7c55 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternalNoop.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/persistsession/PersistenceSessionServiceInternalNoop.java
@@ -20,6 +20,7 @@ package 
org.apache.isis.core.metamodel.services.persistsession;
 
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.function.Supplier;
 
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
@@ -32,7 +33,6 @@ import org.apache.isis.applib.services.xactn.TransactionState;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapterProvider;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 
 @DomainService(
         nature = NatureOfService.DOMAIN,
@@ -108,8 +108,15 @@ public class PersistenceSessionServiceInternalNoop 
implements PersistenceSession
     }
 
     @Override
-    public void executeWithinTransaction(TransactionalClosure 
transactionalClosure) {
-        transactionalClosure.execute();
+    public void executeWithinTransaction(Runnable task) {
+        //[ahuber] was task.run();
+        throw new UnsupportedOperationException("Not supported by this 
implementation of PersistenceSessionServiceInternal");
+    }
+    
+    @Override
+    public <T> T executeWithinTransaction(Supplier<T> task) {
+        //[ahuber] was return task.get();
+        throw new UnsupportedOperationException("Not supported by this 
implementation of PersistenceSessionServiceInternal");
     }
 
     @Override
@@ -150,4 +157,6 @@ public class PersistenceSessionServiceInternalNoop 
implements PersistenceSession
 
 
 
+
+
 }
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosure.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosure.java
deleted file mode 100644
index ef88b55..0000000
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosure.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.system.transaction;
-
-public interface TransactionalClosure {
-
-    public void execute();
-}
diff --git 
a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
 
b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
index 390853a..8af6150 100644
--- 
a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
+++ 
b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
@@ -109,8 +109,6 @@ import 
org.apache.isis.core.runtime.system.persistence.adaptermanager.ObjectAdap
 import 
org.apache.isis.core.runtime.system.persistence.adaptermanager.ObjectAdapterContext.MementoRecreateObjectSupport;
 import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-import 
org.apache.isis.core.runtime.system.transaction.TransactionalClosureWithReturn;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusDeleteObjectCommand;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor;
@@ -381,12 +379,7 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         final PersistenceQueryProcessor<? extends PersistenceQuery> processor 
= lookupProcessorFor(persistenceQuery);
 
         final List<ObjectAdapter> instances = 
transactionManager.executeWithinTransaction(
-                new TransactionalClosureWithReturn<List<ObjectAdapter>>() {
-                    @Override
-                    public List<ObjectAdapter> execute() {
-                        return processPersistenceQuery(processor, 
persistenceQuery);
-                    }
-                });
+                ()->processPersistenceQuery(processor, persistenceQuery) );
         final ObjectSpecification specification = 
persistenceQuery.getSpecification();
         final FreeStandingList results = new FreeStandingList(specification, 
instances);
         return adapterFor(results);
@@ -690,14 +683,11 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         }
 
         return transactionManager.executeWithinTransaction(
-                new TransactionalClosureWithReturn<ObjectAdapter>() {
-                    @Override
-                    public ObjectAdapter execute() {
+                ()-> {
                         LOG.debug("getObject; oid={}", oid);
 
                         final Object pojo = fetchPersistentPojo(oid);
                         return 
objectAdapterContext.addRecreatedPojoToCache(oid, pojo);
-                    }
                 });
     }
 
@@ -809,11 +799,7 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
      */
     private void refreshRootInTransaction(final ObjectAdapter adapter) {
         Assert.assertTrue("only resolve object that is persistent", adapter, 
adapter.representsPersistent());
-        getTransactionManager().executeWithinTransaction(new 
TransactionalClosure() {
-
-            @Override
-            public void execute() {
-
+        getTransactionManager().executeWithinTransaction(()->{
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("resolveImmediately; oid={}", 
adapter.getOid().enString());
                 }
@@ -826,8 +812,6 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
                 }
 
                 refreshRoot(adapter);
-            }
-
         });
     }
 
@@ -891,16 +875,8 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             throw new NotPersistableException("Cannot persist services: " + 
adapter);
         }
 
-        getTransactionManager().executeWithinTransaction(new 
TransactionalClosure() {
-
-            @Override
-            public void execute() {
+        getTransactionManager().executeWithinTransaction(()->{
                 makePersistentTransactionAssumed(adapter);
-
-                // clear out the map of transient -> persistent
-                // already empty // 
PersistenceSession5.this.persistentByTransient.clear();
-            }
-
         });
     }
 
@@ -955,12 +931,9 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             return;
         }
         LOG.debug("destroyObject {}", adapter);
-        transactionManager.executeWithinTransaction(new TransactionalClosure() 
{
-            @Override
-            public void execute() {
-                final DestroyObjectCommand command = 
newDestroyObjectCommand(adapter);
-                transactionManager.addCommand(command);
-            }
+        transactionManager.executeWithinTransaction(()->{
+            final DestroyObjectCommand command = 
newDestroyObjectCommand(adapter);
+            transactionManager.addCommand(command);
         });
     }
 
diff --git 
a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
 
b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
index 0fae449..2e94fa3 100644
--- 
a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
+++ 
b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
@@ -109,8 +109,6 @@ import 
org.apache.isis.core.runtime.system.persistence.adaptermanager.ObjectAdap
 import 
org.apache.isis.core.runtime.system.persistence.adaptermanager.ObjectAdapterContext.MementoRecreateObjectSupport;
 import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
-import 
org.apache.isis.core.runtime.system.transaction.TransactionalClosureWithReturn;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusDeleteObjectCommand;
 import 
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor;
@@ -379,12 +377,7 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         final PersistenceQueryProcessor<? extends PersistenceQuery> processor 
= lookupProcessorFor(persistenceQuery);
 
         final List<ObjectAdapter> instances = 
transactionManager.executeWithinTransaction(
-                new TransactionalClosureWithReturn<List<ObjectAdapter>>() {
-                    @Override
-                    public List<ObjectAdapter> execute() {
-                        return processPersistenceQuery(processor, 
persistenceQuery);
-                    }
-                });
+                ()->processPersistenceQuery(processor, persistenceQuery) );
         final ObjectSpecification specification = 
persistenceQuery.getSpecification();
         final FreeStandingList results = new FreeStandingList(specification, 
instances);
         return adapterFor(results);
@@ -688,14 +681,11 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         }
 
         return transactionManager.executeWithinTransaction(
-                new TransactionalClosureWithReturn<ObjectAdapter>() {
-                    @Override
-                    public ObjectAdapter execute() {
+                ()-> {
                         LOG.debug("getObject; oid={}", oid);
 
                         final Object pojo = fetchPersistentPojo(oid);
                         return 
objectAdapterContext.addRecreatedPojoToCache(oid, pojo);
-                    }
                 });
     }
 
@@ -807,11 +797,7 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
      */
     private void refreshRootInTransaction(final ObjectAdapter adapter) {
         Assert.assertTrue("only resolve object that is persistent", adapter, 
adapter.representsPersistent());
-        getTransactionManager().executeWithinTransaction(new 
TransactionalClosure() {
-
-            @Override
-            public void execute() {
-
+        getTransactionManager().executeWithinTransaction(()->{
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("resolveImmediately; oid={}", 
adapter.getOid().enString());
                 }
@@ -824,8 +810,6 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
                 }
 
                 refreshRoot(adapter);
-            }
-
         });
     }
 
@@ -889,16 +873,10 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             throw new NotPersistableException("Cannot persist services: " + 
adapter);
         }
 
-        getTransactionManager().executeWithinTransaction(new 
TransactionalClosure() {
-
-            @Override
-            public void execute() {
+        getTransactionManager().executeWithinTransaction(()->{
                 makePersistentTransactionAssumed(adapter);
-
                 // clear out the map of transient -> persistent
                 // already empty // 
PersistenceSession5.this.persistentByTransient.clear();
-            }
-
         });
     }
 
@@ -953,12 +931,9 @@ implements 
IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             return;
         }
         LOG.debug("destroyObject {}", adapter);
-        transactionManager.executeWithinTransaction(new TransactionalClosure() 
{
-            @Override
-            public void execute() {
+        transactionManager.executeWithinTransaction(()->{
                 final DestroyObjectCommand command = 
newDestroyObjectCommand(adapter);
                 transactionManager.addCommand(command);
-            }
         });
     }
 
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/persistsession/PersistenceSessionServiceInternalDefault.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/persistsession/PersistenceSessionServiceInternalDefault.java
index 5ee3b82..1d9f192 100644
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/persistsession/PersistenceSessionServiceInternalDefault.java
+++ 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/persistsession/PersistenceSessionServiceInternalDefault.java
@@ -23,6 +23,7 @@ import static java.util.Optional.ofNullable;
 
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.function.Supplier;
 
 import org.apache.isis.applib.NonRecoverableException;
 import org.apache.isis.applib.annotation.DomainService;
@@ -46,7 +47,6 @@ import 
org.apache.isis.core.runtime.system.session.IsisSession;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 
 @DomainService(
         nature = NatureOfService.DOMAIN,
@@ -172,8 +172,13 @@ public class PersistenceSessionServiceInternalDefault 
implements PersistenceSess
     }
 
     @Override
-    public void executeWithinTransaction(TransactionalClosure 
transactionalClosure) {
-        getTransactionManager().executeWithinTransaction(transactionalClosure);
+    public void executeWithinTransaction(Runnable task) {
+        getTransactionManager().executeWithinTransaction(task);
+    }
+    
+    @Override
+    public <T> T executeWithinTransaction(Supplier<T> task) {
+        return getTransactionManager().executeWithinTransaction(task);
     }
 
     @Override
@@ -209,4 +214,7 @@ public class PersistenceSessionServiceInternalDefault 
implements PersistenceSess
     @javax.inject.Inject
     IsisSessionFactory isisSessionFactory;
 
+
+
+
 }
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 fc01c0f..ebe8947 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
@@ -23,7 +23,6 @@ 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.session.IsisSessionFactory;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 
 public abstract class AbstractIsisSessionTemplate {
 
@@ -57,11 +56,8 @@ public abstract class AbstractIsisSessionTemplate {
     protected void doExecute(final Object context) {
         final PersistenceSession persistenceSession = getPersistenceSession();
         final IsisTransactionManager transactionManager = 
getTransactionManager(persistenceSession);
-        transactionManager.executeWithinTransaction(new TransactionalClosure() 
{
-            @Override
-            public void execute() {
-                doExecuteWithTransaction(context);
-            }
+        transactionManager.executeWithinTransaction(()->{
+            doExecuteWithTransaction(context);
         });
     }
 
@@ -78,7 +74,7 @@ public abstract class AbstractIsisSessionTemplate {
 
     // //////////////////////////////////////
 
-//TODO[ISIS-1976] not used !?
+//FIXME[ISIS-1976] not used !?
 //    protected final ObjectAdapter adapterFor(final Object targetObject) {
 //        if(targetObject instanceof OidDto) {
 //            final OidDto oidDto = (OidDto) targetObject;
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index 2354136..b7a22f5 100644
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -46,43 +46,17 @@ extends
     TransactionalResource, 
     SessionScopedComponent {
 
-    // -- CONSTANTS
-
-    public static final String SERVICE_IDENTIFIER = "1";
-
-    /**
-     * @see #isFixturesInstalled()
-     */
-    public static final String INSTALL_FIXTURES_KEY = 
OptionHandlerFixtureAbstract.DATANUCLEUS_INSTALL_FIXTURES_KEY;
-    public static final boolean INSTALL_FIXTURES_DEFAULT = false;
-
-    //---
-
-    MementoRecreateObjectSupport mementoSupport();
-
-    ObjectAdapter adapterForAny(RootOid rootOid);
-    <T> List<ObjectAdapter> allMatchingQuery(final Query<T> query);
-
-    // --
-
+    // 
-------------------------------------------------------------------------------------------------
+    // -- STABLE API (DRAFT)
+    // 
-------------------------------------------------------------------------------------------------
+    
+    void open();
     void close();
-
-    ObjectAdapter createTransientInstance(ObjectSpecification spec);
-
-    ObjectAdapter createViewModelInstance(ObjectSpecification spec, String 
memento);
-
-    void destroyObjectInTransaction(ObjectAdapter adapter);
-
-    void execute(List<PersistenceCommand> persistenceCommandList);
-    <T> ObjectAdapter firstMatchingQuery(final Query<T> query);
-
     boolean flush();
-
-    ObjectAdapter getAggregateRoot(ParentedCollectionOid collectionOid);
-
+    
     IsisConfiguration getConfiguration();
-
-    PersistenceManager getPersistenceManager();
+    IsisTransactionManager getTransactionManager();
+    ServicesInjector getServicesInjector();
     
     /**
      * @param pojo a persistable object
@@ -101,7 +75,13 @@ extends
     Object fetchPersistentPojo(RootOid rootOid);
     /**@since 2.0.0-M2*/
     Map<RootOid, Object> fetchPersistentPojos(List<RootOid> rootOids);
-
+    
+    
+    // 
-------------------------------------------------------------------------------------------------
+    // -- JDO SPECIFIC
+    // 
-------------------------------------------------------------------------------------------------
+    
+    PersistenceManager getPersistenceManager();
     /**
      * Convenient equivalent to {@code getPersistenceManager()}.
      * @return
@@ -109,19 +89,7 @@ extends
     default PersistenceManager pm() {
         return getPersistenceManager();
     }
-
-    ServicesInjector getServicesInjector();
-
-    IsisTransactionManager getTransactionManager();
-
-    Object instantiateAndInjectServices(ObjectSpecification spec);
-
-    boolean isFixturesInstalled();
-
-    Object lookup(Bookmark bookmark, FieldResetPolicy fieldResetPolicy);
-
-    void makePersistentInTransaction(ObjectAdapter adapter);
-
+    
     /**
      * Not type safe. For type-safe queries use <br/><br/> {@code 
pm().newNamedQuery(cls, queryName)}
      * @param cls
@@ -150,13 +118,56 @@ extends
     default <T> javax.jdo.Query newJdoQuery(Class<T> cls, String filter){
         return pm().newQuery(cls, filter);
     }
+    
+    // 
-------------------------------------------------------------------------------------------------
+    // -- API NOT STABLE YET - SUBJECT TO REFACTORING
+    // 
-------------------------------------------------------------------------------------------------
+    
+    // -- SERVICE SUPPORT
 
-    void open();
+    static final String SERVICE_IDENTIFIER = "1";
 
-    void refreshRoot(ObjectAdapter adapter);
+    // -- FIXTURE SUPPORT
+    
+    /**
+     * @see #isFixturesInstalled()
+     */
+    static final String INSTALL_FIXTURES_KEY = 
OptionHandlerFixtureAbstract.DATANUCLEUS_INSTALL_FIXTURES_KEY;
+    static final boolean INSTALL_FIXTURES_DEFAULT = false;
+    
+    boolean isFixturesInstalled();
+    
+    // -- MEMENTO SUPPORT
+    
+    MementoRecreateObjectSupport mementoSupport();
+    
+    // -- TODO remove ObjectAdapter references from API
+    
+    ObjectAdapter adapterForAny(RootOid rootOid);
+    <T> List<ObjectAdapter> allMatchingQuery(final Query<T> query);
 
-    void resolve(Object parent);
+    ObjectAdapter createTransientInstance(ObjectSpecification spec);
 
+    ObjectAdapter createViewModelInstance(ObjectSpecification spec, String 
memento);
+
+    void destroyObjectInTransaction(ObjectAdapter adapter);
+
+    <T> ObjectAdapter firstMatchingQuery(final Query<T> query);
+    
+    ObjectAdapter getAggregateRoot(ParentedCollectionOid collectionOid);
+    
+    void makePersistentInTransaction(ObjectAdapter adapter);
+    
+    void refreshRoot(ObjectAdapter adapter);
     
+    // -- OTHERS
+    
+    void execute(List<PersistenceCommand> persistenceCommandList);
+
+    Object instantiateAndInjectServices(ObjectSpecification spec);
+
+    Object lookup(Bookmark bookmark, FieldResetPolicy fieldResetPolicy);
+
+    void resolve(Object parent);
 
 }
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
index 108d458..b2d16cd 100644
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
+++ 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
@@ -20,6 +20,10 @@
 package org.apache.isis.core.runtime.system.transaction;
 
 import java.util.UUID;
+import java.util.function.Supplier;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
@@ -31,8 +35,6 @@ import 
org.apache.isis.core.metamodel.services.ServicesInjector;
 import 
org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.session.IsisSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class IsisTransactionManager implements SessionScopedComponent {
 
@@ -126,18 +128,19 @@ public class IsisTransactionManager implements 
SessionScopedComponent {
      *  started here, or will ensure that an already-in-progress transaction 
cannot commit.
      * </p>
      */
-    public void executeWithinTransaction(final TransactionalClosure closure) {
-        executeWithinTransaction(null, closure);
+    public void executeWithinTransaction(final Runnable task) {
+        executeWithinTransaction(null, task);
     }
+    
     public void executeWithinTransaction(
             final Command existingCommandIfAny,
-            final TransactionalClosure closure) {
+            final Runnable task) {
         final boolean initiallyInTransaction = inTransaction();
         if (!initiallyInTransaction) {
             startTransaction(existingCommandIfAny);
         }
         try {
-            closure.execute();
+            task.run();
             if (!initiallyInTransaction) {
                 endTransaction();
             }
@@ -172,18 +175,19 @@ public class IsisTransactionManager implements 
SessionScopedComponent {
      *  started here, or will ensure that an already-in-progress transaction 
cannot commit.
      *  </p>
      */
-    public <Q> Q executeWithinTransaction(final 
TransactionalClosureWithReturn<Q> closure) {
-        return executeWithinTransaction(null, closure);
+    public <Q> Q executeWithinTransaction(final Supplier<Q> task) {
+        return executeWithinTransaction(null, task);
     }
+    
     public <Q> Q executeWithinTransaction(
             final Command existingCommandIfAny,
-            final TransactionalClosureWithReturn<Q> closure) {
+            final Supplier<Q> task) {
         final boolean initiallyInTransaction = inTransaction();
         if (!initiallyInTransaction) {
             startTransaction(existingCommandIfAny);
         }
         try {
-            final Q retVal = closure.execute();
+            final Q retVal = task.get();
             if (!initiallyInTransaction) {
                 endTransaction();
             }
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
deleted file mode 100644
index 20bbcdf..0000000
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureAbstract.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.system.transaction;
-
-/**
- * Not used by the framework, but provided for backward compatibility, eg by 
the (non-ASF) Isis addons.
- *
- * @deprecated - implement {@link TransactionalClosure} instead
- */
-@Deprecated
-public abstract class TransactionalClosureAbstract implements 
TransactionalClosure {
-
-}
\ No newline at end of file
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturn.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturn.java
deleted file mode 100644
index ee2d0e5..0000000
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturn.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.system.transaction;
-
-public interface TransactionalClosureWithReturn<T> {
-
-    public T execute();
-}
diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
deleted file mode 100644
index 74caac1..0000000
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.system.transaction;
-
-/**
- * Not used by the framework, but provided for backward compatibility, eg by 
the (non-ASF) Isis addons.
- *
- * @deprecated - implement {@link TransactionalClosureWithReturn} instead
- */
-@Deprecated
-public abstract class TransactionalClosureWithReturnAbstract<T> implements 
TransactionalClosureWithReturn<T> {
-
-}
diff --git 
a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
 
b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
index c41bd7b..2678c84 100644
--- 
a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
+++ 
b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
@@ -37,7 +37,6 @@ import org.apache.isis.applib.services.userreg.UserDetails;
 import org.apache.isis.applib.services.userreg.UserRegistrationService;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
 import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
 import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
 import 
org.apache.isis.viewer.wicket.ui.pages.accmngt.UsernameAvailableValidator;
@@ -131,12 +130,9 @@ public abstract class RegisterPanel extends 
GenericPanel<UserDetails> {
                             
.getServicesInjector().lookupService(UserRegistrationService.class);
 
                     
getIsisSessionFactory().getCurrentSession().getPersistenceSession().getTransactionManager()
-                    .executeWithinTransaction(new TransactionalClosure() {
-                        @Override
-                        public void execute() {
+                    .executeWithinTransaction(() -> {
                             userRegistrationService.registerUser(userDetails);
                             removeAccountConfirmation();
-                        }
                     });
                 }
             });

Reply via email to