You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/06/27 08:08:01 UTC

[isis] branch master updated (d7fefd3 -> ce0968e)

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

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from d7fefd3  ISIS-1963: workaround the issue by selective exception suppression
     new bbdad22  ISIS-1960: applib: remove BackgroundService2 and BackgroundCommandService2
     new 294ffec  ISIS-1960: add removed interfaces to module 'transition'
     new 9332cdd  ISIS-1960: Action background execution built-in default:
     new ce0968e  ISIS-1960: moving TransactionServiceDefault 'metamodel' -> 'runtime'

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../background/BackgroundCommandService.java       | 10 +++
 .../services/background/BackgroundService.java     |  6 ++
 .../services/background/BackgroundService2.java    | 33 ---------
 .../isis/applib/services/xactn/Transaction.java    | 14 ----
 .../applib/services/xactn/TransactionService.java  | 10 ++-
 .../background/BackgroundCommandService2.java      | 13 +---
 .../services/background/BackgroundService2.java}   | 12 +++-
 .../background/BackgroundCommandService2.java      | 13 +---
 .../services/background/BackgroundService2.java}   | 12 +++-
 .../PersistenceSessionServiceInternal.java         | 11 ++-
 .../PersistenceSessionServiceInternalNoop.java     |  8 +++
 .../background/BackgroundCommandExecution.java     | 26 ++-----
 .../background/BackgroundServiceDefault.java       | 67 +++++++++--------
 .../background/CommandInvocationHandler.java       |  6 +-
 .../background/ForkingInvocationHandler.java       | 12 ++++
 .../PersistenceSessionServiceInternalDefault.java  |  7 ++
 .../services/xactn/TransactionServiceDefault.java  | 17 ++++-
 .../system/persistence/PersistenceSessionBase.java |  2 +-
 .../system/transaction/IsisTransaction.java        | 83 +++++++++++-----------
 .../system/transaction/IsisTransactionManager.java | 14 ++--
 20 files changed, 191 insertions(+), 185 deletions(-)
 delete mode 100644 core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
 copy core/{applib => legacy/applib-legacy}/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java (77%)
 copy core/{metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/object/persistencecapable/package-info.java => legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java} (78%)
 rename core/{applib => legacy/transition-1-2}/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java (77%)
 copy core/{metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/object/persistencecapable/package-info.java => legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java} (78%)
 rename core/{metamodel/src/main/java/org/apache/isis/core/metamodel => runtime/src/main/java/org/apache/isis/core/runtime}/services/xactn/TransactionServiceDefault.java (85%)


[isis] 03/04: ISIS-1960: Action background execution built-in default:

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 9332cdd9a6a536cbe769770808d4e3ca16afbd74
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 27 09:31:33 2018 +0200

    ISIS-1960: Action background execution built-in default:
    
    wait for current thread's transaction to complete before executing
    background tasks
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1960
---
 .../applib/services/xactn/TransactionService.java  | 10 ++-
 .../PersistenceSessionServiceInternal.java         | 11 ++--
 .../PersistenceSessionServiceInternalNoop.java     |  8 +++
 .../services/xactn/TransactionServiceDefault.java  |  9 ++-
 .../background/BackgroundCommandExecution.java     | 26 ++------
 .../background/ForkingInvocationHandler.java       | 12 ++++
 .../PersistenceSessionServiceInternalDefault.java  |  7 +++
 .../system/persistence/PersistenceSessionBase.java |  2 +-
 .../system/transaction/IsisTransaction.java        | 73 ++++++++++------------
 .../system/transaction/IsisTransactionManager.java | 14 ++---
 10 files changed, 94 insertions(+), 78 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/xactn/TransactionService.java b/core/applib/src/main/java/org/apache/isis/applib/services/xactn/TransactionService.java
index 124dba5..d6de35b 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/xactn/TransactionService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/xactn/TransactionService.java
@@ -19,6 +19,8 @@
 
 package org.apache.isis.applib.services.xactn;
 
