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 17:57:05 UTC

[37/50] [abbrv] isis git commit: ISIS-970: consolidating processing into DomainObjectAnnotationFacetFactory, ActionAnnotationFF, PropertyAnnotationFF, CollectionAnnotationFF

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/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
new file mode 100644
index 0000000..2a1bccc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetAbstract.java
@@ -0,0 +1,127 @@
+/*
+ *  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.invocation;
+
+import org.apache.isis.applib.events.UsabilityEvent;
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.applib.events.VisibilityEvent;
+import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.InteractionHelper;
+import org.apache.isis.core.metamodel.facets.SingleClassValueFacetAbstract;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionDomainEventFacet;
+import org.apache.isis.core.metamodel.interactions.ActionInvocationContext;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+import org.apache.isis.core.metamodel.interactions.VisibilityContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public abstract class ActionDomainEventFacetAbstract
+        extends SingleClassValueFacetAbstract implements ActionDomainEventFacet {
+
+    private final InteractionHelper interactionHelper;
+
+    /**
+     * Pass event from validate to executing phases.
+     *
+     * <p>
+     * A new event is created for the hide, disable and validate phases.  But when the validate completes (and if does
+     * not invalidate), then the event is passed through to the executing phase using this thread-local.
+     * </p>
+     */
+    final static ThreadLocal<ActionDomainEvent<?>> currentInteraction = new ThreadLocal<>();
+
+    public ActionDomainEventFacetAbstract(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final FacetHolder holder,
+            final ServicesInjector servicesInjector,
+            final SpecificationLoader specificationLoader) {
+        super(CollectionDomainEventFacet.class, holder, eventType, specificationLoader);
+        interactionHelper = new InteractionHelper(servicesInjector);
+    }
+
+    @Override
+    public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
+        if(!interactionHelper.hasEventBusService()) {
+            return null;
+        }
+
+        // reset (belt-n-braces)
+        currentInteraction.set(null);
+
+        final ActionDomainEvent<?> event =
+                interactionHelper.postEventForAction(
+                        eventType(), null, null, AbstractDomainEvent.Phase.HIDE,
+                        getIdentified(), ic.getTarget(), null);
+        if (event != null && event.isHidden()) {
+            return "Hidden by subscriber";
+        }
+        return null;
+    }
+
+    @Override
+    public String disables(UsabilityContext<? extends UsabilityEvent> ic) {
+        if(!interactionHelper.hasEventBusService()) {
+            return null;
+        }
+
+        // reset (belt-n-braces)
+        currentInteraction.set(null);
+
+        final ActionDomainEvent<?> event =
+                interactionHelper.postEventForAction(
+                        eventType(), null, null, AbstractDomainEvent.Phase.DISABLE,
+                        getIdentified(), ic.getTarget(), null);
+        if (event != null && event.isDisabled()) {
+            return event.getDisabledReason();
+        }
+        return null;
+    }
+
+    @Override
+    public String invalidates(ValidityContext<? extends ValidityEvent> ic) {
+        if(!interactionHelper.hasEventBusService()) {
+            return null;
+        }
+
+        // reset (belt-n-braces)
+        currentInteraction.set(null);
+
+        final ActionInvocationContext aic = (ActionInvocationContext) ic;
+        final ActionDomainEvent<?> event =
+                interactionHelper.postEventForAction(
+                        eventType(), null, null, AbstractDomainEvent.Phase.VALIDATE,
+                        getIdentified(), ic.getTarget(), aic.getArgs());
+        if (event != null && event.isInvalid()) {
+            return event.getInvalidityReason();
+        }
+
+        // make available for next phases (executing/executed)
+        currentInteraction.set(event);
+        return null;
+    }
+
+    private Class<?> eventType() {
+        return value();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetDefault.java
new file mode 100644
index 0000000..f92ce63
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetDefault.java
@@ -0,0 +1,35 @@
+/*
+ *  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.invocation;
+
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class ActionDomainEventFacetDefault extends ActionDomainEventFacetAbstract {
+
+    public ActionDomainEventFacetDefault(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
+        super(eventType, holder, servicesInjector, specificationLoader);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionAnnotation.java
new file mode 100644
index 0000000..70fc01f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionAnnotation.java
@@ -0,0 +1,35 @@
+/*
+ *  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.invocation;
+
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class ActionDomainEventFacetForActionAnnotation extends ActionDomainEventFacetAbstract {
+
+    public ActionDomainEventFacetForActionAnnotation(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
+        super(eventType, holder, servicesInjector, specificationLoader);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionInteractionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionInteractionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionInteractionAnnotation.java
new file mode 100644
index 0000000..9f4868a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionDomainEventFacetForActionInteractionAnnotation.java
@@ -0,0 +1,37 @@
+/*
+ *  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.invocation;
+
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+@Deprecated
+public class ActionDomainEventFacetForActionInteractionAnnotation extends ActionDomainEventFacetAbstract {
+
+    @Deprecated
+    public ActionDomainEventFacetForActionInteractionAnnotation(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
+        super(eventType, holder, servicesInjector, specificationLoader);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/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
new file mode 100644
index 0000000..c7887cc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacet.java
@@ -0,0 +1,123 @@
+/*
+ *  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.invocation;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+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;
+
+/**
+ * Represents the mechanism by which the action should be invoked.
+ * 
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to invoking the
+ * actual action method itself (a <tt>public</tt> method that does not represent
+ * a property, a collection or any of the supporting methods).
+ */
+public interface ActionInvocationFacet extends Facet {
+
+    @Deprecated
+    public ObjectAdapter invoke(ObjectAdapter targetAdapter, ObjectAdapter[] argumentAdapters);
+
+    public ObjectAdapter invoke(ObjectAction owningAction, ObjectAdapter targetAdapter, ObjectAdapter[] argumentAdapters);
+
+    public ObjectSpecification getReturnType();
+
+    public ObjectSpecification getOnType();
+
+    public static class CurrentInvocation {
+
+        private final Command command;
+        
+        private final ObjectAdapter target;
+        private final IdentifiedHolder action;
+        private final List<ObjectAdapter> parameters;
+        private final ObjectAdapter result;
+
+        public CurrentInvocation(
+                final ObjectAdapter target,
+                final IdentifiedHolder action,
+                final ObjectAdapter[] parameters,
+                final ObjectAdapter result, 
+                final Command command) {
+            this(target, action, Arrays.asList(parameters), result, command);
+        }
+
+        public CurrentInvocation(
+                final ObjectAdapter target,
+                final IdentifiedHolder action,
+                final List<ObjectAdapter> parameters,
+                final ObjectAdapter result, 
+                final Command command) {
+            this.target = target;
+            this.action = action;
+            this.parameters = parameters;
+            this.result = result;
+            this.command = command;
+        }
+
+        /**
+         * deprecated since part of {@link #getCommand()}
+         */
+        @Deprecated
+        public ObjectAdapter getTarget() {
+            return target;
+        }
+        /**
+         * deprecated since part of {@link #getCommand()}
+         */
+        @Deprecated
+        public IdentifiedHolder getAction() {
+            return action;
+        }
+
+        public List<ObjectAdapter> getParameters() {
+            return parameters;
+        }
+        
+        /**
+         * deprecated since part of {@link #getCommand()}
+         */
+        @Deprecated
+        public ObjectAdapter getResult() {
+            return result;
+        }
+        
+        public Command getCommand() {
+            return command;
+        }
+    }
+    
+    /**
+     * TODO...
+     * @deprecated - should instead use the {@link CommandContext} request.
+     */
+    @Deprecated
+    public static ThreadLocal<CurrentInvocation> currentInvocation = new ThreadLocal<CurrentInvocation>();
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetAbstract.java
new file mode 100644
index 0000000..4845629
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetAbstract.java
@@ -0,0 +1,38 @@
+/*
+ *  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.invocation;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public abstract class ActionInvocationFacetAbstract
+        extends FacetAbstract
+        implements ActionInvocationFacet {
+
+    public static Class<? extends Facet> type() {
+        return ActionInvocationFacet.class;
+    }
+
+    public ActionInvocationFacetAbstract(final FacetHolder holder) {
+        super(type(), holder, Derivation.NOT_DERIVED);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/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
new file mode 100644
index 0000000..eabcf7b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -0,0 +1,435 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.isis.applib.NonRecoverableException;
+import org.apache.isis.applib.RecoverableException;
+import org.apache.isis.applib.ViewModel;
+import org.apache.isis.applib.annotation.Bulk;
+import org.apache.isis.applib.annotation.InvokedOn;
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
+import org.apache.isis.applib.services.background.ActionInvocationMemento;
+import org.apache.isis.applib.services.background.BackgroundService;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.command.spi.CommandService;
+import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.lang.ThrowableExtensions;
+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.actcoll.typeof.ElementSpecificationProviderFromTypeOfFacet;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
+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.object.viewmodel.ViewModelFacet;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.specloader.ReflectiveActionException;
+
+public abstract class ActionInvocationFacetForDomainEventAbstract
+        extends ActionInvocationFacetAbstract
+        implements ImperativeFacet {
+
+    private final static Logger LOG = LoggerFactory.getLogger(ActionInvocationFacetForDomainEventAbstract.class);
+
+    private final Method method;
+    private final ObjectSpecification onType;
+    private final ObjectSpecification returnType;
+
+    private final AdapterManager adapterManager;
+    private final ActionDomainEventFacetAbstract actionInteractionFacet;
+    private final RuntimeContext runtimeContext;
+
+    private final ServicesInjector servicesInjector;
+    final Class<? extends ActionDomainEvent<?>> eventType;
+    private final InteractionHelper interactionHelper;
+
+    public ActionInvocationFacetForDomainEventAbstract(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final Method method,
+            final ObjectSpecification onType,
+            final ObjectSpecification returnType,
+            final ActionDomainEventFacetAbstract actionInteractionFacet,
+            final FacetHolder holder,
+            final RuntimeContext runtimeContext,
+            final AdapterManager adapterManager,
+            final ServicesInjector servicesInjector) {
+        super(holder);
+        this.eventType = eventType;
+        this.method = method;
+        this.onType = onType;
+        this.returnType = returnType;
+        this.actionInteractionFacet = actionInteractionFacet;
+        this.runtimeContext = runtimeContext;
+        this.adapterManager = adapterManager;
+        this.servicesInjector = servicesInjector;
+        this.interactionHelper = new InteractionHelper(servicesInjector);
+    }
+
+    /**
+     * Returns a singleton list of the {@link java.lang.reflect.Method} provided in the
+     * constructor.
+     */
+    @Override
+    public List<Method> getMethods() {
+        return Collections.singletonList(method);
+    }
+
+    @Override
+    public Intent getIntent(final Method method) {
+        return Intent.EXECUTE;
+    }
+
+    @Override
+    public ObjectSpecification getReturnType() {
+        return returnType;
+    }
+
+    @Override
+    public ObjectSpecification getOnType() {
+        return onType;
+    }
+
+    /**
+     * Introduced to disambiguate the meaning of <tt>null</tt> as a return value of
+     * {@link #invoke(org.apache.isis.core.metamodel.adapter.ObjectAdapter, org.apache.isis.core.metamodel.adapter.ObjectAdapter[])}
+     */
+    public static class InvocationResult {
+
+        public static InvocationResult forActionThatReturned(final ObjectAdapter resultAdapter) {
+            return new InvocationResult(true, resultAdapter);
+        }
+
+        public static InvocationResult forActionNotInvoked() {
+            return new InvocationResult(false, null);
+        }
+
+        private final boolean whetherInvoked;
+        private final ObjectAdapter adapter;
+
+        private InvocationResult(final boolean whetherInvoked, final ObjectAdapter result) {
+            this.whetherInvoked = whetherInvoked;
+            this.adapter = result;
+        }
+
+        public boolean getWhetherInvoked() {
+            return whetherInvoked;
+        }
+
+        /**
+         * Returns the result, or null if either the action invocation returned null or
+         * if the action was never invoked in the first place.
+         *
+         * <p>
+         * Use {@link #getWhetherInvoked()} to distinguish between these two cases.
+         */
+        public ObjectAdapter getAdapter() {
+            return adapter;
+        }
+    }
+
+    @Override
+    public ObjectAdapter invoke(final ObjectAdapter targetAdapter, final ObjectAdapter[] argumentAdapters) {
+        return invoke(null, targetAdapter, argumentAdapters);
+    }
+
+    @Override
+    public ObjectAdapter invoke(
+            final ObjectAction owningAction,
+            final ObjectAdapter targetAdapter,
+            final ObjectAdapter[] arguments) {
+
+        try {
+
+            final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
+            final Command command = commandContext != null ? commandContext.getCommand() : null;
+
+            // pick up existing event (saved in thread local during the validation phase)
+            final ActionDomainEvent<?> existingEvent = actionInteractionFacet.currentInteraction.get();
+
+            // ... post the executing event
+            final ActionDomainEvent<?> event =
+                    interactionHelper.postEventForAction(
+                            eventType, existingEvent, command, AbstractDomainEvent.Phase.EXECUTING,
+                            owningAction, targetAdapter, arguments);
+
+            // ... invoke the action
+            final InvocationResult invocationResult = internalInvoke(command, owningAction, targetAdapter, arguments);
+
+            // ... post the executed event
+            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(
+                        eventType, verify(event), command, AbstractDomainEvent.Phase.EXECUTED,
+                        owningAction, targetAdapter, arguments);
+            }
+
+            return invocationResult.getAdapter();
+
+        } finally {
+
+            // clean up event on thread
+
+            // note that if the action invoked some other action via a wrapper then this will already have been cleared
+            // out.  That isn't a problem; we only need to pass the event from validate to pre-execute, not to formally
+            // "nest" the events.
+            actionInteractionFacet.currentInteraction.set(null);
+        }
+    }
+
+    /**
+     * Optional hook to allow the facet implementation for the deprecated {@link org.apache.isis.applib.annotation.PostsActionInvokedEvent} annotation
+     * to discard the event if of a different type.
+     */
+    protected ActionDomainEvent<?> verify(ActionDomainEvent<?> event) {
+        return event;
+    }
+
+    protected InvocationResult internalInvoke(
+            final Command command,
+            final ObjectAction owningAction,
+            final ObjectAdapter targetAdapter,
+            final ObjectAdapter[] arguments) {
+
+
+        try {
+            final Object[] executionParameters = new Object[arguments.length];
+            for (int i = 0; i < arguments.length; i++) {
+                executionParameters[i] = unwrap(arguments[i]);
+            }
+
+            final Object targetPojo = unwrap(targetAdapter);
+
+            final BulkFacet bulkFacet = getFacetHolder().getFacet(BulkFacet.class);
+            if (bulkFacet != null) {
+                final ActionInvocationContext actionInvocationContext = getServicesInjector().lookupService(ActionInvocationContext.class);
+                if (actionInvocationContext != null &&
+                    actionInvocationContext.getInvokedOn() == null) {
+
+                    actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
+                    actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
+                }
+
+                final Bulk.InteractionContext bulkInteractionContext = getServicesInjector().lookupService(Bulk.InteractionContext.class);
+
+                if (bulkInteractionContext != null &&
+                        bulkInteractionContext.getInvokedAs() == null) {
+
+                    bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
+                    actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
+                }
+
+
+            }
+
+            if(command != null && command.getExecutor() == Command.Executor.USER && owningAction != null) {
+
+                if(command.getTarget() != null) {
+                    // already set up by a ObjectActionContributee;
+                    // don't overwrite
+                } else {
+                    command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
+                    command.setTargetAction(CommandUtil.targetActionNameFor(owningAction));
+                    command.setArguments(CommandUtil.argDescriptionFor(owningAction, arguments));
+
+                    final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
+                    command.setTarget(targetBookmark);
+                }
+
+                command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));
+
+                // the background service is used here merely as a means to capture an invocation memento
+                final BackgroundService backgroundService = getServicesInjector().lookupService(BackgroundService.class);
+                if(backgroundService != null) {
+                    final Object targetObject = unwrap(targetAdapter);
+                    final Object[] args = CommandUtil.objectsFor(arguments);
+                    ActionInvocationMemento aim = backgroundService.asActionInvocationMemento(method, targetObject, args);
+
+                    if(aim != null) {
+                        command.setMemento(aim.asMementoString());
+                    } else {
+                        throw new IsisException(
+                                "Unable to build memento for action " +
+                                        owningAction.getIdentifier().toClassAndNameIdentityString());
+                    }
+                }
+
+                // copy over the command execution 'context' (if available)
+                final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
+                if(commandFacet != null && !commandFacet.isDisabled()) {
+                    command.setExecuteIn(commandFacet.executeIn());
+                    command.setPersistence(commandFacet.persistence());
+                } else {
+                    // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
+                    command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
+                    command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
+                }
+            }
+
+
+            if( command != null &&
+                    command.getExecutor() == Command.Executor.USER &&
+                    command.getExecuteIn() == org.apache.isis.applib.annotation.Command.ExecuteIn.BACKGROUND) {
+
+                // persist command so can be this command can be in the 'background'
+                final CommandService commandService = getServicesInjector().lookupService(CommandService.class);
+                if(commandService.persistIfPossible(command)) {
+                    // force persistence, then return the command itself.
+                    final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(command);
+                    return InvocationResult.forActionThatReturned(resultAdapter);
+                } else {
+                    throw new IsisException(
+                            "Unable to schedule action '"
+                                    + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
+                                    + "CommandService does not support persistent commands " );
+                }
+            } else {
+
+                // otherwise, go ahead and execute action in the 'foreground'
+
+                if(command != null) {
+                    command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
+                }
+
+                Object result = method.invoke(targetPojo, executionParameters);
+
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug(" action result " + result);
+                }
+                if (result == null) {
+                    if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
+                        // if this was a void method on a ViewModel.Cloneable, then (to save boilerplate in the domain)
+                        // automatically do the clone and return the clone instead.
+                        final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) targetAdapter.getObject();
+                        final Object clone = cloneable.clone();
+                        final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
+                        return InvocationResult.forActionThatReturned(clonedAdapter);
+                    }
+                    return InvocationResult.forActionThatReturned(null);
+                }
+
+                ObjectAdapter resultAdapter = getAdapterManager().adapterFor(result);
+
+                if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
+                    // if the object returned is a ViewModel.Cloneable, then
+                    // (to save boilerplate in the domain) automatically do the clone.
+                    final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) result;
+                    result = cloneable.clone();
+                    resultAdapter = getAdapterManager().adapterFor(result);
+                }
+
+
+                // copy over TypeOfFacet if required
+                final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
+                resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
+
+                if(command != null) {
+                    if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
+                        final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
+                        command.setResult(bookmark);
+                    }
+                }
+
+                final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
+                currentInvocation.set(
+                        publishedActionFacet != null
+                                ? new CurrentInvocation(targetAdapter, getIdentified(), arguments, resultAdapter, command)
+                                : null);
+
+                return InvocationResult.forActionThatReturned(resultAdapter);
+            }
+
+        } catch (final IllegalArgumentException e) {
+            throw e;
+        } catch (final InvocationTargetException e) {
+            final Throwable targetException = e.getTargetException();
+            if (targetException instanceof IllegalStateException) {
+                throw new ReflectiveActionException("IllegalStateException thrown while executing " + method + " " + targetException.getMessage(), targetException);
+            }
+            if(targetException instanceof RecoverableException) {
+                if (!runtimeContext.getTransactionState().canCommit()) {
+                    // something severe has happened to the underlying transaction;
+                    // so escalate this exception to be non-recoverable
+                    final Throwable targetExceptionCause = targetException.getCause();
+                    Throwable nonRecoverableCause = targetExceptionCause != null? targetExceptionCause: targetException;
+                    throw new NonRecoverableException(nonRecoverableCause);
+                }
+            }
+
+            ThrowableExtensions.throwWithinIsisException(e, "Exception executing " + method);
+
+            // Action was not invoked (an Exception was thrown)
+            return InvocationResult.forActionNotInvoked();
+        } catch (final IllegalAccessException e) {
+            throw new ReflectiveActionException("Illegal access of " + method, e);
+        }
+    }
+
+
+
+    private static Object unwrap(final ObjectAdapter adapter) {
+        return adapter == null ? null : adapter.getObject();
+    }
+
+    @Override
+    public boolean impliesResolve() {
+        return true;
+    }
+
+    @Override
+    public boolean impliesObjectChanged() {
+        return false;
+    }
+
+    @Override
+    protected String toStringValues() {
+        return "method=" + method;
+    }
+
+
+    // /////////////////////////////////////////////////////////
+    // Dependencies (from constructor)
+    // /////////////////////////////////////////////////////////
+
+    private AdapterManager getAdapterManager() {
+        return adapterManager;
+    }
+
+    private ServicesInjector getServicesInjector() {
+        return servicesInjector;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionAnnotation.java
new file mode 100644
index 0000000..954c6d0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionAnnotation.java
@@ -0,0 +1,44 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ActionInvocationFacetForDomainEventFromActionAnnotation
+        extends ActionInvocationFacetForDomainEventAbstract {
+
+    public ActionInvocationFacetForDomainEventFromActionAnnotation(
+            final Class<? extends ActionDomainEvent<?>> eventType, final Method method,
+            final ObjectSpecification onType,
+            final ObjectSpecification returnType,
+            final ActionDomainEventFacetAbstract actionInteractionFacet,
+            final FacetHolder holder,
+            final RuntimeContext runtimeContext,
+            final AdapterManager adapterManager,
+            final ServicesInjector servicesInjector) {
+        super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionInteractionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionInteractionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionInteractionAnnotation.java
new file mode 100644
index 0000000..703e306
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromActionInteractionAnnotation.java
@@ -0,0 +1,44 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ActionInvocationFacetForDomainEventFromActionInteractionAnnotation
+        extends ActionInvocationFacetForDomainEventAbstract {
+
+    public ActionInvocationFacetForDomainEventFromActionInteractionAnnotation(
+            final Class<? extends ActionDomainEvent<?>> eventType, final Method method,
+            final ObjectSpecification onType,
+            final ObjectSpecification returnType,
+            final ActionDomainEventFacetAbstract actionInteractionFacet,
+            final FacetHolder holder,
+            final RuntimeContext runtimeContext,
+            final AdapterManager adapterManager,
+            final ServicesInjector servicesInjector) {
+        super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromDefault.java
new file mode 100644
index 0000000..207eafd
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventFromDefault.java
@@ -0,0 +1,44 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ActionInvocationFacetForDomainEventFromDefault
+        extends ActionInvocationFacetForDomainEventAbstract {
+
+    public ActionInvocationFacetForDomainEventFromDefault(
+            final Class<? extends ActionDomainEvent<?>> eventType, final Method method,
+            final ObjectSpecification onType,
+            final ObjectSpecification returnType,
+            final ActionDomainEventFacetAbstract actionInteractionFacet,
+            final FacetHolder holder,
+            final RuntimeContext runtimeContext,
+            final AdapterManager adapterManager,
+            final ServicesInjector servicesInjector) {
+        super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
new file mode 100644
index 0000000..898b1b7
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
@@ -0,0 +1,52 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.Method;
+import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ActionInvocationFacetForPostsActionInvokedEventAnnotation
+        extends ActionInvocationFacetForDomainEventAbstract {
+
+    public ActionInvocationFacetForPostsActionInvokedEventAnnotation(
+            final Class<? extends ActionDomainEvent<?>> eventType,
+            final Method method,
+            final ObjectSpecification onType,
+            final ObjectSpecification returnType,
+            final ActionDomainEventFacetAbstract actionInteractionFacet,
+            final FacetHolder holder,
+            final RuntimeContext runtimeContext,
+            final AdapterManager adapterManager,
+            final ServicesInjector servicesInjector) {
+        super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
+    }
+
+    @Override
+    protected ActionDomainEvent<?> verify(final ActionDomainEvent<?> event) {
+        // will discard event if different type to that specified in the PostsActionInvokedEvent annotation.
+        return event != null && eventType == event.getClass() ? event : null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/CommandUtil.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/CommandUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/CommandUtil.java
new file mode 100644
index 0000000..967f3c3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/CommandUtil.java
@@ -0,0 +1,120 @@
+/*
+ *  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.invocation;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.memento.MementoService;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+
+
+/**
+ * Factoring out the commonality between <tt>ActionInvocationFacetViaMethod</tt> and <tt>BackgroundServiceDefault</tt>.
+ */
+public class CommandUtil {
+
+    private CommandUtil(){}
+
+    public static String targetActionNameFor(ObjectAction owningAction) {
+        return owningAction.getName();
+    }
+
+    public static String targetClassNameFor(ObjectAdapter targetAdapter) {
+        return StringExtensions.asNaturalName2(targetAdapter.getSpecification().getSingularName());
+    }
+
+    public static String actionIdentifierFor(ObjectAction owningAction) {
+        return owningAction.getIdentifier().toClassAndNameIdentityString();
+    }
+
+    public static String argDescriptionFor(ObjectAction owningAction, ObjectAdapter[] arguments) {
+        final StringBuilder argsBuf = new StringBuilder();
+        List<ObjectActionParameter> parameters = owningAction.getParameters();
+        if(parameters.size() == arguments.length) {
+            // should be the case
+            int i=0;
+            for (ObjectActionParameter param : parameters) {
+                CommandUtil.appendParamArg(argsBuf, param, arguments[i++]);
+            }
+        }
+        String argsStr = argsBuf.toString();
+        return argsStr;
+    }
+
+    public static Bookmark bookmarkFor(final ObjectAdapter adapter) {
+        final Oid oid = adapter.getOid();
+        if(!(oid instanceof RootOid)) {
+            return null;
+        } 
+        final RootOid rootOid = (RootOid) oid;
+        return rootOid.asBookmark();
+    }
+
+    static void appendParamArg(final StringBuilder buf, ObjectActionParameter param, ObjectAdapter objectAdapter) {
+        String titleOf = objectAdapter != null? objectAdapter.titleString(null): "null";
+        buf.append(param.getName()).append(": ").append(titleOf).append("\n");
+    }
+
+    public static void buildMementoArgLists(MementoService mementoService, BookmarkService bookmarkService, final Method method, final Object[] args, final List<Class<?>> argTypes, final List<Object> argObjs) {
+        for (int i = 0; i < args.length; i++) {
+            Object input = args[i];
+            if (mementoService.canSet(input)) {
+                argTypes.add(method.getParameterTypes()[i]);
+                argObjs.add(input);
+            } else {
+                Bookmark argBookmark = bookmarkService.bookmarkFor(input);
+                argTypes.add(Bookmark.class);
+                argObjs.add(argBookmark);
+            }
+        }
+    }
+    
+    
+    public static ObjectAdapter[] adaptersFor(final Object[] args, final AdapterManager adapterManager) {
+        List<Object> argList = Arrays.asList(args);
+        Iterable<ObjectAdapter> adapterList = 
+                Iterables.transform(
+                        argList, ObjectAdapter.Functions.adapterForUsing(adapterManager));
+        return Lists.newArrayList(adapterList).toArray(new ObjectAdapter[]{});
+    }
+
+    public static Object[] objectsFor(ObjectAdapter[] arguments) {
+        List<ObjectAdapter> argList = Arrays.asList(arguments);
+        Iterable<Object> adapterList = 
+                Iterables.transform(
+                        argList, ObjectAdapter.Functions.getObject());
+        return Lists.newArrayList(adapterList).toArray(new Object[]{});
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/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
new file mode 100644
index 0000000..69dc883
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/prototype/PrototypeFacetForActionAnnotation.java
@@ -0,0 +1,48 @@
+/*
+ *  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.prototype;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.Environment;
+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;
+
+public class PrototypeFacetForActionAnnotation extends PrototypeFacetAbstract {
+
+    public static PrototypeFacet create(
+            final Action action,
+            final FacetHolder holder) {
+
+        if(action == null) {
+            return null;
+        }
+
+        final Environment[] environments = action.restrictTo();
+        boolean developmentOnly = Environment.hasDevelopmentOnly(environments);
+
+        return developmentOnly ? new PrototypeFacetForActionAnnotation(holder) : null;
+    }
+
+    private PrototypeFacetForActionAnnotation(FacetHolder holder) {
+        super(holder);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishActionsConfiguration.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishActionsConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishActionsConfiguration.java
new file mode 100644
index 0000000..cf46223
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishActionsConfiguration.java
@@ -0,0 +1,43 @@
+/*
+ *  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.publishing;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facets.object.domainobject.Util;
+
+public enum PublishActionsConfiguration {
+    ALL,
+    IGNORE_SAFE,
+    NONE;
+
+    private static final String PUBLISH_ACTIONS_KEY = "isis.services.publish.actions";
+
+    public static PublishActionsConfiguration parse(IsisConfiguration configuration) {
+        final String configuredValue = configuration.getString(PUBLISH_ACTIONS_KEY);
+        return PublishActionsConfiguration.parse(configuredValue);
+    }
+
+    private static PublishActionsConfiguration parse(final String value) {
+        if ("ignoreQueryOnly".equalsIgnoreCase(value) || "ignoreSafe".equalsIgnoreCase(value)) {
+            return IGNORE_SAFE;
+        }
+        return Util.parseYes(value)? ALL: NONE;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishedActionFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishedActionFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishedActionFacetForActionAnnotation.java
new file mode 100644
index 0000000..1486c46
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/publishing/PublishedActionFacetForActionAnnotation.java
@@ -0,0 +1,128 @@
+/*
+ *  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.publishing;
+
+import java.util.List;
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.PublishedAction;
+import org.apache.isis.applib.annotation.Publishing;
+import org.apache.isis.applib.annotation.PublishingPayloadFactoryForAction;
+import org.apache.isis.applib.services.publish.EventPayload;
+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.publish.PublishedActionFacet;
+import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacetAbstract;
+import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
+
+public class PublishedActionFacetForActionAnnotation extends PublishedActionFacetAbstract {
+
+    public static PublishedActionFacet create(
+            final Action action,
+            final IsisConfiguration configuration,
+            final FacetHolder holder) {
+
+        if (action == null) {
+            return null;
+        }
+
+        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 Publishing publishing = action.publishing();
+
+        switch (publishing) {
+            case AS_CONFIGURED:
+
+                final PublishActionsConfiguration setting = PublishActionsConfiguration.parse(configuration);
+                switch (setting) {
+                    case NONE:
+                        return null;
+                    case IGNORE_SAFE:
+                        if(actionSemanticsFacet.value() == ActionSemantics.Of.SAFE) {
+                            return  null;
+                        }
+                        // else fall through
+                    default:
+                        return new PublishedActionFacetForActionAnnotation(
+                                newPayloadFactory(action), holder);
+                }
+            case DISABLED:
+                return null;
+            case ENABLED:
+                return new PublishedActionFacetForActionAnnotation(
+                        newPayloadFactory(action), holder);
+        }
+        return null;
+    }
+
+    private static PublishingPayloadFactoryForAction newPayloadFactory(final Action action) {
+        final Class<? extends PublishingPayloadFactoryForAction> payloadFactoryClass = action.publishingPayloadFactory();
+        if(payloadFactoryClass == null) {
+            return null;
+        }
+
+        try {
+            return payloadFactoryClass.newInstance();
+        } catch (final InstantiationException e) {
+            return null;
+        } catch (final IllegalAccessException e) {
+            return null;
+        }
+    }
+
+    public PublishedActionFacetForActionAnnotation(
+            final PublishingPayloadFactoryForAction publishingPayloadFactory,
+            final FacetHolder holder) {
+        super(legacyPayloadFactoryFor(publishingPayloadFactory), holder);
+    }
+
+    private static PublishedAction.PayloadFactory legacyPayloadFactoryFor(PublishingPayloadFactoryForAction publishingPayloadFactory) {
+        if(publishingPayloadFactory instanceof PublishingPayloadFactoryForAction.Adapter) {
+            final PublishingPayloadFactoryForAction.Adapter adapter = (PublishingPayloadFactoryForAction.Adapter) publishingPayloadFactory;
+            return adapter.getPayloadFactory();
+        }
+        return new LegacyAdapter(publishingPayloadFactory);
+    }
+
+    private static class LegacyAdapter implements PublishedAction.PayloadFactory {
+
+        private final PublishingPayloadFactoryForAction payloadFactory;
+
+        LegacyAdapter(final PublishingPayloadFactoryForAction payloadFactory) {
+            this.payloadFactory = payloadFactory;
+        }
+
+        @Override
+        public EventPayload payloadFor(final Identifier actionIdentifier, final Object target, final List<Object> arguments, final Object result) {
+            return payloadFactory.payloadFor(actionIdentifier, target, arguments, result);
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/semantics/ActionSemanticsFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/semantics/ActionSemanticsFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/semantics/ActionSemanticsFacetForActionAnnotation.java
new file mode 100644
index 0000000..41961d3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/semantics/ActionSemanticsFacetForActionAnnotation.java
@@ -0,0 +1,54 @@
+/*
+ *  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.semantics;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionSemantics.Of;
+import org.apache.isis.applib.annotation.SemanticsOf;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
+import org.apache.isis.core.metamodel.facets.actions.semantics.ActionSemanticsFacetAbstract;
+
+public class ActionSemanticsFacetForActionAnnotation extends ActionSemanticsFacetAbstract {
+
+    public static ActionSemanticsFacet create(
+            final Action action,
+            final FacetHolder holder) {
+
+        if(action == null) {
+            return null;
+        }
+
+        final SemanticsOf semantics = action.semantics();
+        if(action.semantics() == null) {
+            // don't think this can happen, therefore will return a facet with the default, ie NON_IDEMPOTENT
+            return null;
+        }
+
+        return new ActionSemanticsFacetForActionAnnotation(
+                SemanticsOf.from(semantics), holder);
+    }
+
+    private ActionSemanticsFacetForActionAnnotation(Of of, final FacetHolder holder) {
+        super(of, holder);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetForActionAnnotation.java
new file mode 100644
index 0000000..eb88fae
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetForActionAnnotation.java
@@ -0,0 +1,35 @@
+/*
+ *  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.typeof;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetAbstract;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class TypeOfFacetForActionAnnotation extends TypeOfFacetAbstract {
+
+    public TypeOfFacetForActionAnnotation(
+            final Class<?> type,
+            final SpecificationLoader specificationLookup,
+            final FacetHolder holder) {
+        super(type, holder, specificationLookup);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetOnActionForTypeOfAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetOnActionForTypeOfAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetOnActionForTypeOfAnnotation.java
new file mode 100644
index 0000000..d33c758
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/typeof/TypeOfFacetOnActionForTypeOfAnnotation.java
@@ -0,0 +1,50 @@
+/*
+ *  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.typeof;
+
+import org.apache.isis.applib.annotation.TypeOf;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetAbstract;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+/**
+ * @deprecated
+ */
+@Deprecated
+public class TypeOfFacetOnActionForTypeOfAnnotation extends TypeOfFacetAbstract {
+
+    public static TypeOfFacet create(
+            final TypeOf annotation, final SpecificationLoader specificationLoader, final FacetedMethod holder) {
+        if(annotation == null) {
+            return null;
+        }
+        return new TypeOfFacetOnActionForTypeOfAnnotation(annotation.value(), specificationLoader, holder);
+    }
+
+    private TypeOfFacetOnActionForTypeOfAnnotation(
+            final Class<?> type,
+            final SpecificationLoader specificationLookup,
+            final FacetHolder holder) {
+        super(type, holder, specificationLookup);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotation.java
deleted file mode 100644
index 186236d..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotation.java
+++ /dev/null
@@ -1,46 +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.actions.command.annotation;
-
-import org.apache.isis.applib.annotation.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 CommandFacetAnnotation extends CommandFacetAbstract {
-
-    public static CommandFacet create(final Command annotation, final FacetHolder holder) {
-        return annotation == null
-                ? null
-                : new CommandFacetAnnotation(annotation.persistence(), annotation.executeIn(), Enablement.isDisabled(annotation.disabled()), holder);
-    }
-
-    private CommandFacetAnnotation(
-            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/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotationFactory.java
deleted file mode 100644
index 0cdb31b..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/annotation/CommandFacetAnnotationFactory.java
+++ /dev/null
@@ -1,39 +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.actions.command.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-
-public class CommandFacetAnnotationFactory extends FacetFactoryAbstract {
-
-    public CommandFacetAnnotationFactory() {
-        super(FeatureType.ACTIONS_ONLY);
-    }
-
-    @Override
-    public void process(final ProcessMethodContext processMethodContext) {
-
-        //
-        // moved to ActionAnnotationFacetFactory
-        //
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/configuration/CommandFacetFromConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/configuration/CommandFacetFromConfigurationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/configuration/CommandFacetFromConfigurationFactory.java
deleted file mode 100644
index b7a87de..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/command/configuration/CommandFacetFromConfigurationFactory.java
+++ /dev/null
@@ -1,41 +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.actions.command.configuration;
-
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-
-public class CommandFacetFromConfigurationFactory extends FacetFactoryAbstract {
-
-    public CommandFacetFromConfigurationFactory() {
-        super(FeatureType.ACTIONS_ONLY);
-    }
-
-    @Override
-    public void process(final ProcessMethodContext processMethodContext) {
-
-        //
-        // moved to ActionAnnotationFacetFactory
-        //
-
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/defaults/method/ActionDefaultsFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/defaults/method/ActionDefaultsFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/defaults/method/ActionDefaultsFacetViaMethod.java
index 4bda300..8bb7f51 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/defaults/method/ActionDefaultsFacetViaMethod.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/defaults/method/ActionDefaultsFacetViaMethod.java
@@ -27,8 +27,8 @@ import org.apache.isis.core.metamodel.facetapi.Facet;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facets.ImperativeFacet;
 import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacetAbstract;
-import org.apache.isis.core.metamodel.facets.actions.interaction.ActionInvocationFacetForInteractionAbstract;
-import org.apache.isis.core.metamodel.facets.actions.interaction.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
 
 public class ActionDefaultsFacetViaMethod extends ActionDefaultsFacetAbstract implements ImperativeFacet {
 
@@ -46,8 +46,8 @@ public class ActionDefaultsFacetViaMethod extends ActionDefaultsFacetAbstract im
     private static Method determineActionMethod(final FacetHolder holder) {
         Method method2;
         final Facet actionInvocationFacet = holder.getFacet(ActionInvocationFacet.class);
-        if (actionInvocationFacet instanceof ActionInvocationFacetForInteractionAbstract) {
-            final ActionInvocationFacetForInteractionAbstract facetViaMethod = (ActionInvocationFacetForInteractionAbstract) actionInvocationFacet;
+        if (actionInvocationFacet instanceof ActionInvocationFacetForDomainEventAbstract) {
+            final ActionInvocationFacetForDomainEventAbstract facetViaMethod = (ActionInvocationFacetForDomainEventAbstract) actionInvocationFacet;
             method2 = facetViaMethod.getMethods().get(0);
         } else {
             method2 = null;