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 11:14:16 UTC
[isis] branch master updated: ISIS-1960: Action background
execution: propagate the current auth-session instead of creating a new
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
The following commit(s) were added to refs/heads/master by this push:
new f0330f6 ISIS-1960: Action background execution: propagate the current auth-session instead of creating a new
f0330f6 is described below
commit f0330f6796844f56957c1d628f89425ad01b46d6
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 27 11:29:47 2018 +0200
ISIS-1960: Action background execution: propagate the current
auth-session instead of creating a new
Task-Url: https://issues.apache.org/jira/browse/ISIS-1960
---
.../background/ForkingInvocationHandler.java | 21 +++++++++++++++------
.../runtime/system/session/IsisSessionFactory.java | 2 --
2 files changed, 15 insertions(+), 8 deletions(-)
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 8fa7a34..9fab6e4 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
@@ -24,7 +24,9 @@ import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.internal.InitialisationSession;
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;
@@ -66,11 +68,17 @@ 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));
+ final Optional<IsisSession> currentSession = Optional.ofNullable(IsisContext.getSessionFactory())
+ .map(IsisSessionFactory::getCurrentSession);
+
+ final AuthenticationSession authSession = currentSession
+ .map(IsisSession::getAuthenticationSession)
+ .orElse(new InitialisationSession());
+
+ final CountDownLatch countDownLatch = currentSession
+ .map(IsisSession::getCurrentTransaction)
+ .map(IsisTransaction::countDownLatch)
+ .orElse(new CountDownLatch(0));
backgroundExecutorService.submit(()->{
@@ -78,7 +86,8 @@ class ForkingInvocationHandler<T> implements InvocationHandler {
countDownLatch.await(); // wait for current transaction of the calling thread to complete
IsisContext.getSessionFactory().doInSession(
- ()->proxyMethod.invoke(domainObject, args));
+ ()->proxyMethod.invoke(domainObject, args),
+ authSession );
} catch (Exception e) {
// log in caller's context
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactory.java
index c9fece3..c013869 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactory.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactory.java
@@ -252,8 +252,6 @@ public class IsisSessionFactory
return logonFixture;
}
-
-
// -- openSession, closeSession, currentSession, inSession
private final ThreadLocal<IsisSession> currentSession = new ThreadLocal<>();