+import java.util.concurrent.CountDownLatch;
+
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
@@ -59,7 +61,13 @@ public interface TransactionService {
     @Programmatic
     TransactionState getTransactionState();
 
-
+    /**
+     * Return a latch, that allows threads to wait on the current transaction to complete.
+     */
+    @Programmatic
+    CountDownLatch currentTransactionLatch(); 
+    
+    
     /**
      * Intended only for use by fixture scripts and integration tests.
      *
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 daa1b69..572af70 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
@@ -17,13 +17,14 @@
 package org.apache.isis.core.metamodel.services.persistsession;
 
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.query.Query;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.xactn.Transaction;
 import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.xactn.Transaction;
 import org.apache.isis.applib.services.xactn.TransactionState;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
@@ -120,13 +121,13 @@ public interface PersistenceSessionServiceInternal extends AdapterManager {
 
     @Programmatic
     Transaction currentTransaction();
-
+    
+    @Programmatic
+	CountDownLatch currentTransactionLatch();
 
     @Programmatic
     TransactionState getTransactionState();
 
-    
-
     // -- makePersistent, remove
 
     /**
@@ -174,6 +175,4 @@ public interface PersistenceSessionServiceInternal extends AdapterManager {
     void executeWithinTransaction(TransactionalClosure transactionalClosure);
 
 
-    
-
 }
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 086400b..1016a20 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
@@ -19,6 +19,7 @@
 package org.apache.isis.core.metamodel.services.persistsession;
 
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
@@ -145,6 +146,11 @@ public class PersistenceSessionServiceInternalNoop implements PersistenceSession
     public Transaction currentTransaction() {
         throw new UnsupportedOperationException("Not supported by this implementation of PersistenceSessionServiceInternal");
     }
+    
+	@Override
+	public CountDownLatch currentTransactionLatch() {
+		throw new UnsupportedOperationException("Not supported by this implementation of PersistenceSessionServiceInternal");
+	}
 
     @Override
     public void remove(final ObjectAdapter adapter) {
@@ -170,4 +176,6 @@ public class PersistenceSessionServiceInternalNoop implements PersistenceSession
     public TransactionState getTransactionState() {
         throw new UnsupportedOperationException("Not supported by this implementation of PersistenceSessionServiceInternal");
     }
+
+
 }
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java
index 0848d8b..d3ddf28 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java
@@ -19,11 +19,13 @@
 
 package org.apache.isis.core.metamodel.services.xactn;
 
+import java.util.concurrent.CountDownLatch;
+
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.xactn.Transaction;
 import org.apache.isis.applib.services.xactn.TransactionService;
-import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.xactn.TransactionState;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.services.persistsession.PersistenceSessionServiceInternal;
@@ -87,6 +89,11 @@ public class TransactionServiceDefault implements TransactionService {
     public Transaction currentTransaction() {
         return persistenceSessionServiceInternal.currentTransaction();
     }
+    
+	@Override
+	public CountDownLatch currentTransactionLatch() {
+    	return persistenceSessionServiceInternal.currentTransactionLatch(); 
+	}
 
     @Override
     public TransactionState getTransactionState() {
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index 0d5ec9d..6ac2ed2 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -18,33 +18,15 @@ package org.apache.isis.core.runtime.services.background;
 
 import java.util.List;
 
-import com.google.common.collect.Lists;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.clock.ClockService;
 import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command.Executor;
-import org.apache.isis.applib.services.iactn.Interaction;
-import org.apache.isis.applib.services.iactn.InteractionContext;
-import org.apache.isis.applib.services.jaxb.JaxbService;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
-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.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.sessiontemplate.AbstractIsisSessionTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.apache.isis.applib.services.command.CommandExecutorService;
 import org.apache.isis.applib.services.command.CommandWithDto;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
 
 /**
  * Intended to be used as a base class for executing queued up {@link Command background action}s.
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/ForkingInvocationHandler.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/ForkingInvocationHandler.java
index aa4bbc3..8fa7a34 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/ForkingInvocationHandler.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/ForkingInvocationHandler.java
@@ -20,9 +20,14 @@ import static org.apache.isis.commons.internal.base._With.requires;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.isis.core.runtime.system.context.IsisContext;
+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;
 
 /**
  * Package private invocation handler that executes actions in the background using a ExecutorService
@@ -61,9 +66,16 @@ class ForkingInvocationHandler<T> implements InvocationHandler {
             domainObject = mixedInIfAny;
         }
         
+        final CountDownLatch countDownLatch = Optional.ofNullable(IsisContext.getSessionFactory())
+        		.map(IsisSessionFactory::getCurrentSession)
+        		.map(IsisSession::getCurrentTransaction)
+        		.map(IsisTransaction::countDownLatch)
+        		.orElse(new CountDownLatch(0));
+        
         backgroundExecutorService.submit(()->{
         	
         	try {
+        		countDownLatch.await(); // wait for current transaction of the calling thread to complete
         		
         		IsisContext.getSessionFactory().doInSession(
         			()->proxyMethod.invoke(domainObject, args));
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 480f440..c26445c 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
@@ -22,6 +22,7 @@ import static java.util.Objects.requireNonNull;
 import static java.util.Optional.ofNullable;
 
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.isis.applib.NonRecoverableException;
 import org.apache.isis.applib.annotation.DomainService;
@@ -181,6 +182,12 @@ public class PersistenceSessionServiceInternalDefault implements PersistenceSess
     public Transaction currentTransaction() {
         return getTransactionManager().getCurrentTransaction();
     }
+    
+	@Override
+	public CountDownLatch currentTransactionLatch() {
+    	IsisTransaction transaction = getTransactionManager().getCurrentTransaction();
+    	return transaction==null ? new CountDownLatch(0) : transaction.countDownLatch(); 
+	}
 
     @Override
     public <T> List<ObjectAdapter> allMatchingQuery(final Query<T> query) {
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionBase.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionBase.java
index d10abe5..b75e1b7 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionBase.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionBase.java
@@ -119,7 +119,7 @@ abstract class PersistenceSessionBase implements PersistenceSession {
         // sub-components
         final AdapterManager adapterManager = this;
         this.persistenceQueryFactory = new PersistenceQueryFactory(adapterManager, this.specificationLoader);
-        this.transactionManager = new IsisTransactionManager(this, authenticationSession, servicesInjector);
+        this.transactionManager = new IsisTransactionManager(this, /*authenticationSession,*/ servicesInjector);
 
         this.state = State.NOT_INITIALIZED;
 
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index 96c9fa2..6ebe65d 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -21,19 +21,14 @@ package org.apache.isis.core.runtime.system.transaction;
 
 import java.util.List;
 import java.util.UUID;
