You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/05/01 10:17:11 UTC
[34/35] isis git commit: ISIS-1370: removed the
ActionInvocationFacet#currentInvocation thread-local.
ISIS-1370: removed the ActionInvocationFacet#currentInvocation thread-local.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/eee234c0
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/eee234c0
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/eee234c0
Branch: refs/heads/ISIS-1291
Commit: eee234c03f44f8720f9c1378dbb466d90f83da0d
Parents: a204d74
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun May 1 09:13:12 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sun May 1 09:13:12 2016 +0100
----------------------------------------------------------------------
.../invocation/ActionInvocationFacet.java | 92 --------------------
...onInvocationFacetForDomainEventAbstract.java | 40 ++-------
.../publishing/PublishingServiceInternal.java | 5 +-
.../PublishingServiceInternalDefault.java | 33 +------
4 files changed, 10 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/eee234c0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java
index 42784e5..ce03012 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java
@@ -19,14 +19,9 @@
package org.apache.isis.core.metamodel.facets.actions.action.invocation;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.applib.services.command.Command;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
@@ -51,91 +46,4 @@ public interface ActionInvocationFacet extends Facet {
ObjectSpecification getOnType();
- class CurrentInvocation {
-
- private final Command command;
-
- private final ObjectAdapter target;
- private final ObjectAction action;
- private final IdentifiedHolder identifiedHolder;
- private final List<ObjectAdapter> parameters;
- private final ObjectAdapter result;
-
- public CurrentInvocation(
- final ObjectAdapter target,
- final ObjectAction objectAction,
- final IdentifiedHolder identifiedHolder,
- final ObjectAdapter[] parameters,
- final ObjectAdapter result,
- final Command command) {
- this(target, objectAction, identifiedHolder, Arrays.asList(parameters), result, command);
- }
-
- public CurrentInvocation(
- final ObjectAdapter target,
- final ObjectAction objectAction,
- final IdentifiedHolder identifiedHolder,
- final List<ObjectAdapter> parameters,
- final ObjectAdapter result,
- final Command command) {
- this.target = target;
- this.action = objectAction;
- this.identifiedHolder = identifiedHolder;
- this.parameters = parameters;
- this.result = result;
- this.command = command;
- }
-
- /**
- * Undeprecated ... isn't necessarily the same as the info held in Command because
- * Command only ever wraps the outer-most action, whereas this could be for an action invoked
- * via the WrapperFactory.
- */
- public ObjectAdapter getTarget() {
- return target;
- }
-
- public ObjectAction getAction() {
- return action;
- }
-
- /**
- * Undeprecated ... isn't necessarily the same as the info held in Command because
- * Command only ever wraps the outer-most action, whereas this could be for an action invoked
- * via the WrapperFactory.
- *
- * This is the FacetedMethod for the {@link #getAction()}.
- */
- public IdentifiedHolder getIdentifiedHolder() {
- return identifiedHolder;
- }
-
- public List<ObjectAdapter> getParameters() {
- return parameters;
- }
-
- /**
- * Undeprecated ... isn't necessarily the same as the info held in Command because
- * Command only ever wraps the outer-most action, whereas this could be for an action invoked
- * via the WrapperFactory.
- */
- public ObjectAdapter getResult() {
- return result;
- }
-
- public Command getCommand() {
- return command;
- }
- }
-
- /**
- * This thread-local is populated by ActionInvocationFacet, but is set to null when the action is
- * published. Note that if the WrapperFactory is in use then this can possibly many time
- * within a calling action. Therefore the contents of this thread-local are not necessarily
- * the same as the info held on the CommandContext (which always holds the outer-most action
- * details).
- */
- @Deprecated ThreadLocal<CurrentInvocation> currentInvocation = new ThreadLocal<>();
-
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/eee234c0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
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 716b9f5..c2953e5 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
@@ -367,46 +367,18 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
resultAdapter = getAdapterManager().adapterFor(priorExecution.getResult());
setCommandResultIfEntity(command, resultAdapter);
- // TODO: use InteractionContext instead
-
final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
- if (publishedActionFacet != null && currentInvocation.get() == null) {
- final CurrentInvocation currentInvocation1 = new CurrentInvocation(
- targetAdapter, owningAction, getIdentified(),
- argumentAdapters, resultAdapter, command);
- currentInvocation.set(currentInvocation1);
- }
-
- publishAction();
+ if (publishedActionFacet != null) {
- }
- return resultAdapter;
- }
+ final IdentifiedHolder identifiedHolder = getIdentified();
+ final List<ObjectAdapter> parameterAdapters = Arrays.asList(argumentAdapters);
- private void publishAction() {
-
- final CurrentInvocation currentInvocation = ActionInvocationFacet.currentInvocation.get();
- if(currentInvocation == null) {
- return;
- } else {
- final ObjectAction currentAction = currentInvocation.getAction();
- final IdentifiedHolder identifiedHolder = currentInvocation.getIdentifiedHolder();
- final ObjectAdapter targetAdapter = currentInvocation.getTarget();
- final List<ObjectAdapter> parameterAdapters = currentInvocation.getParameters();
- final ObjectAdapter resultAdapter = currentInvocation.getResult();
-
- try {
-
- if (getPublishingServiceInternal().publishAction(currentAction, identifiedHolder, targetAdapter, parameterAdapters, resultAdapter))
- return;
- } finally {
- // ensures that cannot publish this action more than once
- ActionInvocationFacet.currentInvocation.set(null);
+ getPublishingServiceInternal().publishAction(
+ owningAction, identifiedHolder, targetAdapter, parameterAdapters, resultAdapter);
}
- getPublishingServiceInternal().publishAction();
}
-
+ return resultAdapter;
}
protected Object invokeMethodElseFromCache(
http://git-wip-us.apache.org/repos/asf/isis/blob/eee234c0/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
index dfada2e..036731f 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
@@ -36,10 +36,7 @@ public interface PublishingServiceInternal {
final Map<ObjectAdapter, PublishedObject.ChangeKind> changeKindByEnlistedAdapter);
@Programmatic
- void publishAction();
-
- @Programmatic
- boolean publishAction(
+ void publishAction(
final ObjectAction objectAction,
final IdentifiedHolder identifiedHolder,
final ObjectAdapter targetAdapter,
http://git-wip-us.apache.org/repos/asf/isis/blob/eee234c0/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceInternalDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceInternalDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceInternalDefault.java
index 8fffd78..756d228 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceInternalDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceInternalDefault.java
@@ -56,8 +56,6 @@ import org.apache.isis.core.metamodel.adapter.oid.RootOid;
import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
import org.apache.isis.core.metamodel.facets.FacetedMethod;
import org.apache.isis.core.metamodel.facets.FacetedMethodParameter;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet.CurrentInvocation;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
@@ -165,38 +163,14 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
publishingServiceIfAny.publish(metadata, payload);
}
- @Override @Programmatic
- public void publishAction() {
-
- final CurrentInvocation currentInvocation = ActionInvocationFacet.currentInvocation.get();
- if(currentInvocation == null) {
- return;
- }
-
- final ObjectAction currentAction = currentInvocation.getAction();
- final IdentifiedHolder identifiedHolder = currentInvocation.getIdentifiedHolder();
- final ObjectAdapter targetAdapter = currentInvocation.getTarget();
- final List<ObjectAdapter> parameterAdapters = currentInvocation.getParameters();
- final ObjectAdapter resultAdapter = currentInvocation.getResult();
-
- try {
-
- if (publishAction(currentAction, identifiedHolder, targetAdapter, parameterAdapters, resultAdapter))
- return;
- } finally {
- // ensures that cannot publish this action more than once
- ActionInvocationFacet.currentInvocation.set(null);
- }
- }
-
- public boolean publishAction(
+ public void publishAction(
final ObjectAction objectAction,
final IdentifiedHolder identifiedHolder,
final ObjectAdapter targetAdapter,
final List<ObjectAdapter> parameterAdapters,
final ObjectAdapter resultAdapter) {
if(!canPublish()) {
- return true;
+ return;
}
final String currentUser = userService.getUser().getName();
@@ -205,7 +179,7 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
final PublishedActionFacet publishedActionFacet =
identifiedHolder.getFacet(PublishedActionFacet.class);
if(publishedActionFacet == null) {
- return true;
+ return;
}
final RootOid adapterOid = (RootOid) targetAdapter.getOid();
@@ -258,7 +232,6 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
ObjectAdapter.Util.unwrap(undeletedElseEmpty(resultAdapter)));
payload.withStringifier(stringifier);
publishingServiceIfAny.publish(metadata, payload);
- return false;
}
private static <T> List<T> immutableList(final Iterable<T> iterable) {