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/30 08:14:33 UTC

[4/5] isis git commit: ISIS-968: @ActionLayout(contributed=...) support.

ISIS-968: @ActionLayout(contributed=...) support.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f3294b65
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f3294b65
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f3294b65

Branch: refs/heads/master
Commit: f3294b65d843742f7fa529bc05128f098582872e
Parents: b72dd11
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Jan 29 15:30:20 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Jan 29 19:00:14 2015 +0000

----------------------------------------------------------------------
 .../isis/applib/annotation/ActionLayout.java    |  13 +
 .../isis/applib/annotation/Contributed.java     |  46 +++
 .../isis/applib/annotation/NotContributed.java  |  48 ++-
 .../layout/ActionLayoutFacetFactory.java        |  31 ++
 .../NamedFacetForActionLayoutAnnotation.java    |   2 +-
 ...ntributedFacetForActionLayoutAnnotation.java |  49 +++
 .../NotContributedFacetForLayoutProperties.java |  60 +++
 .../layoutmetadata/ActionLayoutFacetRepr.java   |   2 +
 ...nLayoutAnnotationFacetFactoryJunit4Test.java | 380 +++++++++++++++++++
 .../ActionLayoutAnnotationFacetFactoryTest.java | 139 ++++---
 ...erivedFromDomainServiceFacetFactoryTest.java |  52 +--
 ...erivedFromDomainServiceFacetFactoryTest.java |  52 +--
 .../java/app/ToDoItemAnalysisContributions.java |  12 +-
 .../java/dom/todo/ToDoItemContributions.java    |  19 +-
 14 files changed, 787 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
index a692d71..52a652f 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/ActionLayout.java
@@ -116,6 +116,19 @@ public @interface ActionLayout {
         PANEL_DROPDOWN
     }
 