-
-import com.google.common.collect.Lists;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.HasTransactionId;
 import org.apache.isis.applib.services.WithTransactionScope;
 import org.apache.isis.applib.services.xactn.Transaction;
 import org.apache.isis.applib.services.xactn.TransactionState;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.authentication.MessageBroker;
+import org.apache.isis.commons.internal.collections._Lists;
 import org.apache.isis.core.commons.components.TransactionScopedComponent;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.util.ToString;
@@ -45,6 +40,10 @@ import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyO
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.core.runtime.services.auditing.AuditingServiceInternal;
 import org.apache.isis.core.runtime.services.persistsession.PersistenceSessionServiceInternalDefault;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
 
 /**
  * Used by the {@link IsisTransactionManager} to captures a set of changes to be
@@ -163,11 +162,11 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
 
     private final UUID interactionId;
     private final int sequence;
-    private final AuthenticationSession authenticationSession;
+//    private final AuthenticationSession authenticationSession;
 
-    private final List<PersistenceCommand> persistenceCommands = Lists.newArrayList();
+    private final List<PersistenceCommand> persistenceCommands = _Lists.newArrayList();
     private final IsisTransactionManager transactionManager;
-    private final MessageBroker messageBroker;
+//    private final MessageBroker messageBroker;
     private final PublishingServiceInternal publishingServiceInternal;
     private final AuditingServiceInternal auditingServiceInternal;
 
@@ -178,18 +177,18 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
     public IsisTransaction(
             final UUID interactionId,
             final int sequence,
-            final AuthenticationSession authenticationSession,
+            /*final AuthenticationSession authenticationSession,*/
             final ServicesInjector servicesInjector) {
 
         this.interactionId = interactionId;
         this.sequence = sequence;
-        this.authenticationSession = authenticationSession;
+//        this.authenticationSession = authenticationSession;
 
         final PersistenceSessionServiceInternalDefault persistenceSessionService = servicesInjector
                 .lookupServiceElseFail(PersistenceSessionServiceInternalDefault.class);
         this.transactionManager = persistenceSessionService.getTransactionManager();
 
-        this.messageBroker = authenticationSession.getMessageBroker();
+//        this.messageBroker = authenticationSession.getMessageBroker();
         this.publishingServiceInternal = servicesInjector.lookupServiceElseFail(PublishingServiceInternal.class);
         this.auditingServiceInternal = servicesInjector.lookupServiceElseFail(AuditingServiceInternal.class);
 
@@ -200,8 +199,6 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         LOG.debug("new transaction {}", this);
     }
 
