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 2015/01/22 13:40:34 UTC
[5/6] isis git commit: ISIS-970: unit testing of @Action annotation
ISIS-970: unit testing of @Action annotation
Includes:
- HiddenFacet is now multi-typed (as a minor improvement so that all hidden facets are held (as HidingInteractionAdvisors) and added to, rather than potentially being replaced as the "blessed" facet impl.
- slight alteration (simplification) of the design of @Action(restrictoTo=...)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/18d470c3
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/18d470c3
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/18d470c3
Branch: refs/heads/ISIS-970
Commit: 18d470c3d0246e55a72118b6635cbbba3a2c50ab
Parents: 715502f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Jan 22 12:07:37 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Jan 22 12:07:37 2015 +0000
----------------------------------------------------------------------
.../apache/isis/applib/annotation/Action.java | 4 +-
.../apache/isis/applib/annotation/Command.java | 2 +-
.../applib/annotation/CommandReification.java | 10 +-
.../isis/applib/annotation/Environment.java | 34 -
.../isis/applib/annotation/RestrictTo.java | 27 +
.../applib/fixturescripts/FixtureScripts.java | 2 +-
.../core/metamodel/facetapi/FacetHolder.java | 2 +-
.../isis/core/metamodel/facetapi/FacetUtil.java | 14 +-
.../metamodel/facets/DomainEventHelper.java | 355 ++++++
.../metamodel/facets/InteractionHelper.java | 355 ------
.../action/ActionAnnotationFacetFactory.java | 73 +-
.../action/bulk/BulkFacetForBulkAnnotation.java | 45 +
.../command/CommandActionsConfiguration.java | 42 +
.../CommandFacetForActionAnnotation.java | 20 +-
...andFacetForActionAnnotationAsConfigured.java | 36 +
.../command/CommandFacetFromConfiguration.java | 41 +
.../hidden/HiddenFacetForActionAnnotation.java | 2 +-
.../ActionDomainEventFacetAbstract.java | 18 +-
...onInvocationFacetForDomainEventAbstract.java | 10 +-
.../PrototypeFacetForActionAnnotation.java | 12 +-
...PublishedActionFacetForActionAnnotation.java | 62 +-
...ionFacetForActionAnnotationAsConfigured.java | 33 +
...ActionFacetForPublishedActionAnnotation.java | 67 ++
.../PublishedActionFacetFromConfiguration.java | 34 +
...onSemanticsFacetFallbackToNonIdempotent.java | 32 +
...anticsFacetForActionSemanticsAnnotation.java | 50 +
...nSemanticsFacetFromIdempotentAnnotation.java | 41 +
...onSemanticsFacetFromQueryOnlyAnnotation.java | 40 +
.../bulk/annotation/BulkFacetAnnotation.java | 45 -
.../annotation/BulkFacetAnnotationFactory.java | 39 -
.../configuration/ActionConfiguration.java | 42 -
.../CommandFacetFromConfiguration.java | 41 -
...HiddenFacetOnActionFromLayoutProperties.java | 27 +-
.../actions/prototype/PrototypeFacet.java | 7 +-
.../prototype/PrototypeFacetAbstract.java | 8 +-
.../publish/PublishedActionFacetAbstract.java | 40 +
.../PublishedActionFacetAnnotation.java | 63 --
.../ActionSemanticsFacetAnnotation.java | 46 -
.../ActionSemanticsFacetAnnotationFactory.java | 40 -
.../idempotent/IdempotentFacetAnnotation.java | 32 -
.../IdempotentFacetAnnotationFactory.java | 46 -
.../queryonly/QueryOnlyFacetAnnotation.java | 31 -
.../QueryOnlyFacetAnnotationFactory.java | 45 -
...onSemanticsFacetFallbackToNonIdempotent.java | 32 -
...ticsFacetFallbackToNonIdempotentFactory.java | 48 -
.../metamodel/facets/all/hide/HiddenFacet.java | 3 +-
.../HiddenFacetForCollectionAnnotation.java | 2 +-
...ionAddToFacetForDomainEventFromAbstract.java | 12 +-
.../CollectionDomainEventFacetAbstract.java | 18 +-
...moveFromFacetForDomainEventFromAbstract.java | 12 +-
...enFacetOnCollectionFromLayoutProperties.java | 27 +-
.../members/hidden/HiddenFacetAbstract.java | 40 +-
.../HiddenFacetAbstractAlwaysEverywhere.java | 14 +-
.../members/hidden/HiddenFacetAbstractImpl.java | 10 +-
...HiddenFacetFromLayoutPropertiesAbstract.java | 53 +
.../HiddenFacetOnMemberAnnotation.java | 2 +-
.../HiddenFacetOnMemberFromProperties.java | 4 +-
.../staticmethod/HiddenFacetOnStaticMethod.java | 2 +-
.../annotation/HiddenFacetOnTypeAnnotation.java | 2 +-
.../PublishedObjectFacetAbstract.java | 6 +-
.../HiddenFacetForPropertyAnnotation.java | 2 +-
...ropertyClearFacetForDomainEventAbstract.java | 12 +-
.../PropertyDomainEventFacetAbstract.java | 18 +-
...opertySetterFacetForDomainEventAbstract.java | 12 +-
.../HiddenFacetForPropertyLayoutAnnotation.java | 2 +-
...ddenFacetOnPropertyFromLayoutProperties.java | 31 +-
.../json/LayoutMetadataReaderFromJson.java | 113 +-
.../metamodel/spec/feature/ObjectAction.java | 17 -
.../dflt/ProgrammingModelFacetsJava5.java | 13 +-
...entHelperTest_newActionInteractionEvent.java | 84 ++
...perTest_newCollectionDomainEvent_forAdd.java | 85 ++
...Test_newCollectionDomainEvent_forRemove.java | 85 ++
...perTest_newPropertyDomainEvent_forClear.java | 72 ++
...erTest_newPropertyDomainEvent_forModify.java | 71 ++
...ractionHelper_newActionInteractionEvent.java | 84 --
...er_newCollectionInteractionEvent_forAdd.java | 85 --
...newCollectionInteractionEvent_forRemove.java | 85 --
...er_newPropertyInteractionEvent_forClear.java | 72 --
...r_newPropertyInteractionEvent_forModify.java | 71 --
.../actions/ActionMethodsFacetFactoryTest.java | 11 +-
.../ActionAnnotationFacetFactoryTest.java | 1064 +++++++++++++++++-
...tionFacetFactoryTest_forActionSemantics.java | 20 +-
...FacetFallbackToNonIdempotentFactoryTest.java | 63 ++
.../IdempotentFacetAnnotationFactoryTest.java | 64 ++
.../QueryOnlyFacetAnnotationFactoryTest.java | 65 ++
.../prototype/PrototypeFacetAbstractTest.java | 47 +
...FacetFallbackToNonIdempotentFactoryTest.java | 87 --
.../IdempotentFacetAnnotationFactoryTest.java | 81 --
.../QueryOnlyFacetAnnotationFactoryTest.java | 81 --
.../CollectionFieldMethodsFacetFactoryTest.java | 52 +-
.../HiddenAnnotationFacetFactoryTest.java | 50 +-
.../PropertyMethodsFacetFactoryTest.java | 8 +-
...jectAssociationFiltersTest_visibleWhere.java | 33 +-
.../simple/SimpleObjectsFixturesService.java | 4 +-
.../dom/src/main/java/dom/todo/ToDoItem.java | 6 +-
.../java/dom/todo/ToDoItemSubscriptions.java | 4 +-
.../dom/src/main/java/dom/todo/ToDoItems.java | 4 +-
.../fixture/todo/ToDoItemsFixturesService.java | 6 +-
.../prototyping/ExternalLinksService.java | 4 +-
99 files changed, 2983 insertions(+), 2087 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
index ed56e54..fb9290e 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
@@ -173,13 +173,13 @@ public @interface Action {
/**
- * Which environments the action is available in.
+ * Whether the action is restricted to prototyping.
*
* <p>
* By default there are no restrictions, with the action being available in all environments.
* </p>
*/
- Environment[] restrictTo() default {Environment.DEVELOPMENT, Environment.PRODUCTION};
+ RestrictTo restrictTo() default RestrictTo.NO_RESTRICTIONS;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/annotation/Command.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Command.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Command.java
index 4cb8ce5..56407b6 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Command.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Command.java
@@ -92,7 +92,7 @@ public @interface Command {
/**
- * @deprecated - use {@link org.apache.isis.applib.annotation.Action#commandDisabled()}.
+ * @deprecated - use {@link Action#command()} to specify if the action is handled as a command or not.
*/
@Deprecated
boolean disabled() default false;
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/annotation/CommandReification.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/CommandReification.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/CommandReification.java
index 11d1734..03769b0 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/CommandReification.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/CommandReification.java
@@ -29,7 +29,7 @@ package org.apache.isis.applib.annotation;
*/
public enum CommandReification {
/**
- * Whether the action should be handled as a command is per the default editing policy configured in <tt>isis.properties</tt>.
+ * Whether the action should be handled as a command is per the default command configured in <tt>isis.properties</tt>.
*
* <p>
* If no command policy is configured, then the action is <i>not</i> treated as a command.
@@ -37,15 +37,11 @@ public enum CommandReification {
*/
AS_CONFIGURED,
/**
- * Audit changes to this object.
+ * Handle the action as a command, irrespective of any configuration settings.
*/
ENABLED,
/**
- * Do not allow the properties to be edited, or the collections to be added to/removed from.
- *
- * <p>
- * Corresponds to the {@link Immutable} annotation).
- * </p>
+ * Do not handle the action as a command, irrespective of any configuration settings.
*/
DISABLED
}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/annotation/Environment.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Environment.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Environment.java
deleted file mode 100644
index 7c2e49e..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Environment.java
+++ /dev/null
@@ -1,34 +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.applib.annotation;
-
-public enum Environment {
- DEVELOPMENT,
- PRODUCTION;
-
- public static boolean hasDevelopmentOnly(final Environment[] environments) {
-
- if (environments == null) {
- return false;
- }
-
- return environments.length == 1 && environments[0] == DEVELOPMENT;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/annotation/RestrictTo.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/RestrictTo.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/RestrictTo.java
new file mode 100644
index 0000000..140f40e
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/RestrictTo.java
@@ -0,0 +1,27 @@
+/*
+ * 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.annotation;
+
+/**
+ * Whether an action is restricted to development mode, or available in all.
+ */
+public enum RestrictTo {
+ PROTOTYPING,
+ NO_RESTRICTIONS;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
index 8d6f57f..8044277 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
@@ -245,7 +245,7 @@ public abstract class FixtureScripts extends AbstractService {
* {@link #autoComplete0RunFixtureScript(String)} with <tt>public</tt> visibility</tt>.
*/
@Action(
- restrictTo = Environment.DEVELOPMENT
+ restrictTo = RestrictTo.PROTOTYPING
)
@MemberOrder(sequence="10")
public List<FixtureResult> runFixtureScript(
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetHolder.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetHolder.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetHolder.java
index 7f82f9b..60b1461 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetHolder.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetHolder.java
@@ -58,7 +58,7 @@ public interface FacetHolder {
/**
- * Returns all {@link Facet}s matching the specified {@link FacetFilter}.
+ * Returns all {@link Facet}s matching the specified {@link Filter}.
*
* @param filter
* @return
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetUtil.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetUtil.java
index 2116a68..b5e67f7 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetUtil.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/FacetUtil.java
@@ -87,9 +87,6 @@ public final class FacetUtil {
/**
* Bit nasty, for use only by {@link FacetHolder}s that index their
* {@link Facet}s in a Map.
- *
- * @param facetsByClass
- * @return
*/
@SuppressWarnings("unchecked")
public static Class<? extends Facet>[] getFacetTypes(final Map<Class<? extends Facet>, Facet> facetsByClass) {
@@ -99,16 +96,13 @@ public final class FacetUtil {
/**
* Bit nasty, for use only by {@link FacetHolder}s that index their
* {@link Facet}s in a Map.
- *
- * @param facetsByClass
- * @return
*/
public static List<Facet> getFacets(final Map<Class<? extends Facet>, Facet> facetsByClass, final Filter<Facet> filter) {
final List<Facet> filteredFacets = Lists.newArrayList();
- final List<Facet> allFacets = new ArrayList<Facet>(facetsByClass.values());
- for (int i = 0; i < allFacets.size(); i++) {
- final Facet facet = allFacets.get(i);
- if (filter.accept(facet)) {
+ final List<Facet> allFacets = new ArrayList<>(facetsByClass.values());
+ for (final Facet facet : allFacets) {
+ // facets that implement MultiTypedFacet will be held more than once. The 'contains' check ensures they are only returned once, however.
+ if (filter.accept(facet) && !filteredFacets.contains(facet)) {
filteredFacets.add(facet);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
new file mode 100644
index 0000000..fb14833
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/DomainEventHelper.java
@@ -0,0 +1,355 @@
+/*
+ * 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.metamodel.facets;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import org.apache.isis.applib.FatalException;
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.command.Command2;
+import org.apache.isis.applib.services.command.Command3;
+import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
+import org.apache.isis.applib.services.eventbus.AbstractInteractionEvent;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.applib.services.eventbus.ActionInteractionEvent;
+import org.apache.isis.applib.services.eventbus.CollectionDomainEvent;
+import org.apache.isis.applib.services.eventbus.EventBusService;
+import org.apache.isis.applib.services.eventbus.PropertyDomainEvent;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+
+
+public class DomainEventHelper {
+
+ private final ServicesInjector servicesInjector;
+
+
+ public DomainEventHelper(final ServicesInjector servicesInjector) {
+ this.servicesInjector = servicesInjector;
+ }
+
+ //region > postEventForAction, newActionDomainEvent
+ @SuppressWarnings({ "rawtypes" })
+ public ActionDomainEvent<?> postEventForAction(
+ final Class eventType,
+ final ActionDomainEvent<?> existingEvent,
+ final Command command,
+ final AbstractDomainEvent.Phase phase,
+ final IdentifiedHolder identified,
+ final ObjectAdapter targetAdapter,
+ final ObjectAdapter[] argumentAdapters) {
+
+ if(!hasEventBusService()) {
+ return null;
+ }
+ try {
+ final ActionDomainEvent<?> event;
+ if (existingEvent != null && phase.isValidatingOrLater()) {
+ event = existingEvent;
+ final Object[] arguments = ObjectAdapter.Util.unwrap(argumentAdapters);
+ event.setArguments(Arrays.asList(arguments));
+ if(phase.isExecutingOrLater()) {
+
+ // current event always references the command (originally created by the xactn)
+ event.setCommand(command);
+ if(command != null) {
+ if(command instanceof Command3) {
+ final Command3 command3 = (Command3) command;
+ command3.pushActionDomainEvent(event);
+ } else if(command instanceof Command2 && event instanceof ActionInteractionEvent) {
+ final Command2 command2 = (Command3) command;
+ final ActionInteractionEvent<?> aie = (ActionInteractionEvent<?>) event;
+ command2.pushActionInteractionEvent(aie);
+ }
+ }
+ }
+ } else {
+ final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
+ final Object[] arguments = ObjectAdapter.Util.unwrap(argumentAdapters);
+ final Identifier identifier = identified.getIdentifier();
+ event = newActionDomainEvent(eventType, identifier, source, arguments);
+ }
+
+ if(identified instanceof ObjectAction) {
+ // should always be the case...
+ final ObjectAction objectAction = (ObjectAction) identified;
+ event.setActionSemantics(objectAction.getSemantics());
+ }
+
+ event.setEventPhase(phase);
+ event.setPhase(AbstractInteractionEvent.Phase.from(phase));
+ getEventBusService().post(event);
+ return event;
+ } catch (Exception e) {
+ throw new FatalException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ static <S> ActionDomainEvent<S> newActionDomainEvent(
+ final Class<? extends ActionDomainEvent<S>> type,
+ final Identifier identifier,
+ final S source,
+ final Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ final Constructor<?>[] constructors = type.getConstructors();
+ for (final Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length != 3) {
+ continue;
+ }
+ if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
+ continue;
+ }
+ if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
+ continue;
+ }
+ if(!parameterTypes[2].isAssignableFrom(Object[].class)) {
+ continue;
+ }
+ final Object event = constructor.newInstance(source, identifier, arguments);
+ return (ActionDomainEvent<S>) event;
+ }
+ throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", [Ljava.lang.Object;)");
+ }
+ //endregion
+
+ //region > postEventForProperty, newPropertyInteraction
+ public PropertyDomainEvent<?, ?> postEventForProperty(
+ final Class eventType,
+ final PropertyDomainEvent<?, ?> existingEvent,
+ final AbstractDomainEvent.Phase phase,
+ final IdentifiedHolder identified,
+ final ObjectAdapter targetAdapter,
+ final Object oldValue,
+ final Object newValue) {
+ if(!hasEventBusService()) {
+ return null;
+ }
+ try {
+ final PropertyDomainEvent<?, ?> event;
+ if(existingEvent != null && phase.isValidatingOrLater()) {
+ event = existingEvent;
+ setEventOldValue(event, oldValue);
+ setEventNewValue(event, newValue);
+ } else {
+ final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
+ final Identifier identifier = identified.getIdentifier();
+ event = newPropertyDomainEvent(eventType, identifier, source, oldValue, newValue);
+ }
+ event.setEventPhase(phase);
+ event.setPhase(AbstractInteractionEvent.Phase.from(phase));
+ getEventBusService().post(event);
+ return event;
+ } catch (Exception e) {
+ throw new FatalException(e);
+ }
+ }
+
+ private static <S,T> void setEventOldValue(PropertyDomainEvent<S, T> event, Object oldValue) {
+ event.setOldValue((T) oldValue);
+ }
+
+ private static <S,T> void setEventNewValue(PropertyDomainEvent<S, T> event, Object newValue) {
+ event.setNewValue((T) newValue);
+ }
+
+ @SuppressWarnings("unchecked")
+ static <S,T> PropertyDomainEvent<S,T> newPropertyDomainEvent(
+ final Class<? extends PropertyDomainEvent<S, T>> type,
+ final Identifier identifier,
+ final S source,
+ final T oldValue,
+ final T newValue) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+
+ final Constructor<?>[] constructors = type.getConstructors();
+ for (final Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length != 4) {
+ continue;
+ }
+ if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
+ continue;
+ }
+ if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
+ continue;
+ }
+ if(oldValue != null && !parameterTypes[2].isAssignableFrom(oldValue.getClass())) {
+ continue;
+ }
+ if(newValue != null && !parameterTypes[3].isAssignableFrom(newValue.getClass())) {
+ continue;
+ }
+ final Object event = constructor.newInstance(source, identifier, oldValue, newValue);
+ return (PropertyDomainEvent<S, T>) event;
+ }
+
+ throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", java.lang.Object, java.lang.Object)");
+ }
+ //endregion
+
+ //region > postEventForCollection, newCollectionDomainEvent
+
+ public CollectionDomainEvent<?, ?> postEventForCollection(
+ final Class eventType,
+ final CollectionDomainEvent<?, ?> existingEvent,
+ AbstractDomainEvent.Phase phase,
+ final IdentifiedHolder identified,
+ final ObjectAdapter targetAdapter,
+ final CollectionDomainEvent.Of of,
+ final Object reference) {
+ if(!hasEventBusService()) {
+ return null;
+ }
+ try {
+ final CollectionDomainEvent<?, ?> event;
+ if (existingEvent != null && phase.isValidatingOrLater()) {
+ event = existingEvent;
+ event.setOf(of);
+ setEventValue(event, reference);
+ } else {
+ final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
+ final Identifier identifier = identified.getIdentifier();
+ event = newCollectionDomainEvent(eventType, phase, identifier, source, of, reference);
+ }
+ event.setEventPhase(phase);
+ event.setPhase(AbstractInteractionEvent.Phase.from(phase));
+ getEventBusService().post(event);
+ return event;
+ } catch (Exception e) {
+ throw new FatalException(e);
+ }
+ }
+
+ private static <T,S> void setEventValue(CollectionDomainEvent<T, S> event, Object reference) {
+ event.setValue((S) reference);
+ }
+
+ @SuppressWarnings("unchecked")
+ <S, T> CollectionDomainEvent<S, T> newCollectionDomainEvent(
+ final Class<? extends CollectionDomainEvent<S, T>> type,
+ final AbstractDomainEvent.Phase phase,
+ final Identifier identifier,
+ final S source,
+ final CollectionDomainEvent.Of of,
+ final T value)
+ throws NoSuchMethodException, SecurityException, InstantiationException,
+ IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+
+ final Constructor<?>[] constructors = type.getConstructors();
+
+ // search for constructor accepting source, identifier, type, value
+ for (final Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length != 4) {
+ continue;
+ }
+ if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
+ continue;
+ }
+ if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
+ continue;
+ }
+ if(!parameterTypes[2].isAssignableFrom(CollectionDomainEvent.Of.class)) {
+ continue;
+ }
+ if(value != null && !parameterTypes[3].isAssignableFrom(value.getClass())) {
+ continue;
+ }
+ final Object event = constructor.newInstance(source, identifier, of, value);
+ return (CollectionDomainEvent<S, T>) event;
+ }
+
+ if(phase == AbstractDomainEvent.Phase.EXECUTED) {
+ if(of == CollectionDomainEvent.Of.ADD_TO) {
+ // support for @PostsCollectionAddedTo annotation:
+ // search for constructor accepting source, identifier, value
+ for (final Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length != 3) {
+ continue;
+ }
+ if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
+ continue;
+ }
+ if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
+ continue;
+ }
+ if(value != null && !parameterTypes[2].isAssignableFrom(value.getClass())) {
+ continue;
+ }
+ final Object event = constructor.newInstance(source, identifier, value);
+ return (CollectionDomainEvent<S, T>) event;
+ }
+ } else if(of == CollectionDomainEvent.Of.REMOVE_FROM) {
+ // support for @PostsCollectionRemovedFrom annotation:
+ // search for constructor accepting source, identifier, value
+ for (final Constructor<?> constructor : constructors) {
+ final Class<?>[] parameterTypes = constructor.getParameterTypes();
+ if(parameterTypes.length != 3) {
+ continue;
+ }
+ if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
+ continue;
+ }
+ if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
+ continue;
+ }
+ if(value != null && !parameterTypes[2].isAssignableFrom(value.getClass())) {
+ continue;
+ }
+ final Object event = constructor.newInstance(
+ source, identifier, value);
+ return (CollectionDomainEvent<S, T>) event;
+ }
+ }
+ }
+ throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", java.lang.Object)");
+ }
+
+ //endregion
+
+
+ //region > eventBusService
+
+ private EventBusService eventBusService;
+ private boolean searchedForEventBusService = false;
+
+ public boolean hasEventBusService() {
+ return getEventBusService() != null;
+ }
+
+ private EventBusService getEventBusService() {
+ if (!searchedForEventBusService) {
+ eventBusService = this.servicesInjector.lookupService(EventBusService.class);
+ }
+ // this caching has been disabled, because it prevents integration tests from switching out the
+ // EventBusService with a mock.
+ // perhaps a better appraoch
+ //searchedForEventBusService = true;
+ return eventBusService;
+ }
+
+ //endregion
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/InteractionHelper.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/InteractionHelper.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/InteractionHelper.java
deleted file mode 100644
index bd6552d..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/InteractionHelper.java
+++ /dev/null
@@ -1,355 +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.metamodel.facets;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import org.apache.isis.applib.FatalException;
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command2;
-import org.apache.isis.applib.services.command.Command3;
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
-import org.apache.isis.applib.services.eventbus.AbstractInteractionEvent;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.applib.services.eventbus.ActionInteractionEvent;
-import org.apache.isis.applib.services.eventbus.CollectionDomainEvent;
-import org.apache.isis.applib.services.eventbus.EventBusService;
-import org.apache.isis.applib.services.eventbus.PropertyDomainEvent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-
-
-public class InteractionHelper {
-
- private final ServicesInjector servicesInjector;
-
-
- public InteractionHelper(final ServicesInjector servicesInjector) {
- this.servicesInjector = servicesInjector;
- }
-
- //region > postEventForAction, newActionDomainEvent
- @SuppressWarnings({ "rawtypes" })
- public ActionDomainEvent<?> postEventForAction(
- final Class eventType,
- final ActionDomainEvent<?> existingEvent,
- final Command command,
- final AbstractDomainEvent.Phase phase,
- final IdentifiedHolder identified,
- final ObjectAdapter targetAdapter,
- final ObjectAdapter[] argumentAdapters) {
-
- if(!hasEventBusService()) {
- return null;
- }
- try {
- final ActionDomainEvent<?> event;
- if (existingEvent != null && phase.isValidatingOrLater()) {
- event = existingEvent;
- final Object[] arguments = ObjectAdapter.Util.unwrap(argumentAdapters);
- event.setArguments(Arrays.asList(arguments));
- if(phase.isExecutingOrLater()) {
-
- // current event always references the command (originally created by the xactn)
- event.setCommand(command);
- if(command != null) {
- if(command instanceof Command3) {
- final Command3 command3 = (Command3) command;
- command3.pushActionDomainEvent(event);
- } else if(command instanceof Command2 && event instanceof ActionInteractionEvent) {
- final Command2 command2 = (Command3) command;
- final ActionInteractionEvent<?> aie = (ActionInteractionEvent<?>) event;
- command2.pushActionInteractionEvent(aie);
- }
- }
- }
- } else {
- final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
- final Object[] arguments = ObjectAdapter.Util.unwrap(argumentAdapters);
- final Identifier identifier = identified.getIdentifier();
- event = newActionDomainEvent(eventType, identifier, source, arguments);
- }
-
- if(identified instanceof ObjectAction) {
- // should always be the case...
- final ObjectAction objectAction = (ObjectAction) identified;
- event.setActionSemantics(objectAction.getSemantics());
- }
-
- event.setEventPhase(phase);
- event.setPhase(AbstractInteractionEvent.Phase.from(phase));
- getEventBusService().post(event);
- return event;
- } catch (Exception e) {
- throw new FatalException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- static <S> ActionDomainEvent<S> newActionDomainEvent(
- final Class<? extends ActionDomainEvent<S>> type,
- final Identifier identifier,
- final S source,
- final Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- final Constructor<?>[] constructors = type.getConstructors();
- for (final Constructor<?> constructor : constructors) {
- final Class<?>[] parameterTypes = constructor.getParameterTypes();
- if(parameterTypes.length != 3) {
- continue;
- }
- if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
- continue;
- }
- if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
- continue;
- }
- if(!parameterTypes[2].isAssignableFrom(Object[].class)) {
- continue;
- }
- final Object event = constructor.newInstance(source, identifier, arguments);
- return (ActionDomainEvent<S>) event;
- }
- throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", [Ljava.lang.Object;)");
- }
- //endregion
-
- //region > postEventForProperty, newPropertyInteraction
- public PropertyDomainEvent<?, ?> postEventForProperty(
- final Class eventType,
- final PropertyDomainEvent<?, ?> existingEvent,
- final AbstractDomainEvent.Phase phase,
- final IdentifiedHolder identified,
- final ObjectAdapter targetAdapter,
- final Object oldValue,
- final Object newValue) {
- if(!hasEventBusService()) {
- return null;
- }
- try {
- final PropertyDomainEvent<?, ?> event;
- if(existingEvent != null && phase.isValidatingOrLater()) {
- event = existingEvent;
- setEventOldValue(event, oldValue);
- setEventNewValue(event, newValue);
- } else {
- final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
- final Identifier identifier = identified.getIdentifier();
- event = newPropertyDomainEvent(eventType, identifier, source, oldValue, newValue);
- }
- event.setEventPhase(phase);
- event.setPhase(AbstractInteractionEvent.Phase.from(phase));
- getEventBusService().post(event);
- return event;
- } catch (Exception e) {
- throw new FatalException(e);
- }
- }
-
- private static <S,T> void setEventOldValue(PropertyDomainEvent<S, T> event, Object oldValue) {
- event.setOldValue((T) oldValue);
- }
-
- private static <S,T> void setEventNewValue(PropertyDomainEvent<S, T> event, Object newValue) {
- event.setNewValue((T) newValue);
- }
-
- @SuppressWarnings("unchecked")
- static <S,T> PropertyDomainEvent<S,T> newPropertyDomainEvent(
- final Class<? extends PropertyDomainEvent<S, T>> type,
- final Identifier identifier,
- final S source,
- final T oldValue,
- final T newValue) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- final Constructor<?>[] constructors = type.getConstructors();
- for (final Constructor<?> constructor : constructors) {
- final Class<?>[] parameterTypes = constructor.getParameterTypes();
- if(parameterTypes.length != 4) {
- continue;
- }
- if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
- continue;
- }
- if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
- continue;
- }
- if(oldValue != null && !parameterTypes[2].isAssignableFrom(oldValue.getClass())) {
- continue;
- }
- if(newValue != null && !parameterTypes[3].isAssignableFrom(newValue.getClass())) {
- continue;
- }
- final Object event = constructor.newInstance(source, identifier, oldValue, newValue);
- return (PropertyDomainEvent<S, T>) event;
- }
-
- throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", java.lang.Object, java.lang.Object)");
- }
- //endregion
-
- //region > postEventForCollection, newCollectionDomainEvent
-
- public CollectionDomainEvent<?, ?> postEventForCollection(
- final Class eventType,
- final CollectionDomainEvent<?, ?> existingEvent,
- AbstractDomainEvent.Phase phase,
- final IdentifiedHolder identified,
- final ObjectAdapter targetAdapter,
- final CollectionDomainEvent.Of of,
- final Object reference) {
- if(!hasEventBusService()) {
- return null;
- }
- try {
- final CollectionDomainEvent<?, ?> event;
- if (existingEvent != null && phase.isValidatingOrLater()) {
- event = existingEvent;
- event.setOf(of);
- setEventValue(event, reference);
- } else {
- final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
- final Identifier identifier = identified.getIdentifier();
- event = newCollectionDomainEvent(eventType, phase, identifier, source, of, reference);
- }
- event.setEventPhase(phase);
- event.setPhase(AbstractInteractionEvent.Phase.from(phase));
- getEventBusService().post(event);
- return event;
- } catch (Exception e) {
- throw new FatalException(e);
- }
- }
-
- private static <T,S> void setEventValue(CollectionDomainEvent<T, S> event, Object reference) {
- event.setValue((S) reference);
- }
-
- @SuppressWarnings("unchecked")
- <S, T> CollectionDomainEvent<S, T> newCollectionDomainEvent(
- final Class<? extends CollectionDomainEvent<S, T>> type,
- final AbstractDomainEvent.Phase phase,
- final Identifier identifier,
- final S source,
- final CollectionDomainEvent.Of of,
- final T value)
- throws NoSuchMethodException, SecurityException, InstantiationException,
- IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- final Constructor<?>[] constructors = type.getConstructors();
-
- // search for constructor accepting source, identifier, type, value
- for (final Constructor<?> constructor : constructors) {
- final Class<?>[] parameterTypes = constructor.getParameterTypes();
- if(parameterTypes.length != 4) {
- continue;
- }
- if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
- continue;
- }
- if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
- continue;
- }
- if(!parameterTypes[2].isAssignableFrom(CollectionDomainEvent.Of.class)) {
- continue;
- }
- if(value != null && !parameterTypes[3].isAssignableFrom(value.getClass())) {
- continue;
- }
- final Object event = constructor.newInstance(source, identifier, of, value);
- return (CollectionDomainEvent<S, T>) event;
- }
-
- if(phase == AbstractDomainEvent.Phase.EXECUTED) {
- if(of == CollectionDomainEvent.Of.ADD_TO) {
- // support for @PostsCollectionAddedTo annotation:
- // search for constructor accepting source, identifier, value
- for (final Constructor<?> constructor : constructors) {
- final Class<?>[] parameterTypes = constructor.getParameterTypes();
- if(parameterTypes.length != 3) {
- continue;
- }
- if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
- continue;
- }
- if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
- continue;
- }
- if(value != null && !parameterTypes[2].isAssignableFrom(value.getClass())) {
- continue;
- }
- final Object event = constructor.newInstance(source, identifier, value);
- return (CollectionDomainEvent<S, T>) event;
- }
- } else if(of == CollectionDomainEvent.Of.REMOVE_FROM) {
- // support for @PostsCollectionRemovedFrom annotation:
- // search for constructor accepting source, identifier, value
- for (final Constructor<?> constructor : constructors) {
- final Class<?>[] parameterTypes = constructor.getParameterTypes();
- if(parameterTypes.length != 3) {
- continue;
- }
- if(!parameterTypes[0].isAssignableFrom(source.getClass())) {
- continue;
- }
- if(!parameterTypes[1].isAssignableFrom(Identifier.class)) {
- continue;
- }
- if(value != null && !parameterTypes[2].isAssignableFrom(value.getClass())) {
- continue;
- }
- final Object event = constructor.newInstance(
- source, identifier, value);
- return (CollectionDomainEvent<S, T>) event;
- }
- }
- }
- throw new NoSuchMethodException(type.getName()+".<init>(? super " + source.getClass().getName() + ", " + Identifier.class.getName() + ", java.lang.Object)");
- }
-
- //endregion
-
-
- //region > eventBusService
-
- private EventBusService eventBusService;
- private boolean searchedForEventBusService = false;
-
- public boolean hasEventBusService() {
- return getEventBusService() != null;
- }
-
- private EventBusService getEventBusService() {
- if (!searchedForEventBusService) {
- eventBusService = this.servicesInjector.lookupService(EventBusService.class);
- }
- // this caching has been disabled, because it prevents integration tests from switching out the
- // EventBusService with a mock.
- // perhaps a better appraoch
- //searchedForEventBusService = true;
- return eventBusService;
- }
-
- //endregion
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionAnnotationFacetFactory.java
index d453274..4cd5439 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionAnnotationFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/ActionAnnotationFacetFactory.java
@@ -29,8 +29,10 @@ import org.apache.isis.applib.annotation.ActionInteraction;
import org.apache.isis.applib.annotation.ActionSemantics;
import org.apache.isis.applib.annotation.Bulk;
import org.apache.isis.applib.annotation.Command;
+import org.apache.isis.applib.annotation.Idempotent;
import org.apache.isis.applib.annotation.PostsActionInvokedEvent;
import org.apache.isis.applib.annotation.PublishedAction;
+import org.apache.isis.applib.annotation.QueryOnly;
import org.apache.isis.applib.annotation.TypeOf;
import org.apache.isis.applib.services.HasTransactionId;
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
@@ -51,28 +53,32 @@ import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetInferredF
import org.apache.isis.core.metamodel.facets.actions.action.bulk.BulkFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.command.CommandFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.command.CommandFacetForCommandAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.hidden.HiddenFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionDomainEventFacetAbstract;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionDomainEventFacetDefault;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionDomainEventFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionDomainEventFacetForActionInteractionAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventFromActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventFromActionInteractionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventFromDefault;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract;
import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForPostsActionInvokedEventAnnotation;
-import org.apache.isis.core.metamodel.facets.actions.action.hidden.HiddenFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.prototype.PrototypeFacetForActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.action.publishing.PublishedActionFacetForActionAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.semantics.ActionSemanticsFacetFallbackToNonIdempotent;
import org.apache.isis.core.metamodel.facets.actions.action.semantics.ActionSemanticsFacetForActionAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.semantics.ActionSemanticsFacetFromIdempotentAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.semantics.ActionSemanticsFacetFromQueryOnlyAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.typeof.TypeOfFacetForActionAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.typeof.TypeOfFacetOnActionForTypeOfAnnotation;
import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
-import org.apache.isis.core.metamodel.facets.actions.bulk.annotation.BulkFacetAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.bulk.BulkFacetForBulkAnnotation;
import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
-import org.apache.isis.core.metamodel.facets.actions.publish.annotation.PublishedActionFacetAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.publishing.PublishedActionFacetForPublishedActionAnnotation;
import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
-import org.apache.isis.core.metamodel.facets.actions.semantics.annotations.actionsemantics.ActionSemanticsFacetAnnotation;
-import org.apache.isis.core.metamodel.facets.actions.action.typeof.TypeOfFacetForActionAnnotation;
-import org.apache.isis.core.metamodel.facets.actions.action.typeof.TypeOfFacetOnActionForTypeOfAnnotation;
+import org.apache.isis.core.metamodel.facets.actions.action.semantics.ActionSemanticsFacetForActionSemanticsAnnotation;
+import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
import org.apache.isis.core.metamodel.runtimecontext.RuntimeContextAware;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
@@ -198,7 +204,8 @@ public class ActionAnnotationFacetFactory extends FacetFactoryAbstract implement
final Action action = Annotations.getAnnotation(method, Action.class);
final FacetHolder holder = processMethodContext.getFacetHolder();
- FacetUtil.addFacet(HiddenFacetForActionAnnotation.create(action, holder));
+ HiddenFacet facet = HiddenFacetForActionAnnotation.create(action, holder);
+ FacetUtil.addFacet(facet);
}
void processRestrictTo(final ProcessMethodContext processMethodContext) {
@@ -211,22 +218,37 @@ public class ActionAnnotationFacetFactory extends FacetFactoryAbstract implement
void processSemantics(final ProcessMethodContext processMethodContext) {
final Method method = processMethodContext.getMethod();
- final Action action = Annotations.getAnnotation(method, Action.class);
final FacetHolder holder = processMethodContext.getFacetHolder();
ActionSemanticsFacet facet;
- //
- // check for the deprecated @ActionSemantics first, because the
- // @Action(semantics=...) has a default of NON_IDEMPOTENT that would otherwise be used
- //
- final ActionSemantics actionSemantics = Annotations.getAnnotation(method, ActionSemantics.class);
- facet = ActionSemanticsFacetAnnotation.create(actionSemantics, holder);
+ // check for the deprecated @QueryOnly...
+ final QueryOnly queryOnly = Annotations.getAnnotation(processMethodContext.getMethod(), QueryOnly.class);
+ facet = ActionSemanticsFacetFromQueryOnlyAnnotation.create(queryOnly, holder);
+
+ // else check for the deprecated @Idempotent...
+ if(facet == null) {
+ final Idempotent idempotent = Annotations.getAnnotation(processMethodContext.getMethod(), Idempotent.class);
+ facet = ActionSemanticsFacetFromIdempotentAnnotation.create(idempotent, holder);
+ }
+
+ // else check for the deprecated @ActionSemantics ...
+ if(facet == null) {
+ final ActionSemantics actionSemantics = Annotations.getAnnotation(method, ActionSemantics.class);
+ facet = ActionSemanticsFacetForActionSemanticsAnnotation.create(actionSemantics, holder);
+ }
// else check for @Action(semantics=...)
if(facet == null) {
+ final Action action = Annotations.getAnnotation(method, Action.class);
facet = ActionSemanticsFacetForActionAnnotation.create(action, holder);
}
+
+ // else fallback
+ if(facet == null) {
+ facet = new ActionSemanticsFacetFallbackToNonIdempotent(holder);
+ }
+
FacetUtil.addFacet(facet);
}
@@ -235,18 +257,18 @@ public class ActionAnnotationFacetFactory extends FacetFactoryAbstract implement
final Action action = Annotations.getAnnotation(method, Action.class);
final FacetHolder holder = processMethodContext.getFacetHolder();
- BulkFacet bulkFacet;
+ BulkFacet facet;
// check for the deprecated @Bulk annotation first
final Bulk annotation = Annotations.getAnnotation(method, Bulk.class);
- bulkFacet = BulkFacetAnnotation.create(annotation, holder);
+ facet = BulkFacetForBulkAnnotation.create(annotation, holder);
// else check for @Action(invokeOn=...)
- if(bulkFacet == null) {
- bulkFacet = BulkFacetForActionAnnotation.create(action, holder);
+ if(facet == null) {
+ facet = BulkFacetForActionAnnotation.create(action, holder);
}
- FacetUtil.addFacet(bulkFacet);
+ FacetUtil.addFacet(facet);
}
void processCommand(final ProcessMethodContext processMethodContext) {
@@ -297,21 +319,20 @@ public class ActionAnnotationFacetFactory extends FacetFactoryAbstract implement
return;
}
- PublishedActionFacet publishedActionFacet;
+ PublishedActionFacet facet;
// check for deprecated @PublishedAction annotation first
final PublishedAction annotation = Annotations.getAnnotation(processMethodContext.getMethod(), PublishedAction.class);
- publishedActionFacet = PublishedActionFacetAnnotation.create(annotation, holder);
+ facet = PublishedActionFacetForPublishedActionAnnotation.create(annotation, holder);
// else check for @Action(publishing=...)
- if(publishedActionFacet == null) {
- publishedActionFacet = PublishedActionFacetForActionAnnotation.create(action, configuration, holder);
+ if(facet == null) {
+ facet = PublishedActionFacetForActionAnnotation.create(action, configuration, holder);
}
- FacetUtil.addFacet(publishedActionFacet);
+ FacetUtil.addFacet(facet);
}
-
void processTypeOf(final ProcessMethodContext processMethodContext) {
final Method method = processMethodContext.getMethod();
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/bulk/BulkFacetForBulkAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/bulk/BulkFacetForBulkAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/bulk/BulkFacetForBulkAnnotation.java
new file mode 100644
index 0000000..3ea6ff2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/bulk/BulkFacetForBulkAnnotation.java
@@ -0,0 +1,45 @@
+/*
+ * 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.metamodel.facets.actions.action.bulk;
+
+import org.apache.isis.applib.annotation.Bulk;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
+import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacetAbstract;
+
+public class BulkFacetForBulkAnnotation extends BulkFacetAbstract {
+
+ public static BulkFacet create(
+ final Bulk annotation,
+ final FacetHolder holder) {
+
+ if (annotation == null) {
+ return null;
+ }
+
+ return new BulkFacetForBulkAnnotation(annotation.value(), holder);
+ }
+
+ private BulkFacetForBulkAnnotation(Bulk.AppliesTo value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandActionsConfiguration.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandActionsConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandActionsConfiguration.java
new file mode 100644
index 0000000..2b63609
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandActionsConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * 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.metamodel.facets.actions.action.command;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facets.object.domainobject.Util;
+
+public enum CommandActionsConfiguration {
+ ALL,
+ IGNORE_SAFE,
+ NONE;
+
+ private static final String COMMAND_ACTIONS_KEY = "isis.services.command.actions";
+
+ public static CommandActionsConfiguration parse(final IsisConfiguration configuration) {
+ return parse(configuration.getString(COMMAND_ACTIONS_KEY));
+ }
+
+ private static CommandActionsConfiguration parse(final String value) {
+ if ("ignoreQueryOnly".equalsIgnoreCase(value) || "ignoreSafe".equalsIgnoreCase(value)) {
+ return IGNORE_SAFE;
+ }
+ // must be explicitly enabled
+ return Util.parseYes(value)? ALL: NONE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotation.java
index 052cb58..3777d1d 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotation.java
@@ -29,8 +29,6 @@ import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
import org.apache.isis.core.metamodel.facets.actions.command.CommandFacetAbstract;
-import org.apache.isis.core.metamodel.facets.actions.command.configuration.ActionConfiguration;
-import org.apache.isis.core.metamodel.facets.actions.command.configuration.CommandFacetFromConfiguration;
import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
public class CommandFacetForActionAnnotation extends CommandFacetAbstract {
@@ -49,26 +47,22 @@ public class CommandFacetForActionAnnotation extends CommandFacetAbstract {
switch (command) {
case AS_CONFIGURED:
- final ActionSemanticsFacet actionSemanticsFacet = holder.getFacet(ActionSemanticsFacet.class);
- if(actionSemanticsFacet == null) {
- throw new IllegalStateException("Require ActionSemanticsFacet in order to process");
- }
- if(holder.containsDoOpFacet(CommandFacet.class)) {
- // do not replace
- return null;
- }
- final ActionConfiguration setting = ActionConfiguration.parse(configuration);
+ final CommandActionsConfiguration setting = CommandActionsConfiguration.parse(configuration);
switch (setting) {
case NONE:
return null;
case IGNORE_SAFE:
+ final ActionSemanticsFacet actionSemanticsFacet = holder.getFacet(ActionSemanticsFacet.class);
+ if(actionSemanticsFacet == null) {
+ throw new IllegalStateException("Require ActionSemanticsFacet in order to process");
+ }
if(actionSemanticsFacet.value() == ActionSemantics.Of.SAFE) {
return null;
}
// else fall through
default:
return action != null
- ? new CommandFacetForActionAnnotation(persistence, executeIn, Enablement.ENABLED, holder)
+ ? new CommandFacetForActionAnnotationAsConfigured(persistence, executeIn, Enablement.ENABLED, holder)
: CommandFacetFromConfiguration.create(holder);
}
case DISABLED:
@@ -81,7 +75,7 @@ public class CommandFacetForActionAnnotation extends CommandFacetAbstract {
}
- private CommandFacetForActionAnnotation(
+ CommandFacetForActionAnnotation(
final Persistence persistence,
final ExecuteIn executeIn,
final Enablement enablement,
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotationAsConfigured.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotationAsConfigured.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotationAsConfigured.java
new file mode 100644
index 0000000..1433500
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetForActionAnnotationAsConfigured.java
@@ -0,0 +1,36 @@
+/*
+ * 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.metamodel.facets.actions.action.command;
+
+import org.apache.isis.applib.annotation.Command.ExecuteIn;
+import org.apache.isis.applib.annotation.Command.Persistence;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public class CommandFacetForActionAnnotationAsConfigured extends CommandFacetForActionAnnotation {
+
+ CommandFacetForActionAnnotationAsConfigured(
+ final Persistence persistence,
+ final ExecuteIn executeIn,
+ final Enablement enablement,
+ final FacetHolder holder) {
+ super(persistence, executeIn, enablement, holder);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetFromConfiguration.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetFromConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetFromConfiguration.java
new file mode 100644
index 0000000..1533331
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/command/CommandFacetFromConfiguration.java
@@ -0,0 +1,41 @@
+/*
+ * 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.metamodel.facets.actions.action.command;
+
+import org.apache.isis.applib.annotation.Command.ExecuteIn;
+import org.apache.isis.applib.annotation.Command.Persistence;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
+import org.apache.isis.core.metamodel.facets.actions.command.CommandFacetAbstract;
+
+public class CommandFacetFromConfiguration extends CommandFacetAbstract {
+
+ public static CommandFacet create(final FacetHolder holder) {
+ return new CommandFacetFromConfiguration(Persistence.PERSISTED, ExecuteIn.FOREGROUND, holder);
+ }
+
+ private CommandFacetFromConfiguration(
+ final Persistence persistence,
+ final ExecuteIn executeIn,
+ final FacetHolder holder) {
+ super(persistence, executeIn, Enablement.ENABLED, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/hidden/HiddenFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/hidden/HiddenFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/hidden/HiddenFacetForActionAnnotation.java
index ece95c7..5631252 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/hidden/HiddenFacetForActionAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/hidden/HiddenFacetForActionAnnotation.java
@@ -45,7 +45,7 @@ public class HiddenFacetForActionAnnotation extends HiddenFacetAbstract {
}
private HiddenFacetForActionAnnotation(final Where where, final FacetHolder holder) {
- super(When.ALWAYS, where, holder);
+ super(HiddenFacetForActionAnnotation.class, When.ALWAYS, where, holder);
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java
index 036f619..46ea774 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java
@@ -26,7 +26,7 @@ import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
import org.apache.isis.core.metamodel.facetapi.Facet;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.InteractionHelper;
+import org.apache.isis.core.metamodel.facets.DomainEventHelper;
import org.apache.isis.core.metamodel.facets.SingleClassValueFacetAbstract;
import org.apache.isis.core.metamodel.interactions.ActionInvocationContext;
import org.apache.isis.core.metamodel.interactions.UsabilityContext;
@@ -42,7 +42,7 @@ public abstract class ActionDomainEventFacetAbstract
return ActionDomainEventFacet.class;
}
- private final InteractionHelper interactionHelper;
+ private final DomainEventHelper domainEventHelper;
/**
* Pass event from validate to executing phases.
@@ -60,13 +60,13 @@ public abstract class ActionDomainEventFacetAbstract
final ServicesInjector servicesInjector,
final SpecificationLoader specificationLoader) {
super(type(), holder, eventType, specificationLoader);
- interactionHelper = new InteractionHelper(servicesInjector);
+ domainEventHelper = new DomainEventHelper(servicesInjector);
}
@Override
public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
+ if(!domainEventHelper.hasEventBusService()) {
return null;
}
@@ -74,7 +74,7 @@ public abstract class ActionDomainEventFacetAbstract
currentInteraction.set(null);
final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
+ domainEventHelper.postEventForAction(
eventType(), null, null, AbstractDomainEvent.Phase.HIDE,
getIdentified(), ic.getTarget(), null);
if (event != null && event.isHidden()) {
@@ -85,7 +85,7 @@ public abstract class ActionDomainEventFacetAbstract
@Override
public String disables(UsabilityContext<? extends UsabilityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
+ if(!domainEventHelper.hasEventBusService()) {
return null;
}
@@ -93,7 +93,7 @@ public abstract class ActionDomainEventFacetAbstract
currentInteraction.set(null);
final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
+ domainEventHelper.postEventForAction(
eventType(), null, null, AbstractDomainEvent.Phase.DISABLE,
getIdentified(), ic.getTarget(), null);
if (event != null && event.isDisabled()) {
@@ -104,7 +104,7 @@ public abstract class ActionDomainEventFacetAbstract
@Override
public String invalidates(ValidityContext<? extends ValidityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
+ if(!domainEventHelper.hasEventBusService()) {
return null;
}
@@ -113,7 +113,7 @@ public abstract class ActionDomainEventFacetAbstract
final ActionInvocationContext aic = (ActionInvocationContext) ic;
final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
+ domainEventHelper.postEventForAction(
eventType(), null, null, AbstractDomainEvent.Phase.VALIDATE,
getIdentified(), ic.getTarget(), aic.getArgs());
if (event != null && event.isInvalid()) {
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/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 0389035..89abf44 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
@@ -46,7 +46,7 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.InteractionHelper;
+import org.apache.isis.core.metamodel.facets.DomainEventHelper;
import org.apache.isis.core.metamodel.facets.actcoll.typeof.ElementSpecificationProviderFromTypeOfFacet;
import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
@@ -75,7 +75,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
private final ServicesInjector servicesInjector;
final Class<? extends ActionDomainEvent<?>> eventType;
- private final InteractionHelper interactionHelper;
+ private final DomainEventHelper domainEventHelper;
public ActionInvocationFacetForDomainEventAbstract(
final Class<? extends ActionDomainEvent<?>> eventType,
@@ -96,7 +96,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
this.runtimeContext = runtimeContext;
this.adapterManager = adapterManager;
this.servicesInjector = servicesInjector;
- this.interactionHelper = new InteractionHelper(servicesInjector);
+ this.domainEventHelper = new DomainEventHelper(servicesInjector);
}
/**
@@ -182,7 +182,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
// ... post the executing event
final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
+ domainEventHelper.postEventForAction(
eventType, existingEvent, command, AbstractDomainEvent.Phase.EXECUTING,
owningAction, targetAdapter, arguments);
@@ -193,7 +193,7 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
if (invocationResult.getWhetherInvoked()) {
// perhaps the Action was not properly invoked (i.e. an exception was raised).
// If invoked, then send the ActionInteractionEvent to the EventBus.
- interactionHelper.postEventForAction(
+ domainEventHelper.postEventForAction(
eventType, verify(event), command, AbstractDomainEvent.Phase.EXECUTED,
owningAction, targetAdapter, arguments);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/18d470c3/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java
index 69dc883..0eba467 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java
@@ -20,7 +20,7 @@
package org.apache.isis.core.metamodel.facets.actions.action.prototype;
import org.apache.isis.applib.annotation.Action;
-import org.apache.isis.applib.annotation.Environment;
+import org.apache.isis.applib.annotation.RestrictTo;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.actions.prototype.PrototypeFacet;
import org.apache.isis.core.metamodel.facets.actions.prototype.PrototypeFacetAbstract;
@@ -31,14 +31,10 @@ public class PrototypeFacetForActionAnnotation extends PrototypeFacetAbstract {
final Action action,
final FacetHolder holder) {
- if(action == null) {
- return null;
- }
+ return action == null || action.restrictTo() == RestrictTo.NO_RESTRICTIONS
+ ? null
+ : new PrototypeFacetForActionAnnotation(holder);
- final Environment[] environments = action.restrictTo();
- boolean developmentOnly = Environment.hasDevelopmentOnly(environments);
-
- return developmentOnly ? new PrototypeFacetForActionAnnotation(holder) : null;
}
private PrototypeFacetForActionAnnotation(FacetHolder holder) {