+    // //////////////////////////////////////
+
+    /**
+     * For actions of domain services that can be viewed and contributed (that is, whose
+     * {@link DomainService#nature() nature} is either {@link org.apache.isis.applib.annotation.NatureOfService#VIEW}
+     * or {@link org.apache.isis.applib.annotation.NatureOfService#VIEW_CONTRIBUTIONS_ONLY}), specifies how the
+     * contribution should be implemented, as an action, as an association, or as both.
+     *
+     * <p>
+     *     Has no meaning for actions of domain entities.
+     * </p>
+     */
+    Contributed contributed() default Contributed.AS_BOTH;
 
 
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/applib/src/main/java/org/apache/isis/applib/annotation/Contributed.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Contributed.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Contributed.java
new file mode 100644
index 0000000..88c46ea
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Contributed.java
@@ -0,0 +1,46 @@
+/*
+ *  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;
+
+/**
+ * The means by which a domain service action will be contributed to a domain object.
+ */
+public enum Contributed {
+    /**
+     * Default: contributed as both an action and also (if takes a single argument and has safe semantics) as an association
+     * (contributed property if returns a single value, contributed collection if returns a collection).
+     */
+    AS_BOTH,
+    /**
+     * Contributed as an action but <i>not</i> as an association.
+     */
+    AS_ACTION,
+    /**
+     * (If takes a single argument and has safe semantics) then is contributed as an association
+     * (contributed property if returns a single value, contributed collection if returns a collection) but <i>not</i>
+     * as an action.
+     */
+    AS_ASSOCIATION,
+    /**
+     * The action is not contributed as either an action or as an association.
+     */
+    AS_NEITHER;
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/applib/src/main/java/org/apache/isis/applib/annotation/NotContributed.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/NotContributed.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/NotContributed.java
index 067e9e0..5e37325 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/NotContributed.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/NotContributed.java
@@ -28,27 +28,57 @@ import java.lang.annotation.Target;
 /**
  * Indicates the a (repository) action should not be contributed, either as
  * an object action, or as an association (property/collection), or as either.
- * 
- * <p>
+ * <p/>
+ * <p/>
  * It may still be appear in the repository menu (unless it has been annotated
  * as {@link NotInServiceMenu}).
- * 
- * <p>
+ * <p/>
+ * <p/>
  * If annotated with {@link Hidden}, then also implies that the
  * menu should not be contributed.
- * 
- * <p>
+ * <p/>
+ * <p/>
  * Has no meaning for actions on regular entities.
+ *
+ * @deprecated - to not contribute at all, move action to a service whose {@link org.apache.isis.applib.annotation.DomainService#nature() nature} is {@link org.apache.isis.applib.annotation.NatureOfService#VIEW_MENU_ONLY} or {@link org.apache.isis.applib.annotation.NatureOfService#DOMAIN}; to contribute only as an action or as an association, ensure action is in a service whose nature is {@link org.apache.isis.applib.annotation.NatureOfService#VIEW} or {@link org.apache.isis.applib.annotation.NatureOfService#VIEW_CONTRIBUTIONS_ONLY}, and use {@link ActionLayout#contributed()} to specify whether the contribution should be  {@link Contributed#AS_ACTION as action} or {@link Contributed#AS_ASSOCIATION as association}.
  */
+@Deprecated
 @Inherited
-@Target({ ElementType.METHOD })
+@Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface NotContributed {
+
+    /**
+     * @deprecated
+     */
+    @Deprecated
     public enum As {
         ACTION,
         ASSOCIATION,
         EITHER;
+
+        /**
+         * @deprecated
+         */
+        @Deprecated
+        public static As from(final Contributed contributed) {
+            if(contributed == null) { return null; }
+            switch (contributed) {
+                case AS_ACTION: return As.ASSOCIATION;
+                case AS_ASSOCIATION: return As.ACTION;
+                case AS_NEITHER: return As.EITHER;
+                case AS_BOTH: return null;
+            }
+            return null;
+        }
+
     }
-    
-    As value() default As.EITHER; 
+
+    /**
+     * @deprecated
+     * @return
+     */
+    @Deprecated
+    As value() default As.EITHER;
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java
index 23a653c..9068ab9 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutFacetFactory.java
@@ -19,14 +19,17 @@
 package org.apache.isis.core.metamodel.facets.actions.layout;
 
 
+import java.lang.reflect.Method;
 import java.util.Properties;
 import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facetapi.FacetUtil;
 import org.apache.isis.core.metamodel.facetapi.FeatureType;
 import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory;
 import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacet;
 import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacet;
 import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacetFallback;
 import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacet;
@@ -35,6 +38,8 @@ import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
 import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
 import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaFacet;
 import org.apache.isis.core.metamodel.facets.object.bookmarkpolicy.BookmarkPolicyFacet;
+import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 
 
 public class ActionLayoutFacetFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
@@ -114,6 +119,32 @@ public class ActionLayoutFacetFactory extends FacetFactoryAbstract implements Co
         }
         FacetUtil.addFacet(actionPositionFacet);
 
+
+        // contributing
+
+        if (isContributingService(processMethodContext)) {
+            NotContributedFacet notContributedFacet = NotContributedFacetForLayoutProperties.create(properties, holder);
+            if(notContributedFacet == null) {
+                notContributedFacet = NotContributedFacetForActionLayoutAnnotation.create(actionLayout, holder);
+            }
+            FacetUtil.addFacet(notContributedFacet);
+        }
+    }
+
+    protected boolean isContributingService(final ProcessMethodContext processMethodContext) {
+        final Method method = processMethodContext.getMethod();
+        final Class<?> declaringClass = method.getDeclaringClass();
+        final ObjectSpecification spec = getSpecificationLoader().loadSpecification(declaringClass);
+
+        final DomainServiceFacet domainServiceFacet = spec.getFacet(DomainServiceFacet.class);
+        return domainServiceFacet != null && !domainServiceFacet.isNoop() &&
+                domainServiceFacet.getNatureOfService() != NatureOfService.VIEW_MENU_ONLY &&
+                domainServiceFacet.getNatureOfService() != NatureOfService.DOMAIN;
+    }
+
+
+    protected boolean skipContributing(final DomainServiceFacet domainServiceFacet) {
+        return domainServiceFacet == null || domainServiceFacet.isNoop() || domainServiceFacet.getNatureOfService() == NatureOfService.VIEW_MENU_ONLY || domainServiceFacet.getNatureOfService() == NatureOfService.DOMAIN;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NamedFacetForActionLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NamedFacetForActionLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NamedFacetForActionLayoutAnnotation.java
index 3bf2cab..6a36efb 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NamedFacetForActionLayoutAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NamedFacetForActionLayoutAnnotation.java
@@ -27,7 +27,7 @@ import org.apache.isis.core.metamodel.facets.all.named.NamedFacetAbstract;
 
 public class NamedFacetForActionLayoutAnnotation extends NamedFacetAbstract {
 
-    public static NamedFacet create(ActionLayout actionLayout, FacetHolder holder) {
+    public static NamedFacet create(final ActionLayout actionLayout, final FacetHolder holder) {
         if(actionLayout == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForActionLayoutAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForActionLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForActionLayoutAnnotation.java
new file mode 100644
index 0000000..7273c48
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForActionLayoutAnnotation.java
@@ -0,0 +1,49 @@
+/*
+ *  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.layout;
+
+
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.Contributed;
+import org.apache.isis.applib.annotation.NotContributed;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacet;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacetAbstract;
+
+
+public class NotContributedFacetForActionLayoutAnnotation extends NotContributedFacetAbstract {
+
+    public static NotContributedFacet create(
+            final ActionLayout actionLayout, final FacetHolder holder) {
+        if(actionLayout == null) {
+            return null;
+        }
+        final Contributed contributed = actionLayout.contributed();
+        final NotContributed.As as = NotContributed.As.from(contributed);
+        if(as == null) {
+            return null;
+        }
+        return new NotContributedFacetForActionLayoutAnnotation(as, holder);
+    }
+
+    private NotContributedFacetForActionLayoutAnnotation(final NotContributed.As as, final FacetHolder holder) {
+        super(as, holder);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForLayoutProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForLayoutProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForLayoutProperties.java
new file mode 100644
index 0000000..b2029f2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/layout/NotContributedFacetForLayoutProperties.java
@@ -0,0 +1,60 @@
+/*
+ *  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.layout;
+
+
+import java.util.Properties;
+import com.google.common.base.Strings;
+import org.apache.isis.applib.annotation.Contributed;
+import org.apache.isis.applib.annotation.NotContributed;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacet;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacetAbstract;
+
+
+public class NotContributedFacetForLayoutProperties extends NotContributedFacetAbstract {
+
+    public static NotContributedFacet create(final Properties properties, final FacetHolder holder) {
+        final Contributed contributed = contributing(properties);
+        if(contributed == null) {
+            return null;
+        }
+        return contributed != null? new NotContributedFacetForLayoutProperties(NotContributed.As.from(contributed), holder): null;
+    }
+
+    private NotContributedFacetForLayoutProperties(
+            final NotContributed.As as,
+            final FacetHolder holder) {
+        super(as, holder);
+    }
+
+
+    private static Contributed contributing(final Properties properties) {
+        if(properties == null) {
+            return null;
+        }
+        String contributing = Strings.emptyToNull(properties.getProperty("contributing"));
+        if(contributing == null) {
+            // alternate key
+            contributing = Strings.emptyToNull(properties.getProperty("contributed"));
+        }
+        return contributing != null? Contributed.valueOf(contributing): null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/ActionLayoutFacetRepr.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/ActionLayoutFacetRepr.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/ActionLayoutFacetRepr.java
index 37ba265..e8612f8 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/ActionLayoutFacetRepr.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/layoutmetadata/ActionLayoutFacetRepr.java
@@ -19,6 +19,7 @@ package org.apache.isis.core.metamodel.layoutmetadata;
 
 import org.apache.isis.applib.annotation.ActionLayout;
 import org.apache.isis.applib.annotation.BookmarkPolicy;
+import org.apache.isis.applib.annotation.Contributed;
 import org.apache.isis.applib.annotation.Where;
 
 public class ActionLayoutFacetRepr {
@@ -31,4 +32,5 @@ public class ActionLayoutFacetRepr {
     public String named;
     public boolean namedEscaped = true;
     public ActionLayout.Position position;
+    public Contributed contributed;
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryJunit4Test.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryJunit4Test.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryJunit4Test.java
new file mode 100644
index 0000000..54909d3
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryJunit4Test.java
@@ -0,0 +1,380 @@
+/*
+ *  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.layout;
+
+import org.hamcrest.CoreMatchers;
+import org.jmock.Expectations;
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.Contributed;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.NotContributed;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryJUnit4TestCase;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.actions.notcontributed.NotContributedFacet;
+import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
+import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacetAbstract;
+
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class ActionLayoutAnnotationFacetFactoryJunit4Test extends AbstractFacetFactoryJUnit4TestCase {
+
+    ActionLayoutFacetFactory facetFactory;
+
+    @Before
+    public void setUp() throws Exception {
+        facetFactory = new ActionLayoutFacetFactory();
+        facetFactory.setSpecificationLookup(mockSpecificationLoaderSpi);
+    }
+
+    public static class Contributing extends ActionLayoutAnnotationFacetFactoryJunit4Test {
+
+        @Test
+        public void onDomainServiceForViewWithDefault() {
+
+            // given
+            @DomainService(nature = NatureOfService.VIEW)
+            class CustomerService {
+
+                @ActionLayout()
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(nullValue()));
+
+        }
+
+        @Test
+        public void onDomainServiceForViewWithBoth() {
+            // given
+            @DomainService(nature = NatureOfService.VIEW)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_BOTH)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(nullValue()));
+
+        }
+
+        @Test
+        public void testOnDomainServiceForViewWithAssociation() {
+
+            // given
+            @DomainService(nature = NatureOfService.VIEW)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_ASSOCIATION)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(not(nullValue())));
+            assertThat(facet instanceof NotContributedFacetForActionLayoutAnnotation, CoreMatchers.is(true));
+            final NotContributedFacetForActionLayoutAnnotation facetImpl = (NotContributedFacetForActionLayoutAnnotation) facet;
+            assertThat(facetImpl.value(), CoreMatchers.equalTo(NotContributed.As.ACTION));
+
+        }
+
+        @Test
+        public void onDomainServiceForViewWithAction() {
+
+            // given
+            @DomainService(nature = NatureOfService.VIEW)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_ACTION)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(not(nullValue())));
+            assertThat(facet instanceof NotContributedFacetForActionLayoutAnnotation, CoreMatchers.is(true));
+            final NotContributedFacetForActionLayoutAnnotation facetImpl = (NotContributedFacetForActionLayoutAnnotation) facet;
+            assertThat(facetImpl.value(), CoreMatchers.equalTo(NotContributed.As.ASSOCIATION));
+        }
+
+        @Test
+        public void onDomainServiceForViewWithNeither() {
+            // given
+            @DomainService(nature = NatureOfService.VIEW)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_NEITHER)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(not(nullValue())));
+            assertThat(facet instanceof NotContributedFacetForActionLayoutAnnotation, CoreMatchers.is(true));
+            final NotContributedFacetForActionLayoutAnnotation facetImpl = (NotContributedFacetForActionLayoutAnnotation) facet;
+            assertThat(facetImpl.value(), CoreMatchers.equalTo(NotContributed.As.EITHER));
+        }
+
+        @Test
+        public void onDomainServiceForViewContributionsOnly() {
+
+            // given
+            @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_NEITHER)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(not(nullValue())));
+            assertThat(facet instanceof NotContributedFacetForActionLayoutAnnotation, CoreMatchers.is(true));
+            final NotContributedFacetForActionLayoutAnnotation facetImpl = (NotContributedFacetForActionLayoutAnnotation) facet;
+            assertThat(facetImpl.value(), CoreMatchers.equalTo(NotContributed.As.EITHER));
+
+        }
+
+        @Test
+        public void onDomainServiceForViewMenuOnly() {
+
+            // given
+            @DomainService(nature = NatureOfService.VIEW_MENU_ONLY)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_NEITHER)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_MENU_ONLY) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(nullValue()));
+
+        }
+
+        @Test
+        public void onDomainServiceForDomainWithBoth() {
+
+            // given
+            @DomainService(nature = NatureOfService.DOMAIN)
+            class CustomerService {
+
+                @ActionLayout(contributed = Contributed.AS_NEITHER)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {
+                }));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(nullValue()));
+
+        }
+
+        @Test
+        public void onDomainObjectIsIgnored() {
+
+
+            // given
+            @DomainObject
+            class Customer {
+
+                @ActionLayout(contributed = Contributed.AS_NEITHER)
+                public String name() {
+                    return "Joe";
+                }
+            }
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(null));
+            }});
+
+            expectNoMethodsRemoved();
+
+            facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+
+            // when
+            facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+
+            // then
+            final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
+            assertThat(facet, CoreMatchers.is(nullValue()));
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java
index 321102f..d500b9b 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/layout/ActionLayoutAnnotationFacetFactoryTest.java
@@ -20,13 +20,18 @@
 package org.apache.isis.core.metamodel.facets.actions.layout;
 
 import java.lang.reflect.Method;
+import org.jmock.Expectations;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.apache.isis.applib.annotation.ActionLayout;
 import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryJUnit4TestCase;
 import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext;
 import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacet;
 import org.apache.isis.core.metamodel.facets.actions.position.ActionPositionFacetFallback;
 import org.apache.isis.core.metamodel.facets.members.cssclassfa.CssClassFaFacet;
+import org.apache.isis.core.metamodel.facets.object.domainservice.DomainServiceFacet;
 
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.instanceOf;
@@ -34,10 +39,18 @@ import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.assertThat;
 
-public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactoryTest {
+public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactoryJUnit4TestCase {
 
+    ActionLayoutFacetFactory facetFactory;
+
+    @Before
+    public void setUp() throws Exception {
+        facetFactory = new ActionLayoutFacetFactory();
+        facetFactory.setSpecificationLookup(mockSpecificationLoaderSpi);
+    }
+
+    @Test
     public void testActionLayoutAnnotationPickedUp() {
-        final ActionLayoutFacetFactory facetFactory = new ActionLayoutFacetFactory();
 
         class Customer {
             @SuppressWarnings("unused")
@@ -48,17 +61,26 @@ public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactory
         }
         final Method method = findMethod(Customer.class, "foz");
 
-        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));
+        context.checking(new Expectations() {{
+            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            will(returnValue(mockObjSpec));
+
+            allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+            will(returnValue(null));
+        }});
+
+
+        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, facetedMethod));
 
         final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class);
-        assertNotNull(facet);
-        assertTrue(facet instanceof ActionPositionFacetForActionLayoutAnnotation);
+        Assert.assertNotNull(facet);
+        Assert.assertTrue(facet instanceof ActionPositionFacetForActionLayoutAnnotation);
         final ActionPositionFacetForActionLayoutAnnotation actionLayoutFacetAnnotation = (ActionPositionFacetForActionLayoutAnnotation) facet;
-        assertEquals(ActionLayout.Position.PANEL, actionLayoutFacetAnnotation.position());
+        Assert.assertEquals(ActionLayout.Position.PANEL, actionLayoutFacetAnnotation.position());
     }
 
+    @Test
     public void testActionLayoutFallbackPickedUp() {
-        final ActionLayoutFacetFactory facetFactory = new ActionLayoutFacetFactory();
 
         class Customer {
             @SuppressWarnings("unused")
@@ -69,55 +91,84 @@ public class ActionLayoutAnnotationFacetFactoryTest extends AbstractFacetFactory
         }
         final Method method = findMethod(Customer.class, "foo");
 
-        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));
+        context.checking(new Expectations() {{
+            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            will(returnValue(mockObjSpec));
+
+            allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+            will(returnValue(null));
+        }});
+
+        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, facetedMethod));
 
         final Facet facet = facetedMethod.getFacet(ActionPositionFacet.class);
-        assertNotNull(facet);
-        assertTrue(facet instanceof ActionPositionFacetFallback);
+        Assert.assertNotNull(facet);
+        Assert.assertTrue(facet instanceof ActionPositionFacetFallback);
     }
 
-    public void testCssClassFaLeftPositionIsDefault() {
-        final ActionLayoutFacetFactory facetFactory = new ActionLayoutFacetFactory();
+    public static class CssClassFa extends ActionLayoutAnnotationFacetFactoryTest {
 
-        class Customer {
-            @SuppressWarnings("unused")
-            @ActionLayout(cssClassFa = "font-awesome")
-            public String foz() {
-                return null;
+        @Test
+        public void testDefaultPosition() {
+
+            class Customer {
+                @SuppressWarnings("unused")
+                @ActionLayout(cssClassFa = "font-awesome")
+                public String foz() {
+                    return null;
+                }
             }
-        }
-        final Method method = findMethod(Customer.class, "foz");
+            final Method method = findMethod(Customer.class, "foz");
 
-        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+                will(returnValue(mockObjSpec));
 
-        Facet facet = facetedMethod.getFacet(CssClassFaFacet.class);
-        assertThat(facet, is(notNullValue()));
-        assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class)));
-        CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet;
-        assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw font-awesome")));
-        assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(ActionLayout.CssClassFaPosition.LEFT));
-    }
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(null));
+            }});
 
-    public void testCssClassFaRightPosition() {
-        final ActionLayoutFacetFactory facetFactory = new ActionLayoutFacetFactory();
+            facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, facetedMethod));
 
-        class Customer {
-            @SuppressWarnings("unused")
-            @ActionLayout(cssClassFa = "font-awesome", cssClassFaPosition = ActionLayout.CssClassFaPosition.RIGHT)
-            public String foz() {
-                return null;
-            }
+            Facet facet = facetedMethod.getFacet(CssClassFaFacet.class);
+            assertThat(facet, is(notNullValue()));
+            assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class)));
+            CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet;
+            assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw font-awesome")));
+            assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(ActionLayout.CssClassFaPosition.LEFT));
         }
-        final Method method = findMethod(Customer.class, "foz");
 
-        facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));
+        @Test
+        public void testRightPosition() {
+
+            class Customer {
+                @SuppressWarnings("unused")
+                @ActionLayout(cssClassFa = "font-awesome", cssClassFaPosition = ActionLayout.CssClassFaPosition.RIGHT)
+                public String foz() {
+                    return null;
+                }
+            }
+            final Method method = findMethod(Customer.class, "foz");
+
+            context.checking(new Expectations() {{
+                allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+                will(returnValue(mockObjSpec));
+
+                allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
+                will(returnValue(null));
+            }});
+
+            facetFactory.process(new ProcessMethodContext(Customer.class, null, null, method, mockMethodRemover, facetedMethod));
+
+            Facet facet = facetedMethod.getFacet(CssClassFaFacet.class);
+            assertThat(facet, is(notNullValue()));
+            assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class)));
+            CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet;
+            assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw font-awesome")));
+            assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(ActionLayout.CssClassFaPosition.RIGHT));
+        }
 
-        Facet facet = facetedMethod.getFacet(CssClassFaFacet.class);
-        assertThat(facet, is(notNullValue()));
-        assertThat(facet, is(instanceOf(CssClassFaFacetForActionLayoutAnnotation.class)));
-        CssClassFaFacetForActionLayoutAnnotation classFaFacetForActionLayoutAnnotation = (CssClassFaFacetForActionLayoutAnnotation) facet;
-        assertThat(classFaFacetForActionLayoutAnnotation.value(), is(equalTo("fa fa-fw font-awesome")));
-        assertThat(classFaFacetForActionLayoutAnnotation.getPosition(), is(ActionLayout.CssClassFaPosition.RIGHT));
     }
 
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notcontributed/derived/NotContributedFacetDerivedFromDomainServiceFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notcontributed/derived/NotContributedFacetDerivedFromDomainServiceFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notcontributed/derived/NotContributedFacetDerivedFromDomainServiceFacetFactoryTest.java
index 5a05f12..d62e916 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notcontributed/derived/NotContributedFacetDerivedFromDomainServiceFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notcontributed/derived/NotContributedFacetDerivedFromDomainServiceFacetFactoryTest.java
@@ -34,7 +34,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
 
         // given
         @DomainService(nature = NatureOfService.VIEW_MENU_ONLY)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -42,19 +42,20 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_MENU_ONLY) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_MENU_ONLY) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
@@ -69,7 +70,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
 
         // given
         @DomainService(nature = NatureOfService.DOMAIN)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -77,19 +78,20 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
@@ -104,7 +106,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
 
         // given
         @DomainService(nature = NatureOfService.VIEW)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -112,19 +114,20 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
@@ -136,7 +139,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
 
         // given
         @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -144,19 +147,20 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);
@@ -167,7 +171,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
     public void whenNone() throws Exception {
 
         // given
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -175,7 +179,7 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
@@ -184,10 +188,10 @@ public class NotContributedFacetDerivedFromDomainServiceFacetFactoryTest extends
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotContributedFacet.class);

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest.java
index 7d69a76..dfb1a4a 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/actions/notinservicemenu/derived/NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest.java
@@ -34,7 +34,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
 
         // given
         @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -42,19 +42,20 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_CONTRIBUTIONS_ONLY) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
@@ -69,7 +70,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
 
         // given
         @DomainService(nature = NatureOfService.DOMAIN)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -77,19 +78,20 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.DOMAIN) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
@@ -104,7 +106,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
 
         // given
         @DomainService(nature = NatureOfService.VIEW)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -112,19 +114,20 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
@@ -136,7 +139,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
 
         // given
         @DomainService(nature = NatureOfService.VIEW_MENU_ONLY)
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -144,19 +147,20 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
-            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_MENU_ONLY) {}));
+            will(returnValue(new DomainServiceFacetAbstract(mockObjSpec, null, NatureOfService.VIEW_MENU_ONLY) {
+            }));
         }});
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);
@@ -167,7 +171,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
     public void whenNone() throws Exception {
 
         // given
-        class Customer {
+        class CustomerService {
 
             public String name() {
                 return "Joe";
@@ -175,7 +179,7 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
         }
 
         context.checking(new Expectations() {{
-            allowing(mockSpecificationLoaderSpi).loadSpecification(Customer.class);
+            allowing(mockSpecificationLoaderSpi).loadSpecification(CustomerService.class);
             will(returnValue(mockObjSpec));
 
             allowing(mockObjSpec).getFacet(DomainServiceFacet.class);
@@ -184,10 +188,10 @@ public class NotInServiceMenuFacetDerivedFromDomainServiceFacetFactoryTest exten
 
         expectNoMethodsRemoved();
 
-        facetedMethod = FacetedMethod.createForAction(Customer.class, "name");
+        facetedMethod = FacetedMethod.createForAction(CustomerService.class, "name");
 
         // when
-        facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
+        facetFactory.process(new FacetFactory.ProcessMethodContext(CustomerService.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod));
 
         // then
         final Facet facet = facetedMethod.getFacet(NotInServiceMenuFacet.class);

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/example/application/todoapp/dom/src/main/java/app/ToDoItemAnalysisContributions.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/app/ToDoItemAnalysisContributions.java b/example/application/todoapp/dom/src/main/java/app/ToDoItemAnalysisContributions.java
index 6527ffe..baf4b00 100644
--- a/example/application/todoapp/dom/src/main/java/app/ToDoItemAnalysisContributions.java
+++ b/example/application/todoapp/dom/src/main/java/app/ToDoItemAnalysisContributions.java
@@ -21,20 +21,18 @@ package app;
 import dom.todo.ToDoItem;
 
 import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.Contributed;
 import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.NotContributed;
-import org.apache.isis.applib.annotation.NotContributed.As;
-import org.apache.isis.applib.annotation.NotInServiceMenu;
+import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.applib.annotation.SemanticsOf;
 
-@DomainService
+@DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
 public class ToDoItemAnalysisContributions {
 
 
     //region > analyseCategory (action)
-    @NotInServiceMenu
-    @NotContributed(As.ASSOCIATION)
+    @ActionLayout(contributed = Contributed.AS_ACTION)
     @Action(
             semantics = SemanticsOf.SAFE
     )

http://git-wip-us.apache.org/repos/asf/isis/blob/f3294b65/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
index 655ad30..3698130 100644
--- a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
+++ b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemContributions.java
@@ -32,11 +32,10 @@ import org.joda.time.LocalDate;
 import org.apache.isis.applib.AbstractFactoryAndRepository;
 import org.apache.isis.applib.annotation.Action;
 import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.Contributed;
 import org.apache.isis.applib.annotation.Disabled;
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.NotContributed;
-import org.apache.isis.applib.annotation.NotContributed.As;
 import org.apache.isis.applib.annotation.Optional;
 import org.apache.isis.applib.annotation.ParameterLayout;
 import org.apache.isis.applib.annotation.SemanticsOf;
@@ -49,13 +48,13 @@ import org.apache.isis.applib.value.Clob;
 public class ToDoItemContributions extends AbstractFactoryAndRepository {
 
     //region > priority (contributed property)
-    @NotContributed(As.ACTION) // ie contributed as association
     @Action(
             semantics = SemanticsOf.SAFE,
             hidden = Where.ALL_TABLES
     )
     @ActionLayout(
-            describedAs = "The relative priority of this item compared to others not yet complete (using 'due by' date)"
+            describedAs = "The relative priority of this item compared to others not yet complete (using 'due by' date)",
+            contributed = Contributed.AS_ASSOCIATION
     )
     @Disabled(reason="Relative priority, derived from due date")
     public Integer relativePriority(final ToDoItem toDoItem) {
@@ -104,10 +103,10 @@ public class ToDoItemContributions extends AbstractFactoryAndRepository {
     //endregion
 
     //region >  next, previous (contributed actions)
-    @NotContributed(As.ASSOCIATION) // ie contributed as action
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(
-            describedAs = "The next item not yet completed"
+            describedAs = "The next item not yet completed",
+            contributed = Contributed.AS_ACTION
     )
     public ToDoItem next(final ToDoItem item) {
         final Integer priority = relativePriority(item);
@@ -129,9 +128,9 @@ public class ToDoItemContributions extends AbstractFactoryAndRepository {
 
     // //////////////////////////////////////
 
-    @NotContributed(As.ASSOCIATION) // ie contributed as action
     @ActionLayout(
-            describedAs = "The previous item not yet completed"
+            describedAs = "The previous item not yet completed",
+            contributed = Contributed.AS_ACTION
     )
     @Action(semantics = SemanticsOf.SAFE)
     public ToDoItem previous(final ToDoItem item) {
@@ -170,7 +169,9 @@ public class ToDoItemContributions extends AbstractFactoryAndRepository {
     //endregion
 
     //region > similarTo (contributed collection)
-    @NotContributed(As.ACTION)
+    @ActionLayout(
+            contributed = Contributed.AS_ASSOCIATION
+    )
     @Action(semantics = SemanticsOf.SAFE)
     public List<ToDoItem> similarTo(final ToDoItem toDoItem) {
         final List<ToDoItem> similarToDoItems = allMatches(