-    
-
     // -- transactionId
 
     @Programmatic
@@ -223,6 +220,7 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
     }
 
     
+    private final CountDownLatch countDownLatch = new CountDownLatch(1);
 
     // -- state
 
@@ -234,6 +232,9 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
 
     private void setState(final State state) {
         this.state = state;
+        if(state.isComplete()) {
+        	countDownLatch.countDown();
+        }
     }
 
     @Override
@@ -251,12 +252,8 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         return transactionState;
     }
 
-
-    
-
     // -- commands
 
-
     /**
      * Add the non-null command to the list of commands to execute at the end of
      * the transaction.
@@ -320,8 +317,6 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         removeCommand(CreateObjectCommand.class, onObject);
     }
 
-    
-
     // -- flush
 
     public final void flush() {
@@ -446,9 +441,6 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         setState(State.COMMITTED);
     }
 
-
-    
-
     // -- abortCause, markAsAborted
 
     /**
@@ -494,11 +486,6 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         clearAbortCause();
     }
 
-
-
-
-    
-
     // -- toString
 
     @Override
@@ -512,21 +499,29 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         return str;
     }
 
-    
-
     // -- getMessageBroker
 
+//    /**
+//     * The {@link org.apache.isis.core.commons.authentication.MessageBroker} for this transaction.
+//     * 
+//     * <p>
+//     * Injected in constructor
+//     *
+//     * @deprecated - obtain the {@link org.apache.isis.core.commons.authentication.MessageBroker} instead from the {@link AuthenticationSession}.
+//     */
+//    public MessageBroker getMessageBroker() {
+//        return messageBroker;
+//    }
+    
+    // -- countDownLatch
+
     /**
-     * The {@link org.apache.isis.core.commons.authentication.MessageBroker} for this transaction.
+     * Returns a latch that allows threads to wait on. The latch count drops to zero once this transaction completes.
      * 
-     * <p>
-     * Injected in constructor
-     *
-     * @deprecated - obtain the {@link org.apache.isis.core.commons.authentication.MessageBroker} instead from the {@link AuthenticationSession}.
      */
-    public MessageBroker getMessageBroker() {
-        return messageBroker;
-    }
+	public CountDownLatch countDownLatch() {
+		return countDownLatch;
+	}
 
     
 
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 166a4e4..a8b9a87 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
@@ -21,20 +21,18 @@ package org.apache.isis.core.runtime.system.transaction;
 
 import java.util.UUID;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
 import org.apache.isis.applib.services.iactn.Interaction;
 import org.apache.isis.applib.services.iactn.InteractionContext;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.components.SessionScopedComponent;
 import org.apache.isis.core.commons.exceptions.IsisException;
 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 {
 
@@ -52,7 +50,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
     // -- constructor, fields
 
     private final PersistenceSession persistenceSession;
-    private final AuthenticationSession authenticationSession;
+    //private final AuthenticationSession authenticationSession;
     private final ServicesInjector servicesInjector;
 
     private final CommandContext commandContext;
@@ -60,11 +58,11 @@ public class IsisTransactionManager implements SessionScopedComponent {
 
     public IsisTransactionManager(
             final PersistenceSession persistenceSession,
-            final AuthenticationSession authenticationSession,
+            /*final AuthenticationSession authenticationSession,*/
             final ServicesInjector servicesInjector) {
 
         this.persistenceSession = persistenceSession;
-        this.authenticationSession = authenticationSession;
+        //this.authenticationSession = authenticationSession;
         this.servicesInjector = servicesInjector;
 
         this.commandContext = this.servicesInjector.lookupServiceElseFail(CommandContext.class);
@@ -239,7 +237,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
             final UUID transactionId = command.getTransactionId();
 
             this.currentTransaction = new IsisTransaction(transactionId,
-                    interaction.next(Interaction.Sequence.TRANSACTION.id()), authenticationSession, servicesInjector);
+                    interaction.next(Interaction.Sequence.TRANSACTION.id()), /*authenticationSession,*/ servicesInjector);
             transactionLevel = 0;
 
             persistenceSession.startTransaction();


[isis] 02/04: ISIS-1960: add removed interfaces to module 'transition'

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 294ffec8c82d1ff3038cdd3f7d4d6d3e96485eeb
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 27 08:00:10 2018 +0200

    ISIS-1960: add removed interfaces to module 'transition'
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1960
---
 .../background/BackgroundCommandService2.java      | 28 ++++++++++++++++++++++
 .../services/background/BackgroundService2.java    | 28 ++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java b/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
new file mode 100644
index 0000000..7c3ed13
--- /dev/null
+++ b/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
@@ -0,0 +1,28 @@
+/**
+ *  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.applib.services.background;
+
+/**
+ * Persists a {@link org.apache.isis.schema.cmd.v1.CommandDto memento-ized} command such that it can be
+ * executed asynchronously, for example through a Quartz scheduler.
+ * @deprecated use BackgroundCommandService instead
+ */
+@Deprecated
+public interface BackgroundCommandService2 extends BackgroundCommandService {
+
+    
+}
diff --git a/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java b/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
new file mode 100644
index 0000000..7f68327
--- /dev/null
+++ b/core/legacy/transition-1-2/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
@@ -0,0 +1,28 @@
+/**
+ *  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.applib.services.background;
+
+/**
+ * Submit actions to be invoked in the background.
+ * @deprecated use BackgroundService instead
+ * 
+ */
+@Deprecated
+public interface BackgroundService2 extends BackgroundService {
+   
+
+}


[isis] 04/04: ISIS-1960: moving TransactionServiceDefault 'metamodel' -> 'runtime'

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit ce0968e53742140577ecdd92a4d8cc3337164d15
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 27 09:41:51 2018 +0200

    ISIS-1960: moving TransactionServiceDefault 'metamodel' -> 'runtime'
    
    also cleaning up 'Transaction' interface
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1960
---
 .../org/apache/isis/applib/services/xactn/Transaction.java | 14 --------------
 .../runtime}/services/xactn/TransactionServiceDefault.java |  8 ++++++--
 .../core/runtime/system/transaction/IsisTransaction.java   | 10 +++++++++-
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/xactn/Transaction.java b/core/applib/src/main/java/org/apache/isis/applib/services/xactn/Transaction.java
index a9857ab..cfc7c70 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/xactn/Transaction.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/xactn/Transaction.java
@@ -51,20 +51,6 @@ public interface Transaction extends HasTransactionId {
     @Programmatic
     void flush();
 
-    /**
-     * If the cause has been rendered higher up in the stack, then clear the cause so that
-     * it won't be picked up and rendered elsewhere.
-     *
-     * <p>
-     *     DO NOT CALL - for framework use only.
-     * </p>
-     *
-     * @deprecated - for framework use only
-     */
-    @Deprecated
-    @Programmatic
-    void clearAbortCause();
-
     @Programmatic
     TransactionState getTransactionState();
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/xactn/TransactionServiceDefault.java
similarity index 90%
rename from core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java
rename to core/runtime/src/main/java/org/apache/isis/core/runtime/services/xactn/TransactionServiceDefault.java
index d3ddf28..de21748 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/xactn/TransactionServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/xactn/TransactionServiceDefault.java
@@ -17,7 +17,7 @@
  *  under the License.
  */
 
-package org.apache.isis.core.metamodel.services.xactn;
+package org.apache.isis.core.runtime.services.xactn;
 
 import java.util.concurrent.CountDownLatch;
 
@@ -29,6 +29,7 @@ import org.apache.isis.applib.services.xactn.TransactionService;
 import org.apache.isis.applib.services.xactn.TransactionState;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.services.persistsession.PersistenceSessionServiceInternal;
+import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 
 @DomainService(
         nature = NatureOfService.DOMAIN,
@@ -72,7 +73,10 @@ public class TransactionServiceDefault implements TransactionService {
                 throw new IsisException("Transaction is marked to abort");
             case ALWAYS:
                 persistenceSessionServiceInternal.abortTransaction();
-                currentTransaction().clearAbortCause();
+                final Transaction currentTransaction = currentTransaction();
+                if(currentTransaction instanceof IsisTransaction) {
+                	((IsisTransaction)currentTransaction).clearAbortCause();
+                }
                 break;
             }
             break;
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index 6ebe65d..fef3fc9 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -476,7 +476,15 @@ public class IsisTransaction implements TransactionScopedComponent, Transaction
         return abortCause;
     }
 
-    @Override
+    /**
+     * If the cause has been rendered higher up in the stack, then clear the cause so that
+     * it won't be picked up and rendered elsewhere.
+     *
+     * <p>
+     *     for framework internal use only.
+     * </p>
+     *
+     */
     public void clearAbortCause() {
         abortCause = null;
     }


[isis] 01/04: ISIS-1960: applib: remove BackgroundService2 and BackgroundCommandService2

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit bbdad22b392cf910ae196ca7304edc86b117b7f6
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 27 07:41:53 2018 +0200

    ISIS-1960: applib: remove BackgroundService2 and
    BackgroundCommandService2
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1960
---
 .../background/BackgroundCommandService.java       | 10 ++++
 .../services/background/BackgroundService.java     |  6 ++
 .../background/BackgroundCommandService2.java      | 13 +----
 .../services/background/BackgroundService2.java    | 13 ++---
 .../background/BackgroundServiceDefault.java       | 67 +++++++++++++---------
 .../background/CommandInvocationHandler.java       |  6 +-
 6 files changed, 65 insertions(+), 50 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService.java
index 11621d8..c086d2b 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService.java
@@ -16,6 +16,9 @@
  */
 package org.apache.isis.applib.services.background;
 
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.schema.cmd.v1.CommandDto;
+
 /**
  * Persists a {@link org.apache.isis.schema.cmd.v1.CommandDto command-reified} action such that it can be executed asynchronously,
  * for example through a Quartz scheduler.
@@ -34,5 +37,12 @@ package org.apache.isis.applib.services.background;
  *
  */
 public interface BackgroundCommandService {
+	
+	public void schedule(
+            final CommandDto dto,
+            final Command parentCommand,
+            final String targetClassName,
+            final String targetActionName,
+            final String targetArgs);
 
 }
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
index 158a86a..f22af39 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
@@ -47,5 +47,11 @@ public interface BackgroundService {
     @Programmatic
     <T> T execute(final T object);
 
+    /**
+     * Returns a proxy around the mixin object which is then used to obtain the
+     * signature of the action to be invoked in the background.
+     */
+    @Programmatic
+    <T> T executeMixin(Class<T> mixinClass, Object mixedIn);
 
 }
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java b/core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
similarity index 77%
rename from core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
rename to core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
index e693592..7c3ed13 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
+++ b/core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundCommandService2.java
@@ -16,20 +16,13 @@
  */
 package org.apache.isis.applib.services.background;
 
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.schema.cmd.v1.CommandDto;
-
 /**
  * Persists a {@link org.apache.isis.schema.cmd.v1.CommandDto memento-ized} command such that it can be
  * executed asynchronously, for example through a Quartz scheduler.
- *
+ * @deprecated use BackgroundCommandService instead
  */
+@Deprecated
 public interface BackgroundCommandService2 extends BackgroundCommandService {
 
-    void schedule(
-            final CommandDto dto,
-            final Command parentCommand,
-            final String targetClassName,
-            final String targetActionName,
-            final String targetArgs);
+    
 }
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java b/core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
similarity index 77%
rename from core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
rename to core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
index 529aa85..7f68327 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
+++ b/core/legacy/applib-legacy/src/main/java/org/apache/isis/applib/services/background/BackgroundService2.java
@@ -16,18 +16,13 @@
  */
 package org.apache.isis.applib.services.background;
 
-import org.apache.isis.applib.annotation.Programmatic;
-
 /**
  * Submit actions to be invoked in the background.
+ * @deprecated use BackgroundService instead
+ * 
  */
+@Deprecated
 public interface BackgroundService2 extends BackgroundService {
-
-    /**
-     * Returns a proxy around the mixin object which is then used to obtain the
-     * signature of the action to be invoked in the background.
-     */
-    @Programmatic
-    <T> T executeMixin(Class<T> mixinClass, Object mixedIn);
+   
 
 }
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index 75d20b3..b19d921 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -30,8 +30,7 @@ import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.background.BackgroundCommandService;
-import org.apache.isis.applib.services.background.BackgroundCommandService2;
-import org.apache.isis.applib.services.background.BackgroundService2;
+import org.apache.isis.applib.services.background.BackgroundService;
 import org.apache.isis.applib.services.command.CommandContext;
 import org.apache.isis.applib.services.factory.FactoryService;
 import org.apache.isis.commons.internal._Constants;
@@ -55,43 +54,55 @@ import org.slf4j.LoggerFactory;
 		nature = NatureOfService.DOMAIN,
 		menuOrder = "" + Integer.MAX_VALUE
 		)
-public class BackgroundServiceDefault implements BackgroundService2 {
+public class BackgroundServiceDefault implements BackgroundService {
 	
 	static final Logger LOG = LoggerFactory.getLogger(BackgroundServiceDefault.class);
 
-	/*
-	 * For the fixed thread-pool let there be 1-4 concurrent threads,
-	 * limited by the number of available (logical) processor cores.
-	 * 
-	 * Note: Future improvements might make these values configurable, 
-	 * but for now lets try to be reasonably nice here.
-	 * 
-	 */
-	private final int minThreadCount = 1; // only used if there is no BackgroundCommandService
-	private final int maxThreadCount = 4; // only used if there is no BackgroundCommandService
-
-	private final int threadCount = // only used if there is no BackgroundCommandService
-			Math.max(minThreadCount, 
-					Math.min(maxThreadCount,
-							Runtime.getRuntime().availableProcessors()));
-
 	// only used if there is no BackgroundCommandService
-	private ExecutorService backgroundExecutorService; 
+	private static class BuiltinExecutor {
+		/*
+		 * For the fixed thread-pool let there be 1-4 concurrent threads,
+		 * limited by the number of available (logical) processor cores.
+		 * 
+		 * Note: Future improvements might make these values configurable, 
+		 * but for now lets try to be reasonably nice here.
+		 * 
+		 */
+		private final int minThreadCount = 1; 
+		private final int maxThreadCount = 4;
+
+		private final int threadCount =
+				Math.max(minThreadCount, 
+						Math.min(maxThreadCount,
+								Runtime.getRuntime().availableProcessors()));
+
+		public final ExecutorService backgroundExecutorService = 
+				Executors.newFixedThreadPool(threadCount);
+
+		public void shutdown() {
+			backgroundExecutorService.shutdownNow();
+		}	
+	}
+	
+	private BuiltinExecutor builtinExecutor; // only used if there is no BackgroundCommandService
+	
+	private boolean usesBuiltinExecutor() {
+		return backgroundCommandService==null;
+	}
 
 	@Programmatic
 	@PostConstruct
 	public void init(Map<String,String> props) {
-		if(backgroundCommandService==null) {
-			backgroundExecutorService = Executors.newFixedThreadPool(threadCount);	
+		if(usesBuiltinExecutor()) {
+			builtinExecutor = new BuiltinExecutor();
 		}
 	}
 
 	@Programmatic
 	@PreDestroy
 	public void shutdown() {
-		if(backgroundExecutorService!=null) {
-			backgroundExecutorService.shutdownNow();
-			backgroundExecutorService = null;
+		if(builtinExecutor!=null) {
+			builtinExecutor.shutdown();
 		}
 	}
 
@@ -149,12 +160,12 @@ public class BackgroundServiceDefault implements BackgroundService2 {
 	 */
 	private <T> InvocationHandler newMethodHandler(final T target, final Object mixedInIfAny) {
 
-		if(backgroundCommandService==null) {
-			return new ForkingInvocationHandler<T>(target, mixedInIfAny, backgroundExecutorService);
+		if(usesBuiltinExecutor()) {
+			return new ForkingInvocationHandler<T>(target, mixedInIfAny, builtinExecutor.backgroundExecutorService);
 		}
 
 		return new CommandInvocationHandler<T>(
-				(BackgroundCommandService2) backgroundCommandService, 
+				backgroundCommandService, 
 				target, 
 				mixedInIfAny, 
 				specificationLoader,
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/CommandInvocationHandler.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/CommandInvocationHandler.java
index 0c1b090..437d591 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/CommandInvocationHandler.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/CommandInvocationHandler.java
@@ -24,7 +24,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.function.Supplier;
 
-import org.apache.isis.applib.services.background.BackgroundCommandService2;
+import org.apache.isis.applib.services.background.BackgroundCommandService;
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -42,7 +42,7 @@ import org.apache.isis.schema.cmd.v1.CommandDto;
 
 class CommandInvocationHandler<T> implements InvocationHandler {
 	
-	private final BackgroundCommandService2 backgroundCommandService;
+	private final BackgroundCommandService backgroundCommandService;
 	private final T target;
 	private final Object mixedInIfAny;
 	private final SpecificationLoader specificationLoader;
@@ -51,7 +51,7 @@ class CommandInvocationHandler<T> implements InvocationHandler {
 	private final Supplier<AdapterManager> adapterManagerSupplier;
 
 	CommandInvocationHandler(
-			BackgroundCommandService2 backgroundCommandService, 
+			BackgroundCommandService backgroundCommandService, 
 			T target,
 			Object mixedInIfAny,
 			SpecificationLoader specificationLoader,