You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/04/12 09:08:27 UTC

[1/8] isis git commit: ISIS-1369: adding in tests (taken from isis-module-security).

Repository: isis
Updated Branches:
  refs/heads/ISIS-1291 [created] 3aa60199b


ISIS-1369: adding in tests (taken from isis-module-security).


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

Branch: refs/heads/ISIS-1291
Commit: 565ac811905b8e872649d12a7f017061100a94f7
Parents: 474cb71
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Apr 11 19:01:13 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Apr 11 19:01:13 2016 +0100

----------------------------------------------------------------------
 .../appfeat/ApplicationMemberTypeTest.java      |  36 ++
 .../appfeat/ApplicationFeatureIdTest.java       | 604 +++++++++++++++++++
 ...ApplicationFeatureRepositoryDefaultTest.java | 300 +++++++++
 .../appfeat/ApplicationFeatureTest.java         | 170 ++++++
 .../appfeat/ApplicationFeatureTypeTest.java     | 191 ++++++
 5 files changed, 1301 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/565ac811/core/applib/src/test/java/org/apache/isis/applib/services/appfeat/ApplicationMemberTypeTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/test/java/org/apache/isis/applib/services/appfeat/ApplicationMemberTypeTest.java b/core/applib/src/test/java/org/apache/isis/applib/services/appfeat/ApplicationMemberTypeTest.java
new file mode 100644
index 0000000..e6c53dd
--- /dev/null
+++ b/core/applib/src/test/java/org/apache/isis/applib/services/appfeat/ApplicationMemberTypeTest.java
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.applib.services.appfeat;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationMemberTypeTest {
+
+    public static class ToString extends ApplicationMemberTypeTest {
+
+        @Test
+        public void happyCase() throws Exception {
+            assertThat(ApplicationMemberType.PROPERTY.toString(), is("PROPERTY"));
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/565ac811/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureIdTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureIdTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureIdTest.java
new file mode 100644
index 0000000..53127c7
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureIdTest.java
@@ -0,0 +1,604 @@
+/*
+ *  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.services.appfeat;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.TreeSet;
+
+import com.google.common.base.Function;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.apache.isis.applib.services.appfeat.ApplicationMemberType;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.value.ValueTypeContractTestAbstract;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.emptyCollectionOf;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationFeatureIdTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES);
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    public static class Title extends ApplicationFeatureIdTest {
+
+        @Test
+        public void happyCase() throws Exception {
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar#foo");
+
+            assertThat(applicationFeatureId.title(), is("com.mycompany.Bar#foo"));
+        }
+    }
+
+    public static class NewPackage extends ApplicationFeatureIdTest {
+
+        @Test
+        public void testNewPackage() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com.mycompany");
+            // then
+            assertThat(applicationFeatureId.getType(), is(ApplicationFeatureType.PACKAGE));
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is(nullValue()));
+            assertThat(applicationFeatureId.getMemberName(), is(nullValue()));
+        }
+    }
+
+    public static class NewClass extends ApplicationFeatureIdTest {
+
+        @Test
+        public void testNewClass() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+            // then
+            assertThat(applicationFeatureId.getType(), is(ApplicationFeatureType.CLASS));
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is("Bar"));
+            assertThat(applicationFeatureId.getMemberName(), is(nullValue()));
+        }
+    }
+
+    public static class NewMember extends ApplicationFeatureIdTest {
+
+        @Test
+        public void using_fullyQualifiedClassName_and_MemberName() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+            // then
+            assertThat(applicationFeatureId.getType(), is(ApplicationFeatureType.MEMBER));
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is("Bar"));
+            assertThat(applicationFeatureId.getMemberName(), is("foo"));
+        }
+
+        @Test
+        public void using_fullyQualifiedName() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar#foo");
+            // then
+            assertThat(applicationFeatureId.getType(), is(ApplicationFeatureType.MEMBER));
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is("Bar"));
+            assertThat(applicationFeatureId.getMemberName(), is("foo"));
+        }
+
+    }
+
+    public static class Constructor_AFT_String extends ApplicationFeatureIdTest {
+
+        @Test
+        public void whenPackage() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.PACKAGE, "com.mycompany");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newPackage("com.mycompany")));
+        }
+
+        @Test
+        public void whenClass() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.CLASS, "com.mycompany.Bar");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newClass("com.mycompany.Bar")));
+        }
+
+        @Test
+        public void whenMember() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.MEMBER, "com.mycompany.Bar#foo");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newMember("com.mycompany.Bar","foo")));
+        }
+    }
+
+    public static class NewFeature_AFT_String extends ApplicationFeatureIdTest {
+
+        @Test
+        public void whenPackage() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature(ApplicationFeatureType.PACKAGE, "com.mycompany");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newPackage("com.mycompany")));
+        }
+
+        @Test
+        public void whenClass() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature(ApplicationFeatureType.CLASS, "com.mycompany.Bar");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newClass("com.mycompany.Bar")));
+        }
+
+        @Test
+        public void whenMember() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature(ApplicationFeatureType.MEMBER, "com.mycompany.Bar#foo");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newMember("com.mycompany.Bar","foo")));
+        }
+    }
+
+    public static class NewFeature_String_String_String extends ApplicationFeatureIdTest {
+
+        @Test
+        public void whenPackage() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature("com.mycompany", null, null);
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newPackage("com.mycompany")));
+        }
+
+        @Test
+        public void whenClass() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature("com.mycompany", "Bar", null);
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newClass("com.mycompany.Bar")));
+        }
+
+        @Test
+        public void whenMember() throws Exception {
+            // when
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newFeature("com.mycompany", "Bar", "foo");
+            // then
+            assertThat(applicationFeatureId, is(ApplicationFeatureId.newMember("com.mycompany.Bar","foo")));
+        }
+    }
+
+    public static class GetParentIds extends ApplicationFeatureIdTest {
+
+        @Test
+        public void whenPackageWithNoParent() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com");
+
+            // when
+            final List<ApplicationFeatureId> parentIds = applicationFeatureId.getParentIds();
+
+            // then
+            assertThat(parentIds, emptyCollectionOf(ApplicationFeatureId.class));
+        }
+
+        @Test
+        public void whenPackageWithHasParent() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com.mycompany");
+
+            // when
+            final List<ApplicationFeatureId> parentIds = applicationFeatureId.getParentIds();
+
+            // then
+            assertThat(parentIds, contains(ApplicationFeatureId.newPackage("com")));
+        }
+
+        @Test
+        public void whenPackageWithHasParents() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com.mycompany.bish.bosh");
+
+            // when
+            final List<ApplicationFeatureId> parentIds = applicationFeatureId.getParentIds();
+
+            // then
+            assertThat(parentIds, contains(
+                    ApplicationFeatureId.newPackage("com.mycompany.bish"),
+                    ApplicationFeatureId.newPackage("com.mycompany"),
+                    ApplicationFeatureId.newPackage("com")
+                    ));
+        }
+
+        @Test
+        public void whenClassWithParents() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            // when
+            final List<ApplicationFeatureId> parentIds = applicationFeatureId.getParentIds();
+
+            // then
+            assertThat(parentIds, contains(
+                    ApplicationFeatureId.newPackage("com.mycompany"),
+                    ApplicationFeatureId.newPackage("com")
+                    ));
+        }
+
+        @Test
+        public void whenMember() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+
+            // when
+            final List<ApplicationFeatureId> parentIds = applicationFeatureId.getParentIds();
+
+            // then
+            assertThat(parentIds, contains(
+                    ApplicationFeatureId.newClass("com.mycompany.Bar"),
+                    ApplicationFeatureId.newPackage("com.mycompany"),
+                    ApplicationFeatureId.newPackage("com")
+                    ));
+        }
+
+    }
+
+    public static class GetParentPackageId extends ApplicationFeatureIdTest {
+
+        @Test
+        public void givenPackageWhenParentIsNotRoot() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com.mycompany");
+            // when
+            final ApplicationFeatureId parentPackageId = applicationFeatureId.getParentPackageId();
+            // then
+            assertThat(parentPackageId.getType(), is(ApplicationFeatureType.PACKAGE));
+            assertThat(parentPackageId.getPackageName(), is("com"));
+            assertThat(parentPackageId.getClassName(), is(nullValue()));
+            assertThat(parentPackageId.getMemberName(), is(nullValue()));
+        }
+
+        @Test
+        public void givenPackageWhenParentIsRoot() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com");
+            // when
+            final ApplicationFeatureId parentPackageId = applicationFeatureId.getParentPackageId();
+            // then
+            assertThat(parentPackageId, is(nullValue()));
+        }
+
+        @Test
+        public void givenRootPackage() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("");
+            // when
+            final ApplicationFeatureId parentPackageId = applicationFeatureId.getParentPackageId();
+            // then
+            assertThat(parentPackageId, is(nullValue()));
+        }
+
+        @Test
+        public void givenClass() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            // when
+            final ApplicationFeatureId parentPackageId = applicationFeatureId.getParentPackageId();
+
+            // then
+            assertThat(parentPackageId.getType(), is(ApplicationFeatureType.PACKAGE));
+            assertThat(parentPackageId.getPackageName(), is("com.mycompany"));
+            assertThat(parentPackageId.getClassName(), is(nullValue()));
+            assertThat(parentPackageId.getMemberName(), is(nullValue()));
+        }
+
+        @Test
+        public void givenClassInRootPackage() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newClass("Bar");
+
+            // when
+            final ApplicationFeatureId parentPackageId = applicationFeatureId.getParentPackageId();
+
+            // then
+            assertThat(parentPackageId.getType(), is(ApplicationFeatureType.PACKAGE));
+            assertThat(parentPackageId.getPackageName(), is(""));
+            assertThat(parentPackageId.getClassName(), is(nullValue()));
+            assertThat(parentPackageId.getMemberName(), is(nullValue()));
+        }
+
+        @Test
+        public void givenMember() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+
+            // then
+            expectedException.expect(IllegalStateException.class);
+
+            // when
+            applicationFeatureId.getParentPackageId();
+        }
+
+    }
+
+    public static class GetParentClass extends ApplicationFeatureIdTest {
+
+        @Test
+        public void givenMember() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+
+            // when
+            final ApplicationFeatureId parentClassId = applicationFeatureId.getParentClassId();
+
+            // then
+            assertThat(parentClassId.getType(), is(ApplicationFeatureType.CLASS));
+            assertThat(parentClassId.getPackageName(), is("com.mycompany"));
+            assertThat(parentClassId.getClassName(), is("Bar"));
+            assertThat(parentClassId.getMemberName(), is(nullValue()));
+        }
+
+        @Test
+        public void givenPackage() throws Exception {
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newPackage("com");
+
+            // then
+            expectedException.expect(IllegalStateException.class);
+
+            // when
+            applicationFeatureId.getParentClassId();
+        }
+
+        @Test
+        public void givenClass() throws Exception {
+
+            // given
+            final ApplicationFeatureId applicationFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            // then
+            expectedException.expect(IllegalStateException.class);
+
+            // when
+            applicationFeatureId.getParentClassId();
+        }
+    }
+
+    public static abstract class ValueTypeContractTest extends ValueTypeContractTestAbstract<ApplicationFeatureId> {
+
+        public static class PackageFeatures extends ValueTypeContractTest {
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithSameValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newPackage("com.mycompany"),
+                        ApplicationFeatureId.newPackage("com.mycompany"));
+            }
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithDifferentValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newPackage("com.mycompany2"),
+                        ApplicationFeatureId.newClass("com.mycompany.Foo"),
+                        ApplicationFeatureId.newMember("com.mycompany.Foo#bar"));
+            }
+        }
+
+        public static class ClassFeatures extends ValueTypeContractTest {
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithSameValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newClass("com.mycompany.Foo"),
+                        ApplicationFeatureId.newClass("com.mycompany.Foo"));
+            }
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithDifferentValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newPackage("com.mycompany"),
+                        ApplicationFeatureId.newClass("com.mycompany.Foo2"),
+                        ApplicationFeatureId.newMember("com.mycompany.Foo#bar"));
+            }
+        }
+
+        public static class MemberFeatures extends ValueTypeContractTest {
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithSameValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newMember("com.mycompany.Foo#bar"),
+                        ApplicationFeatureId.newMember("com.mycompany.Foo#bar"));
+            }
+
+            @Override
+            protected List<ApplicationFeatureId> getObjectsWithDifferentValue() {
+                return Arrays.asList(
+                        ApplicationFeatureId.newPackage("com.mycompany"),
+                        ApplicationFeatureId.newClass("com.mycompany.Foo"),
+                        ApplicationFeatureId.newMember("com.mycompany.Foo#bar2"));
+            }
+        }
+
+    }
+
+
+    public static class FunctionsTest extends ApplicationFeatureIdTest {
+
+        public static class GET_CLASS_NAME extends FunctionsTest {
+
+            private Function<ApplicationFeatureId, String> func = ApplicationFeatureId.Functions.GET_CLASS_NAME;
+
+            @Test
+            public void whenNull() throws Exception {
+                expectedException.expect(NullPointerException.class);
+                func.apply(null);
+            }
+
+            @Test
+            public void whenPackage() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newPackage("com.mycompany")), is(nullValue()));
+            }
+
+            @Test
+            public void whenClass() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newClass("com.mycompany.Bar")), is("Bar"));
+            }
+
+            @Test
+            public void whenMember() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newMember("com.mycompany.Bar#foo")), is("Bar"));
+            }
+
+        }
+
+        public static class GET_MEMBER_NAME extends FunctionsTest {
+
+            private Function<ApplicationFeatureId, String> func = ApplicationFeatureId.Functions.GET_MEMBER_NAME;
+
+            @Test
+            public void whenNull() throws Exception {
+                expectedException.expect(NullPointerException.class);
+                func.apply(null);
+            }
+
+            @Test
+            public void whenPackage() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newPackage("com.mycompany")), is(nullValue()));
+            }
+
+            @Test
+            public void whenClass() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newClass("com.mycompany.Bar")), is(nullValue()));
+            }
+
+            @Test
+            public void whenMember() throws Exception {
+                assertThat(func.apply(ApplicationFeatureId.newMember("com.mycompany.Bar#foo")), is("foo"));
+            }
+
+        }
+
+    }
+
+    public static class PredicatesTest extends ApplicationFeatureIdTest {
+
+        public static class IsClassContaining extends PredicatesTest {
+
+            private ApplicationMemberType memberType;
+
+            @Mock
+            private ApplicationFeatureRepositoryDefault mockApplicationFeatureRepository;
+            @Mock
+            private ApplicationFeature mockApplicationFeature;
+
+            @Test
+            public void whenNull() throws Exception {
+                expectedException.expect(NullPointerException.class);
+
+                ApplicationFeatureId.Predicates.
+                        isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                        apply(null);
+            }
+
+            @Test
+            public void whenNotClass() throws Exception {
+                assertThat(
+                        ApplicationFeatureId.Predicates.
+                                isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                                apply(ApplicationFeatureId.newPackage("com.mycompany")),
+                        is(false));
+                assertThat(
+                        ApplicationFeatureId.Predicates.
+                                isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                                apply(ApplicationFeatureId.newMember("com.mycompany.Bar#foo")),
+                        is(false));
+            }
+
+            @Test
+            public void whenClassButFeatureNotFound() throws Exception {
+                final ApplicationFeatureId classFeature = ApplicationFeatureId.newClass("com.mycompany.Bar");
+                context.checking(new Expectations() {{
+                    allowing(mockApplicationFeatureRepository).findFeature(classFeature);
+                    will(returnValue(null));
+                }});
+
+                assertThat(
+                        ApplicationFeatureId.Predicates.
+                                isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                                apply(classFeature),
+                        is(false));
+            }
+            @Test
+            public void whenClassAndFeatureNotFoundButHasNoMembersOfType() throws Exception {
+                final ApplicationFeatureId classFeature = ApplicationFeatureId.newClass("com.mycompany.Bar");
+                context.checking(new Expectations() {{
+                    oneOf(mockApplicationFeatureRepository).findFeature(classFeature);
+                    will(returnValue(mockApplicationFeature));
+
+                    allowing(mockApplicationFeature).membersOf(ApplicationMemberType.ACTION);
+                    will(returnValue(new TreeSet<>()));
+                }});
+
+                assertThat(
+                        ApplicationFeatureId.Predicates.
+                                isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                                apply(classFeature),
+                        is(false));
+            }
+            @Test
+            public void whenClassAndFeatureNotFoundAndHasMembersOfType() throws Exception {
+                final ApplicationFeatureId classFeature = ApplicationFeatureId.newClass("com.mycompany.Bar");
+                context.checking(new Expectations() {{
+                    oneOf(mockApplicationFeatureRepository).findFeature(classFeature);
+                    will(returnValue(mockApplicationFeature));
+
+                    allowing(mockApplicationFeature).membersOf(ApplicationMemberType.ACTION);
+                    will(returnValue(new TreeSet<ApplicationFeatureId>() {{
+                        add(ApplicationFeatureId.newMember("com.mycompany.Bar#foo"));
+                    }}));
+                }});
+
+                assertThat(
+                        ApplicationFeatureId.Predicates.
+                                isClassContaining(ApplicationMemberType.ACTION, mockApplicationFeatureRepository).
+                                apply(classFeature),
+                        is(true));
+            }
+        }
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/565ac811/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefaultTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefaultTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefaultTest.java
new file mode 100644
index 0000000..5217299
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefaultTest.java
@@ -0,0 +1,300 @@
+/*
+ *  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.services.appfeat;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.hamcrest.Matchers;
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet;
+import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetAbstract;
+import org.apache.isis.core.metamodel.facets.objectvalue.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.maxlen.MaxLengthFacetAbstract;
+import org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.properties.typicallen.annotation.TypicalLengthFacetOnPropertyAnnotation;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+
+public class ApplicationFeatureRepositoryDefaultTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    ObjectSpecification mockSpec;
+    @Mock
+    OneToOneAssociation mockProp;
+    @Mock
+    OneToManyAssociation mockColl;
+    @Mock
+    ObjectAction mockAct;
+    ObjectAction mockActThatIsHidden;
+
+    @Mock
+    DomainObjectContainer mockContainer;
+
+    @Mock
+    ServicesInjector mockServicesInjector;
+
+    ApplicationFeatureRepositoryDefault applicationFeatureRepository;
+
+    @Before
+    public void setUp() throws Exception {
+        applicationFeatureRepository = new ApplicationFeatureRepositoryDefault();
+        applicationFeatureRepository.container = mockContainer;
+        applicationFeatureRepository.setServicesInjector(mockServicesInjector);
+        applicationFeatureRepository.applicationFeatureFactory = new ApplicationFeatureFactory();
+
+
+        mockActThatIsHidden = context.mock(ObjectAction.class, "mockActThatIsHidden");
+    }
+
+    public static class Load extends ApplicationFeatureRepositoryDefaultTest {
+
+        public static class Bar {}
+
+        @Ignore // considering deleting this test, it's too long and too fragile.  integ tests ought to suffice.
+        @Test
+        public void happyCase() throws Exception {
+
+            final List<ObjectAssociation> properties = Lists.<ObjectAssociation>newArrayList(mockProp);
+            final List<ObjectAssociation> collections = Lists.<ObjectAssociation>newArrayList(mockColl);
+            final List<ObjectAction> actions = Lists.newArrayList(mockAct, mockActThatIsHidden);
+
+            context.checking(new Expectations() {{
+                allowing(mockSpec).isAbstract();
+                will(returnValue(false));
+
+                allowing(mockSpec).getFullIdentifier();
+                will(returnValue(Bar.class.getName()));
+
+                allowing(mockSpec).getAssociations(with(Contributed.INCLUDED), with(ObjectAssociation.Filters.PROPERTIES));
+                will(returnValue(properties));
+
+                allowing(mockSpec).getAssociations(with(Contributed.INCLUDED), with(ObjectAssociation.Filters.COLLECTIONS));
+                will(returnValue(collections));
+
+                allowing(mockSpec).getFacet(HiddenFacet.class);
+                will(returnValue(new HiddenFacetAbstract(When.ALWAYS, Where.EVERYWHERE, mockSpec) {
+                    @Override
+                    protected String hiddenReason(final ObjectAdapter target, final Where whereContext) {
+                        return null;
+                    }
+                }));
+
+                allowing(mockSpec).getCorrespondingClass();
+                will(returnValue(Bar.class));
+
+                allowing(mockSpec).getObjectActions(with(Contributed.INCLUDED));
+                will(returnValue(actions));
+
+                allowing(mockProp).getId();
+                will(returnValue("someProperty"));
+
+                allowing(mockProp).getFacet(MaxLengthFacet.class);
+                will(returnValue(new MaxLengthFacetAbstract(30, mockProp){}));
+
+                allowing(mockProp).getFacet(TypicalLengthFacet.class);
+                will(returnValue(new TypicalLengthFacetOnPropertyAnnotation(15, mockProp)));
+
+                allowing(mockProp).isAlwaysHidden();
+                will(returnValue(false));
+
+                allowing(mockColl).getId();
+                will(returnValue("someCollection"));
+
+                allowing(mockColl).isAlwaysHidden();
+                will(returnValue(false));
+
+                allowing(mockAct).getId();
+                will(returnValue("someAction"));
+
+                allowing(mockAct).isAlwaysHidden();
+                will(returnValue(false));
+
+                allowing(mockAct).getSemantics();
+                will(returnValue(ActionSemantics.Of.SAFE));
+
+                allowing(mockActThatIsHidden).getId();
+                will(returnValue("someActionThatIsHidden"));
+
+                allowing(mockActThatIsHidden).isAlwaysHidden();
+                will(returnValue(true));
+
+                allowing(mockActThatIsHidden).getSemantics();
+                will(returnValue(ActionSemantics.Of.SAFE));
+
+                allowing(mockServicesInjector).getRegisteredServices();
+                will(returnValue(Lists.newArrayList()));
+            }});
+
+            // then
+            final Sequence sequence = context.sequence("loadSequence");
+            context.checking(new Expectations() {{
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newClass(Bar.class.getName()))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newMember(Bar.class.getName(), "someProperty"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newMember(Bar.class.getName(), "someCollection"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newMember(Bar.class.getName(), "someAction"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org.isisaddons.module.security.dom.feature"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org.isisaddons.module.security.dom"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org.isisaddons.module.security"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org.isisaddons.module"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org.isisaddons"))));
+
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                inSequence(sequence);
+                will(returnValue(new ApplicationFeature(ApplicationFeatureId.newPackage("org"))));
+            }});
+
+            // when
+            applicationFeatureRepository.createApplicationFeaturesFor(mockSpec);
+
+            // then
+            final ApplicationFeature orgPkg = applicationFeatureRepository.findPackage(ApplicationFeatureId.newPackage("org"));
+            assertThat(orgPkg, is(notNullValue()));
+            final ApplicationFeature orgIsisaddonsPkg = applicationFeatureRepository.findPackage(ApplicationFeatureId.newPackage("org.isisaddons"));
+            assertThat(orgPkg, is(notNullValue()));
+            final ApplicationFeature featurePkg = applicationFeatureRepository.findPackage(ApplicationFeatureId.newPackage("org.isisaddons.module.security.dom.feature"));
+            assertThat(orgPkg, is(notNullValue()));
+            assertThat(orgPkg.getContents(), contains(orgIsisaddonsPkg.getFeatureId()));
+            assertThat(featurePkg.getContents(), contains(ApplicationFeatureId.newClass(Bar.class.getName())));
+
+            // then
+            final ApplicationFeature barClass = applicationFeatureRepository.findClass(ApplicationFeatureId.newClass(Bar.class.getName()));
+            assertThat(barClass, is(Matchers.notNullValue()));
+
+            // then the mockActThatIsHidden is not listed.
+            assertThat(barClass.getProperties().size(), is(1));
+            assertThat(barClass.getCollections().size(), is(1));
+            assertThat(barClass.getActions().size(), is(1));
+            assertThat(barClass.getProperties(),
+                    containsInAnyOrder(
+                            ApplicationFeatureId.newMember(Bar.class.getName(), "someProperty")
+                    ));
+            assertThat(barClass.getCollections(),
+                    containsInAnyOrder(
+                            ApplicationFeatureId.newMember(Bar.class.getName(), "someCollection")
+                    ));
+            assertThat(barClass.getActions(),
+                    containsInAnyOrder(
+                            ApplicationFeatureId.newMember(Bar.class.getName(), "someAction")
+                    ));
+        }
+
+    }
+
+    public static class AddClassParent extends ApplicationFeatureRepositoryDefaultTest {
+
+        @Test
+        public void parentNotYetEncountered() throws Exception {
+
+            // given
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            // then
+            final ApplicationFeature newlyCreatedParent = new ApplicationFeature();
+            context.checking(new Expectations() {{
+                oneOf(mockContainer).newTransientInstance(ApplicationFeature.class);
+                will(returnValue(newlyCreatedParent));
+            }});
+
+            // when
+            final ApplicationFeatureId classParentId = applicationFeatureRepository.addClassParent(classFeatureId);
+
+            // then
+            Assert.assertThat(classParentId, is(equalTo(classFeatureId.getParentPackageId())));
+            final ApplicationFeature classPackage = applicationFeatureRepository.findPackage(classParentId);
+            assertThat(classPackage, is(newlyCreatedParent));
+        }
+
+        @Test
+        public void parentAlreadyEncountered() throws Exception {
+
+            // given
+            final ApplicationFeatureId packageId = ApplicationFeatureId.newPackage("com.mycompany");
+            final ApplicationFeature pkg = new ApplicationFeature();
+            pkg.setFeatureId(packageId);
+            applicationFeatureRepository.packageFeatures.put(packageId, pkg);
+
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            // when
+            final ApplicationFeatureId applicationFeatureId = applicationFeatureRepository.addClassParent(classFeatureId);
+
+            // then
+            Assert.assertThat(applicationFeatureId, is(equalTo(packageId)));
+        }
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/565ac811/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTest.java
new file mode 100644
index 0000000..e439b3b
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTest.java
@@ -0,0 +1,170 @@
+/*
+ *  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.services.appfeat;
+
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.apache.isis.applib.services.appfeat.ApplicationMemberType;
+
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationFeatureTest {
+
+    public static class GetContents_and_AddToContents extends ApplicationFeatureTest {
+
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void givenPackage_whenAddPackageAndClass() throws Exception {
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newPackage("com.mycompany"));
+            final ApplicationFeatureId packageFeatureId = ApplicationFeatureId.newPackage("com.mycompany.flob");
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bar");
+
+            applicationFeature.addToContents(packageFeatureId);
+            applicationFeature.addToContents(classFeatureId);
+
+            assertThat(applicationFeature.getContents().size(), is(2));
+            assertThat(applicationFeature.getContents(), containsInAnyOrder(packageFeatureId, classFeatureId));
+        }
+
+        @Test
+        public void givenPackage_whenAddMember() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newPackage("com.mycompany"));
+            final ApplicationFeatureId memberFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+
+            applicationFeature.addToContents(memberFeatureId);
+        }
+
+        @Test
+        public void givenClass() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newClass("com.mycompany.Bar"));
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.flob.Bar");
+
+            applicationFeature.addToContents(classFeatureId);
+        }
+
+        @Test
+        public void givenMember() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newMember("com.mycompany.Bar", "foo"));
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.flob.Bar");
+
+            applicationFeature.addToContents(classFeatureId);
+        }
+
+    }
+
+    public static class GetMembers_and_AddToMembers extends ApplicationFeatureTest {
+
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void givenPackage() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newPackage("com.mycompany"));
+            final ApplicationFeatureId memberFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+
+            applicationFeature.addToMembers(memberFeatureId, ApplicationMemberType.PROPERTY);
+        }
+
+        @Test
+        public void givenClass_whenAddMember() throws Exception {
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newClass("com.mycompany.Bar"));
+            final ApplicationFeatureId memberFeatureId = ApplicationFeatureId.newMember("com.mycompany.Bar", "foo");
+            final ApplicationFeatureId memberFeatureId2 = ApplicationFeatureId.newMember("com.mycompany.Bar", "boz");
+
+            applicationFeature.addToMembers(memberFeatureId, ApplicationMemberType.PROPERTY);
+            applicationFeature.addToMembers(memberFeatureId2, ApplicationMemberType.PROPERTY);
+
+            assertThat(applicationFeature.getProperties().size(), is(2));
+            assertThat(applicationFeature.getProperties(), containsInAnyOrder(memberFeatureId, memberFeatureId2));
+        }
+
+        @Test
+        public void givenClass_whenAddPackage() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newClass("com.mycompany.Bar"));
+            final ApplicationFeatureId packageFeatureId = ApplicationFeatureId.newPackage("com.mycompany");
+
+            applicationFeature.addToMembers(packageFeatureId, ApplicationMemberType.PROPERTY);
+        }
+
+        @Test
+        public void givenClass_whenAddClass() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newClass("com.mycompany.Bar"));
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.Bop");
+
+            applicationFeature.addToMembers(classFeatureId, ApplicationMemberType.PROPERTY);
+        }
+
+        @Test
+        public void givenMember() throws Exception {
+
+            expectedException.expect(IllegalStateException.class);
+
+            final ApplicationFeature applicationFeature = new ApplicationFeature(ApplicationFeatureId.newMember("com.mycompany.Bar", "foo"));
+            final ApplicationFeatureId classFeatureId = ApplicationFeatureId.newClass("com.mycompany.flob.Bar");
+
+            applicationFeature.addToMembers(classFeatureId, ApplicationMemberType.PROPERTY);
+        }
+    }
+
+
+    public static class FunctionsTest extends ApplicationFeatureTest {
+
+        @Test
+        public void GET_FQN() throws Exception {
+            final ApplicationFeature input = new ApplicationFeature(ApplicationFeatureId.newMember("com.mycompany.Foo#bar"));
+            assertThat(ApplicationFeature.Functions.GET_FQN.apply(input), is("com.mycompany.Foo#bar"));
+        }
+        @Test
+        public void GET_ID() throws Exception {
+            final ApplicationFeatureId featureId = ApplicationFeatureId.newMember("com.mycompany.Foo#bar");
+            final ApplicationFeature input = new ApplicationFeature(featureId);
+            assertThat(ApplicationFeature.Functions.GET_ID.apply(input), is(featureId));
+        }
+    }
+
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/565ac811/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
new file mode 100644
index 0000000..1f00249
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
@@ -0,0 +1,191 @@
+/*
+ *  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.services.appfeat;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationFeatureTypeTest {
+
+    public static class HideClassName extends ApplicationFeatureTypeTest {
+        @Test
+        public void all() throws Exception {
+            assertThat(ApplicationFeatureType.PACKAGE.hideClassName(), is(true));
+            assertThat(ApplicationFeatureType.CLASS.hideClassName(), is(false));
+            assertThat(ApplicationFeatureType.MEMBER.hideClassName(), is(false));
+        }
+    }
+
+    public static class HideMemberName extends ApplicationFeatureTypeTest {
+
+        @Test
+        public void all() throws Exception {
+            assertThat(ApplicationFeatureType.PACKAGE.hideMember(), is(true));
+            assertThat(ApplicationFeatureType.CLASS.hideMember(), is(true));
+            assertThat(ApplicationFeatureType.MEMBER.hideMember(), is(false));
+        }
+    }
+
+    public static class Init extends ApplicationFeatureTypeTest {
+
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void givenPackage() throws Exception {
+
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.PACKAGE);
+
+            ApplicationFeatureType.PACKAGE.init(applicationFeatureId, "com.mycompany");
+
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is(nullValue()));
+            assertThat(applicationFeatureId.getMemberName(), is(nullValue()));
+
+        }
+        @Test
+        public void givenClass() throws Exception {
+
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.CLASS);
+
+            ApplicationFeatureType.CLASS.init(applicationFeatureId, "com.mycompany.Bar");
+
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is("Bar"));
+            assertThat(applicationFeatureId.getMemberName(), is(nullValue()));
+
+        }
+        @Test
+        public void givenMember() throws Exception {
+
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.MEMBER);
+
+            ApplicationFeatureType.MEMBER.init(applicationFeatureId, "com.mycompany.Bar#foo");
+
+            assertThat(applicationFeatureId.getPackageName(), is("com.mycompany"));
+            assertThat(applicationFeatureId.getClassName(), is("Bar"));
+            assertThat(applicationFeatureId.getMemberName(), is("foo"));
+        }
+        @Test
+        public void givenMemberMalformed() throws Exception {
+
+            expectedException.expect(IllegalArgumentException.class);
+            final ApplicationFeatureId applicationFeatureId = new ApplicationFeatureId(ApplicationFeatureType.MEMBER);
+
+            ApplicationFeatureType.MEMBER.init(applicationFeatureId, "com.mycompany.BarISMISSINGTHEHASHSYMBOL");
+        }
+    }
+
+    public static class EnsurePackage extends ApplicationFeatureTypeTest {
+
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void whenPackage() throws Exception {
+            ApplicationFeatureType.ensurePackage(new ApplicationFeatureId(ApplicationFeatureType.PACKAGE));
+        }
+        @Test
+        public void whenClass() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensurePackage(new ApplicationFeatureId(ApplicationFeatureType.CLASS));
+        }
+        @Test
+        public void whenMember() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensurePackage(new ApplicationFeatureId(ApplicationFeatureType.MEMBER));
+        }
+    }
+
+    public static class EnsurePackageOrClass extends ApplicationFeatureTypeTest {
+
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void whenPackage() throws Exception {
+            ApplicationFeatureType.ensurePackageOrClass(new ApplicationFeatureId(ApplicationFeatureType.PACKAGE));
+        }
+        @Test
+        public void whenClass() throws Exception {
+            ApplicationFeatureType.ensurePackageOrClass(new ApplicationFeatureId(ApplicationFeatureType.CLASS));
+        }
+        @Test
+        public void whenMember() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensurePackageOrClass(new ApplicationFeatureId(ApplicationFeatureType.MEMBER));
+        }
+
+    }
+
+    public static class EnsureClass extends ApplicationFeatureTypeTest {
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void whenPackage() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensureClass(new ApplicationFeatureId(ApplicationFeatureType.PACKAGE));
+        }
+        @Test
+        public void whenClass() throws Exception {
+            ApplicationFeatureType.ensureClass(new ApplicationFeatureId(ApplicationFeatureType.CLASS));
+        }
+        @Test
+        public void whenMember() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensureClass(new ApplicationFeatureId(ApplicationFeatureType.MEMBER));
+        }
+
+    }
+
+    public static class EnsureMember extends ApplicationFeatureTypeTest {
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
+
+        @Test
+        public void whenPackage() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensureMember(new ApplicationFeatureId(ApplicationFeatureType.PACKAGE));
+        }
+        @Test
+        public void whenClass() throws Exception {
+            expectedException.expect(IllegalStateException.class);
+            ApplicationFeatureType.ensureMember(new ApplicationFeatureId(ApplicationFeatureType.CLASS));
+        }
+        @Test
+        public void whenMember() throws Exception {
+            ApplicationFeatureType.ensureMember(new ApplicationFeatureId(ApplicationFeatureType.MEMBER));
+        }
+    }
+
+    public static class ToString extends ApplicationFeatureTypeTest {
+
+        @Test
+        public void happyCase() throws Exception {
+            assertThat(ApplicationFeatureType.PACKAGE.toString(), is("PACKAGE"));
+        }
+    }
+
+}
\ No newline at end of file


[7/8] isis git commit: ISIS-1372: just moved BacgroundService#asActionInvocationMemento over to new CommandMementoService#asActionInvocationMemento.

Posted by da...@apache.org.
ISIS-1372: just moved BacgroundService#asActionInvocationMemento over to new CommandMementoService#asActionInvocationMemento.


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

Branch: refs/heads/ISIS-1291
Commit: 9b35ceb9d1e1272fcbf864e2ea7906f824f0308f
Parents: b1b3dc5
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 00:54:32 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 00:54:32 2016 +0100

----------------------------------------------------------------------
 .../guides/_rgsvc_application-layer-spi.adoc    |  12 ++
 .../_rgsvc_spi_CommandMementoService.adoc       |  60 +++++++
 .../services/command/CommandMementoService.java |  45 +++++
 ...onInvocationFacetForDomainEventAbstract.java |   9 +-
 .../background/BackgroundServiceDefault.java    |  46 +-----
 .../command/CommandMementoServiceDefault.java   | 163 +++++++++++++++++++
 6 files changed, 285 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/adocs/documentation/src/main/asciidoc/guides/_rgsvc_application-layer-spi.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_application-layer-spi.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_application-layer-spi.adoc
index 395a6f6..3fc6e30 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_application-layer-spi.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_application-layer-spi.adoc
@@ -34,6 +34,17 @@ The table below summarizes the application layer SPIs defined by Apache Isis.  I
 `JdoRepository`
 
 
+|xref:rgsvc.adoc#_rgsvc_api_CommandContext[`o.a.i.applib.` +
+`services.command` +
+`CommandMementoService`]
+|(`1.13.0-SNAPSHOT`) Creates memento of current action invocation, for use either as a reified command or for implementatins of the xref:rgsvc.adoc#_rgsvc_spi_PublishingService[`PublishingService`].
+|`CommandMemento-` +
+`ServiceDefault` +
+``o.a.i.core`` +
+``isis-core-runtim``
+|
+
+
 |xref:rgsvc.adoc#_rgsvc_spi_CommandService[`o.a.i.applib.` +
 `services.command.spi` +
 `CommandService`]
@@ -73,5 +84,6 @@ Key:
 
 
 include::_rgsvc_spi_BackgroundCommandService.adoc[leveloffset=+1]
+include::_rgsvc_api_CommandMementoService.adoc[leveloffset=+1]
 include::_rgsvc_spi_CommandService.adoc[leveloffset=+1]
 include::_rgsvc_api_HomePageProviderService.adoc[leveloffset=+1]

http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_CommandMementoService.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_CommandMementoService.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_CommandMementoService.adoc
new file mode 100644
index 0000000..17c3d47
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_CommandMementoService.adoc
@@ -0,0 +1,60 @@
+[[_rgsvc_spi_CommandMementoService]]
+= `CommandMementoService` (`1.13.0-SNAPSHOT`)
+:Notice: 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.
+:_basedir: ../
+:_imagesdir: images/
+
+
+The `CommandMementoService` (`1.13.0-SNAPSHOT`) is responsible for creating a memento of a current action invocation,
+to store in the `Command` object (from xref:rgsvc.adoc#_rgsvc_api_CommandContext[`CommandContext`]).
+This memento can be reified for use either in xref:rgsvc.adoc#_rgsvc_spi_BackgroundCommandService[background command]s, or to be published using xref:rgsvc.adoc#_rgsvc_spi_PublishingService[`PublishingService`].
+
+
+
+
+== SPI & Implementation
+
+The SPI of the service is:
+
+[source,java]
+----
+public interface CommandMementoService {
+    @Programmatic
+    ActionInvocationMemento asActionInvocationMemento(
+                        Method m, Object domainObject, Object[] args);
+}
+----
+
+The default implementation is provided by core (`o.a.i.core.runtime.services.command.CommandMementoServiceDefault`).
+
+
+
+
+== Registering the Services
+
+Assuming that the `configuration-and-annotation` services installer is configured (implicit if using the
+`AppManifest` to xref:rgcms.adoc#_rgcms_classes_AppManifest-bootstrapping[bootstrap the app]) then Apache Isis' core
+implementation of `CommandMementoService` is automatically registered (it is annotated with `@DomainService`) so no
+further configuration is required.
+
+To use an alternative implementation, use
+xref:rgant.adoc#_rgant-DomainServiceLayout_menuOrder[`@DomainServiceLayout#menuOrder()`] (as explained
+in the xref:rgsvc.adoc#_rgsvc_intro_overriding-the-services[introduction] to this guide).
+
+
+
+== Related Services
+
+This service is used when invoking an action, the memento being copied onto the `Command`.
+If the action turns out to be published, then the memento is copied down from the `Command`
+ and may be used by the xref:rgsvc.adoc#_rgsvc_spi_PublishingService[`PublishingService`] implementation.
+
+In addition, the service is also called by xref:rgsvc.adoc#_rgsvc_api_BackgroundService[`BackgroundService`] in order to create a memento
+for a command that can then be run in the background at some time in the future.
+
+
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java b/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
new file mode 100644
index 0000000..57eb8b3
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/command/CommandMementoService.java
@@ -0,0 +1,45 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.applib.services.command;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.services.background.ActionInvocationMemento;
+
+/**
+ * Submit actions to be invoked in the background.
+ * 
+ * <p>
+ * Example usage:
+ * <pre>
+ * public void submitInvoices() {
+ *     for(Customer customer: customerRepository.findCustomersToInvoice()) {
+ *         backgroundService.execute(customer).submitInvoice();
+ *     }
+ * }
+ * 
+ * &#64;javax.inject.Inject
+ * private BackgroundService backgroundService;
+ * </pre>
+ */
+public interface CommandMementoService {
+
+    @Programmatic
+    ActionInvocationMemento asActionInvocationMemento(Method m, Object domainObject, Object[] args);
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 14bd6aa..790ff8c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -39,10 +39,10 @@ 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.CommandMementoService;
 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;
@@ -339,12 +339,11 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
                     if(command.getMemento() == null) {
                         // similarly, guard here to deal with subsequent contributed/mixin actions.
 
-                        // 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 CommandMementoService commandMementoService = getServicesInjector().lookupService(CommandMementoService.class);
+                        if(commandMementoService != null) {
                             final Object targetObject = unwrap(targetAdapter);
                             final Object[] args = CommandUtil.objectsFor(arguments);
-                            final ActionInvocationMemento aim = backgroundService.asActionInvocationMemento(method, targetObject, args);
+                            final ActionInvocationMemento aim = commandMementoService.asActionInvocationMemento(method, targetObject, args);
 
                             if(aim != null) {
                                 command.setMemento(aim.asMementoString());

http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index f56a697..457dfb9 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -18,9 +18,6 @@ package org.apache.isis.core.runtime.services.background;
 
 import java.lang.reflect.Method;
 import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
 
 import com.google.common.collect.Lists;
 
@@ -76,13 +73,6 @@ public class BackgroundServiceDefault implements BackgroundService {
         this.mementoService = mementoService.withNoEncoding();
     }
     
-    // //////////////////////////////////////
-
-    
-    @Programmatic
-    @PostConstruct
-    public void init(Map<String,String> props) {
-    }
 
     // //////////////////////////////////////
 
@@ -213,43 +203,10 @@ public class BackgroundServiceDefault implements BackgroundService {
     @Programmatic
     @Override
     public ActionInvocationMemento asActionInvocationMemento(Method method, Object domainObject, Object[] args) {
-        
-        final ObjectSpecificationDefault targetObjSpec = getJavaSpecificationOfOwningClass(method);
-        final ObjectMember member = targetObjSpec.getMember(method);
-        if(member == null) {
-            return null;
-        }
-        if(!(member instanceof ObjectAction)) {
-            return null;
-        }
-
-        final ObjectAction action = (ObjectAction) member;
-        final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
-        
-        final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);
-
-        final List<Class<?>> argTypes = Lists.newArrayList();
-        final List<Object> argObjs = Lists.newArrayList();
-        CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
-
-        final ActionInvocationMemento aim = 
-                new ActionInvocationMemento(mementoService, 
-                        actionIdentifier, 
-                        domainObjectBookmark,
-                        argTypes,
-                        argObjs);
-       
-        return aim;
+        throw new RuntimeException("Replaced by CommandMementoService");
     }
 
 
-    /**
-     * Not API
-     */
-    ActionInvocationMemento newActionInvocationMemento(String mementoStr) {
-        return new ActionInvocationMemento(mementoService, mementoStr);
-    }
-
     // //////////////////////////////////////
 
     @javax.inject.Inject
@@ -258,7 +215,6 @@ public class BackgroundServiceDefault implements BackgroundService {
     @javax.inject.Inject
     private BookmarkService bookmarkService;
 
-    @javax.inject.Inject
     private CommandContext commandContext;
 
     /**

http://git-wip-us.apache.org/repos/asf/isis/blob/9b35ceb9/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
new file mode 100644
index 0000000..a0ef2bf
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
@@ -0,0 +1,163 @@
+/**
+ *  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.runtime.services.command;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.services.background.ActionInvocationMemento;
+import org.apache.isis.applib.services.background.BackgroundCommandService;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.command.CommandMementoService;
+import org.apache.isis.core.commons.ensure.Ensure;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.specloader.specimpl.dflt.ObjectSpecificationDefault;
+import org.apache.isis.core.runtime.services.memento.MementoServiceDefault;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+/**
+ * Depends on an implementation of {@link BackgroundCommandService} to
+ * be configured.
+ */
+@DomainService(
+        nature = NatureOfService.DOMAIN
+)
+public class CommandMementoServiceDefault implements CommandMementoService {
+
+    private final MementoServiceDefault mementoService;
+
+    public CommandMementoServiceDefault() {
+        this(new MementoServiceDefault());
+    }
+
+    CommandMementoServiceDefault(MementoServiceDefault mementoService) {
+        this.mementoService = mementoService.withNoEncoding();
+    }
+    
+    // //////////////////////////////////////
+
+    
+    @Programmatic
+    @PostConstruct
+    public void init(Map<String,String> props) {
+    }
+
+    // //////////////////////////////////////
+
+
+    private ObjectSpecificationDefault getJavaSpecificationOfOwningClass(final Method method) {
+        return getJavaSpecification(method.getDeclaringClass());
+    }
+
+    private ObjectSpecificationDefault getJavaSpecification(final Class<?> cls) {
+        final ObjectSpecification objectSpec = getSpecification(cls);
+        if (!(objectSpec instanceof ObjectSpecificationDefault)) {
+            throw new UnsupportedOperationException(
+                "Only Java is supported "
+                + "(specification is '" + objectSpec.getClass().getCanonicalName() + "')");
+        }
+        return (ObjectSpecificationDefault) objectSpec;
+    }
+
+    private ObjectSpecification getSpecification(final Class<?> type) {
+        return getSpecificationLoader().loadSpecification(type);
+    }
+
+
+    // //////////////////////////////////////
+
+    @Programmatic
+    @Override
+    public ActionInvocationMemento asActionInvocationMemento(Method method, Object domainObject, Object[] args) {
+        
+        final ObjectSpecificationDefault targetObjSpec = getJavaSpecificationOfOwningClass(method);
+        final ObjectMember member = targetObjSpec.getMember(method);
+        if(member == null) {
+            return null;
+        }
+        if(!(member instanceof ObjectAction)) {
+            return null;
+        }
+
+        final ObjectAction action = (ObjectAction) member;
+        final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
+        
+        final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);
+
+        final List<Class<?>> argTypes = Lists.newArrayList();
+        final List<Object> argObjs = Lists.newArrayList();
+        CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
+
+        final ActionInvocationMemento aim = 
+                new ActionInvocationMemento(mementoService, 
+                        actionIdentifier, 
+                        domainObjectBookmark,
+                        argTypes,
+                        argObjs);
+       
+        return aim;
+    }
+
+
+    /**
+     * Not API
+     */
+    ActionInvocationMemento newActionInvocationMemento(String mementoStr) {
+        return new ActionInvocationMemento(mementoService, mementoStr);
+    }
+
+    // //////////////////////////////////////
+
+    @javax.inject.Inject
+    private BookmarkService bookmarkService;
+
+
+    private void ensureDependenciesInjected() {
+        Ensure.ensureThatState(this.bookmarkService, is(not(nullValue())), "BookmarkService domain service must be configured");
+    }
+
+    // //////////////////////////////////////
+
+    protected SpecificationLoaderSpi getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+    protected AdapterManager getAdapterManager() {
+        return IsisContext.getPersistenceSession();
+    }
+
+
+
+}


[8/8] isis git commit: ISIS-1372: BackgroundServiceDefault now reuses the code in CommandMementoServiceDefault to create an ActionInvocationMemento.

Posted by da...@apache.org.
ISIS-1372: BackgroundServiceDefault now reuses the code in CommandMementoServiceDefault to create an ActionInvocationMemento.


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

Branch: refs/heads/ISIS-1291
Commit: 3aa60199b2d1bb917ba07945023b95b52991cc26
Parents: 9b35ceb
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 01:07:54 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 01:07:54 2016 +0100

----------------------------------------------------------------------
 .../background/BackgroundServiceDefault.java    | 27 ++++++--------------
 .../command/CommandMementoServiceDefault.java   |  4 ++-
 2 files changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/3aa60199/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
index 457dfb9..f00ff3d 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundServiceDefault.java
@@ -17,9 +17,6 @@
 package org.apache.isis.core.runtime.services.background;
 
 import java.lang.reflect.Method;
-import java.util.List;
-
-import com.google.common.collect.Lists;
 
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
@@ -27,10 +24,10 @@ import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.background.ActionInvocationMemento;
 import org.apache.isis.applib.services.background.BackgroundCommandService;
 import org.apache.isis.applib.services.background.BackgroundService;
-import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.command.CommandMementoService;
 import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.lang.ArrayExtensions;
@@ -165,26 +162,15 @@ public class BackgroundServiceDefault implements BackgroundService {
 
                 final ObjectAction action = (ObjectAction) member;
 
-                final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
                 final String targetClassName = CommandUtil.targetClassNameFor(targetAdapter);
                 final String targetActionName = CommandUtil.targetActionNameFor(action);
                 final String targetArgs = CommandUtil.argDescriptionFor(action, adaptersFor(args));
-                
-                final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);
-
-                final List<Class<?>> argTypes = Lists.newArrayList();
-                final List<Object> argObjs = Lists.newArrayList();
-                CommandUtil.buildMementoArgLists(mementoService, bookmarkService, proxiedMethod, args, argTypes, argObjs);
 
                 final Command command = commandContext.getCommand();
-                
-                final ActionInvocationMemento aim = 
-                        new ActionInvocationMemento(mementoService, 
-                                actionIdentifier, 
-                                domainObjectBookmark,
-                                argTypes,
-                                argObjs);
-               
+
+                final ActionInvocationMemento aim = commandMementoService
+                        .asActionInvocationMemento(proxyMethod, domainObject, args);
+
                 backgroundCommandService.schedule(aim, command, targetClassName, targetActionName, targetArgs);
                 
                 return null;
@@ -213,6 +199,9 @@ public class BackgroundServiceDefault implements BackgroundService {
     private BackgroundCommandService backgroundCommandService;
 
     @javax.inject.Inject
+    private CommandMementoService commandMementoService;
+
+    @javax.inject.Inject
     private BookmarkService bookmarkService;
 
     private CommandContext commandContext;

http://git-wip-us.apache.org/repos/asf/isis/blob/3aa60199/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
index a0ef2bf..3b96812 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/command/CommandMementoServiceDefault.java
@@ -107,8 +107,10 @@ public class CommandMementoServiceDefault implements CommandMementoService {
         if(member == null) {
             return null;
         }
+
         if(!(member instanceof ObjectAction)) {
-            return null;
+            throw new UnsupportedOperationException(String.format(
+                    "Method %s does not correspond to an action.", method.getName()));
         }
 
         final ObjectAction action = (ObjectAction) member;


[6/8] isis git commit: ISIS-1370: tidying up other unused code related to payload factories for publishing service. Also use the PublishingService2 API if present.

Posted by da...@apache.org.
ISIS-1370: tidying up other unused code related to payload factories for publishing service.  Also use the PublishingService2 API if present.


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

Branch: refs/heads/ISIS-1291
Commit: b1b3dc52db25a32100b6e1cbf0676baac0c91bf7
Parents: fec5e92
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 00:33:23 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 00:33:23 2016 +0100

----------------------------------------------------------------------
 ...shingServiceWithDefaultPayloadFactories.java |  8 +--
 .../system/transaction/IsisTransaction.java     | 70 ++++----------------
 2 files changed, 15 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/b1b3dc52/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
index f794e65..be08eba 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
@@ -25,17 +25,11 @@ import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
-import org.apache.isis.applib.annotation.PublishedAction;
-import org.apache.isis.applib.annotation.PublishedObject;
-import org.apache.isis.applib.services.publish.PublishingService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 
-/**
- * Wrapper around {@link PublishingService} that also includes the payload factories for
- * {@link PublishedObject.PayloadFactory published object}s and {@link PublishedAction.PayloadFactory published action}s.
- */
+// unused... keeping around just for these static methods, that I suspect might be needed elsewhere.
 public class PublishingServiceWithDefaultPayloadFactories {
 
     private final static Function<ObjectAdapter, ObjectAdapter> NOT_DESTROYED_ELSE_EMPTY = new Function<ObjectAdapter, ObjectAdapter>() {

http://git-wip-us.apache.org/repos/asf/isis/blob/b1b3dc52/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index ccd335a..77d0295 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -43,7 +43,6 @@ import org.apache.isis.applib.Identifier;
 import org.apache.isis.applib.RecoverableException;
 import org.apache.isis.applib.annotation.Bulk;
 import org.apache.isis.applib.annotation.PublishedAction;
-import org.apache.isis.applib.annotation.PublishedObject;
 import org.apache.isis.applib.annotation.PublishedObject.ChangeKind;
 import org.apache.isis.applib.clock.Clock;
 import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
@@ -56,13 +55,10 @@ import org.apache.isis.applib.services.command.CommandContext;
 import org.apache.isis.applib.services.command.spi.CommandService;
 import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
 import org.apache.isis.applib.services.publish.EventMetadata;
-import org.apache.isis.applib.services.publish.EventPayload;
-import org.apache.isis.applib.services.publish.EventPayloadForActionInvocation;
-import org.apache.isis.applib.services.publish.EventPayloadForObjectChanged;
-import org.apache.isis.applib.services.publish.EventSerializer;
 import org.apache.isis.applib.services.publish.EventType;
 import org.apache.isis.applib.services.publish.ObjectStringifier;
 import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.applib.services.publish.PublishingService2;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.authentication.MessageBroker;
 import org.apache.isis.core.commons.components.TransactionScopedComponent;
@@ -251,7 +247,7 @@ public class IsisTransaction implements TransactionScopedComponent {
      */
     private final AuditingService3 auditingService3;
     /**
-     * could be null if none has been registered
+     * could be null if none has been registered.
      */
     private final PublishingService publishingService;
 
@@ -282,7 +278,7 @@ public class IsisTransaction implements TransactionScopedComponent {
         
         this.commandContext = servicesInjector.lookupService(CommandContext.class);
         this.auditingService3 = servicesInjector.lookupService(AuditingService3.class);
-        this.publishingService = getPublishingServiceIfAny(servicesInjector);
+        this.publishingService = servicesInjector.lookupService(PublishingService.class);
 
         // determine whether this xactn is taking place in the context of an
         // existing command in which a previous xactn has already occurred.
@@ -313,53 +309,6 @@ public class IsisTransaction implements TransactionScopedComponent {
     // Publishing service
     // ///////////////////////////////////////////
 
-    private PublishingService getPublishingServiceIfAny(ServicesInjector servicesInjector) {
-        final PublishingService publishingService = servicesInjector.lookupService(PublishingService.class);
-        if(publishingService == null) {
-            return null;
-        }
-
-        PublishedObject.PayloadFactory objectPayloadFactory = servicesInjector.lookupService(PublishedObject.PayloadFactory.class);
-        if(objectPayloadFactory == null) {
-            objectPayloadFactory = newDefaultObjectPayloadFactory();
-        }
-        
-        PublishedAction.PayloadFactory actionPayloadFactory = servicesInjector.lookupService(PublishedAction.PayloadFactory.class);
-        if(actionPayloadFactory == null) {
-            actionPayloadFactory = newDefaultActionPayloadFactory();
-        }
-        
-        return publishingService;
-    }
-    
-
-    protected EventSerializer newSimpleEventSerializer() {
-        return new EventSerializer.Simple();
-    }
-
-
-    protected PublishedObject.PayloadFactory newDefaultObjectPayloadFactory() {
-        return new PublishedObject.PayloadFactory() {
-            @Override
-            public EventPayload payloadFor(final Object changedObject, ChangeKind changeKind) {
-                return new EventPayloadForObjectChanged<Object>(changedObject);
-            }
-        };
-    }
-
-    protected PublishedAction.PayloadFactory newDefaultActionPayloadFactory() {
-        return new PublishedAction.PayloadFactory(){
-            @Override
-            public EventPayload payloadFor(Identifier actionIdentifier, Object target, List<Object> arguments, Object result) {
-                return new EventPayloadForActionInvocation<Object>(
-                        actionIdentifier, 
-                        target, 
-                        arguments, 
-                        result);
-            }
-        };
-    }
-    
     // ////////////////////////////////////////////////////////////////
     // GUID
     // ////////////////////////////////////////////////////////////////
@@ -588,7 +537,8 @@ public class IsisTransaction implements TransactionScopedComponent {
                     actionTargetClass, actionTargetAction, actionTarget, actionMemberIdentifier,
                     // commandTargetClass, commandTargetAction, commandTarget, commandMemberIdentifier,
                     parameterNames, parameterTypes, returnType);
-            publishingService.publish(metadata, null);
+
+            publish(metadata);
         } finally {
             // ensures that cannot publish this action more than once
             ActionInvocationFacet.currentInvocation.set(null);
@@ -629,11 +579,19 @@ public class IsisTransaction implements TransactionScopedComponent {
             
             final EventMetadata metadata = newEventMetadata(eventTypeFor, currentUser, timestamp, title, enlistedAdapterClass, null, enlistedTarget, null, null, null, null);
 
-            publishingService.publish(metadata, null);
+            publish(metadata);
         }
         return enlistedAdapters;
     }
 
+    private void publish(final EventMetadata metadata) {
+        if(publishingService instanceof PublishingService2) {
+            ((PublishingService2)publishingService).publish(metadata);
+        } else {
+            publishingService.publish(metadata, null);
+        }
+    }
+
     private static EventType eventTypeFor(ChangeKind changeKind) {
         if(changeKind == ChangeKind.UPDATE) {
             return EventType.OBJECT_UPDATED;


[4/8] isis git commit: ISIS-1373: isis-core-applib now depends on isis-core-schema, rather than other way around. Moved JaxbServiceDefault to applib.

Posted by da...@apache.org.
ISIS-1373: isis-core-applib now depends on isis-core-schema, rather than other way around.  Moved JaxbServiceDefault to applib.


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

Branch: refs/heads/ISIS-1291
Commit: 4967495f381ee9f565a9c1cb63a08bd0dbcd1653
Parents: efdb1d4
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 00:12:01 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 00:12:01 2016 +0100

----------------------------------------------------------------------
 core/applib/pom.xml                             |   4 +-
 .../services/jaxb/JaxbServiceDefault.java       |  49 ++
 .../utils/ActionInvocationMementoDtoUtils.java  | 567 +++++++++++++++++++
 .../jaxbadapters/PersistentEntityAdapter.java   |  68 +++
 .../org/apache/isis/schema/utils/Roundtrip.java | 312 ++++++++++
 core/schema/pom.xml                             |   4 +-
 .../services/jaxb/JaxbServiceDefault.java       |  49 --
 .../utils/ActionInvocationMementoDtoUtils.java  | 566 ------------------
 .../jaxbadapters/PersistentEntityAdapter.java   |  68 ---
 .../org/apache/isis/schema/utils/Roundtrip.java | 311 ----------
 10 files changed, 1000 insertions(+), 998 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/applib/pom.xml
----------------------------------------------------------------------
diff --git a/core/applib/pom.xml b/core/applib/pom.xml
index 1a6796c..4cb78cd 100644
--- a/core/applib/pom.xml
+++ b/core/applib/pom.xml
@@ -90,8 +90,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>joda-time</groupId>
-            <artifactId>joda-time</artifactId>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-schema</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/applib/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java b/core/applib/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java
new file mode 100644
index 0000000..3679fdb
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.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.schema.services.jaxb;
+
+import javax.inject.Inject;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.services.jaxb.JaxbService;
+import org.apache.isis.schema.utils.jaxbadapters.PersistentEntityAdapter;
+
+@DomainService(
+        nature = NatureOfService.DOMAIN
+)
+public class JaxbServiceDefault extends JaxbService.Simple {
+
+    protected void configure(final Unmarshaller unmarshaller) {
+        final PersistentEntityAdapter adapter = new PersistentEntityAdapter();
+        container.injectServicesInto(adapter);
+        unmarshaller.setAdapter(PersistentEntityAdapter.class, adapter);
+    }
+
+    protected void configure(final Marshaller marshaller) {
+        final PersistentEntityAdapter adapter = new PersistentEntityAdapter();
+        container.injectServicesInto(adapter);
+        marshaller.setAdapter(PersistentEntityAdapter.class, adapter);
+    }
+
+    @Inject
+    DomainObjectContainer container;
+}
+

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/applib/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java b/core/applib/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
new file mode 100644
index 0000000..3f6db44
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
@@ -0,0 +1,567 @@
+/*
+ *  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.schema.utils;
+
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.sql.Timestamp;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import com.google.common.base.Function;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.io.Resources;
+
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+import org.joda.time.LocalTime;
+
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.schema.aim.v1.ActionInvocationMementoDto;
+import org.apache.isis.schema.aim.v1.ParamDto;
+import org.apache.isis.schema.common.v1.BookmarkObjectState;
+import org.apache.isis.schema.common.v1.OidDto;
+import org.apache.isis.schema.common.v1.ValueDto;
+import org.apache.isis.schema.common.v1.ValueType;
+import org.apache.isis.schema.utils.jaxbadapters.JavaSqlTimestampXmlGregorianCalendarAdapter;
+import org.apache.isis.schema.utils.jaxbadapters.JodaDateTimeXMLGregorianCalendarAdapter;
+import org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateTimeXMLGregorianCalendarAdapter;
+import org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateXMLGregorianCalendarAdapter;
+import org.apache.isis.schema.utils.jaxbadapters.JodaLocalTimeXMLGregorianCalendarAdapter;
+
+public final class ActionInvocationMementoDtoUtils {
+
+    //region > static
+    private static final Function<ParamDto, String> PARAM_DTO_TO_NAME = new Function<ParamDto, String>() {
+        @Override public String apply(final ParamDto input) {
+            return input.getParameterName();
+        }
+    };
+    private static final Function<ParamDto, ValueType> PARAM_DTO_TO_TYPE = new Function<ParamDto, ValueType>() {
+        @Override public ValueType apply(final ParamDto input) {
+            return input.getParameterType();
+        }
+    };
+    private static JAXBContext jaxbContext;
+    private static JAXBContext getJaxbContext() {
+        if(jaxbContext == null) {
+            try {
+                jaxbContext = JAXBContext.newInstance(ActionInvocationMementoDto.class);
+            } catch (JAXBException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return jaxbContext;
+    }
+    //endregion
+
+    public static ActionInvocationMementoDto newDto() {
+        return new ActionInvocationMementoDto();
+    }
+
+    //region > actionIdentifier, target
+
+    public static void setMetadata(
+            final ActionInvocationMementoDto aim,
+            final UUID transactionId,
+            final int sequence,
+            final Timestamp timestamp,
+            final String targetClass,
+            final String targetAction,
+            final String actionIdentifier,
+            final String targetObjectType,
+            final String targetObjectIdentifier,
+            final String title,
+            final String user) {
+        ActionInvocationMementoDto.Metadata metadata = aim.getMetadata();
+        if(metadata == null) {
+            metadata = new ActionInvocationMementoDto.Metadata();
+            aim.setMetadata(metadata);
+        }
+
+        metadata.setTransactionId(transactionId.toString());
+        metadata.setSequence(sequence);
+        metadata.setTimestamp(JavaSqlTimestampXmlGregorianCalendarAdapter.print(timestamp));
+
+        metadata.setTargetClass(targetClass);
+        metadata.setTargetAction(targetAction);
+        metadata.setActionIdentifier(actionIdentifier);
+
+        final OidDto target = new OidDto();
+        target.setObjectType(targetObjectType);
+        target.setObjectIdentifier(targetObjectIdentifier);
+        metadata.setTarget(target);
+
+        metadata.setTitle(title);
+        metadata.setUser(user);
+   }
+
+
+    //endregion
+
+    //region > addArgValue, addArgReference
+    public static boolean addArgValue(
+            final ActionInvocationMementoDto aim,
+            final String parameterName,
+            final Class<?> parameterType,
+            final Object arg) {
+
+        ParamDto paramDto = null;
+        if(parameterType == String.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.STRING, arg);
+        } else
+        if(parameterType == byte.class || parameterType == Byte.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.BYTE, arg);
+        } else
+        if(parameterType == short.class || parameterType == Short.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.SHORT, arg);
+        }else
+        if(parameterType == int.class || parameterType == Integer.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.INT, arg);
+        }else
+        if(parameterType == long.class || parameterType == Long.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.LONG, arg);
+        }else
+        if(parameterType == char.class || parameterType == Character.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.CHAR, arg);
+        }else
+        if(parameterType == boolean.class || parameterType == Boolean.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.BOOLEAN, arg);
+        }else
+        if(parameterType == float.class || parameterType == Float.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.FLOAT, arg);
+        }else
+        if(parameterType == double.class || parameterType == Double.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.DOUBLE, arg);
+        }else
+        if(parameterType == BigInteger.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.BIG_INTEGER, arg);
+        }else
+        if(parameterType == BigDecimal.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.BIG_DECIMAL, arg);
+        }else
+        if(parameterType == DateTime.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.JODA_DATE_TIME, arg);
+        }else
+        if(parameterType == LocalDateTime.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_DATE_TIME, arg);
+        }else
+        if(parameterType == LocalDate.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_DATE, arg);
+        }else
+        if(parameterType == LocalTime.class) {
+            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_TIME, arg);
+        }
+
+        if(paramDto != null) {
+            final ValueDto valueDto = valueDtoFor(paramDto);
+            setValue(valueDto, parameterType, arg);
+            return true;
+        }
+
+        // none of the supported value types
+        return false;
+    }
+
+
+    public static void addArgReference(
+            final ActionInvocationMementoDto aim,
+            final String parameterName,
+            final Bookmark bookmark) {
+        final ParamDto paramDto = newParamDto(aim, parameterName, ValueType.REFERENCE, bookmark);
+        final ValueDto valueDto = valueDtoFor(paramDto);
+        OidDto argValue = asOidDto(bookmark);
+        valueDto.setReference(argValue);
+    }
+
+
+    private static OidDto asOidDto(final Bookmark reference) {
+        OidDto argValue;
+        if(reference != null) {
+            argValue = new OidDto();
+            argValue.setObjectType(reference.getObjectType());
+            argValue.setObjectState(bookmarkObjectStateOf(reference));
+            argValue.setObjectIdentifier(reference.getIdentifier());
+        } else {
+            argValue = null;
+        }
+        return argValue;
+    }
+
+    private static BookmarkObjectState bookmarkObjectStateOf(final Bookmark reference) {
+        switch(reference.getObjectState()) {
+        case PERSISTENT: return BookmarkObjectState.PERSISTENT;
+        case TRANSIENT: return BookmarkObjectState.TRANSIENT;
+        case VIEW_MODEL: return BookmarkObjectState.VIEW_MODEL;
+        }
+        throw new IllegalArgumentException(String.format("reference.objectState '%s' not recognized", reference.getObjectState()));
+    }
+
+    private static ParamDto newParamDto(
+            final ActionInvocationMementoDto aim,
+            final String parameterName,
+            final ValueType parameterType, final Object value) {
+        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderAutoCreate(aim);
+        final ParamDto paramDto = newParamDto(parameterName, parameterType);
+        paramDto.setNull(value == null);
+        addParamNum(params, paramDto);
+        return paramDto;
+    }
+
+    // lazily creates if required
+    private static ValueDto valueDtoFor(final ParamDto paramDto) {
+        ValueDto valueDto = paramDto.getValue();
+        if(valueDto == null) {
+            valueDto = new ValueDto();
+        }
+        paramDto.setValue(valueDto);
+        return valueDto;
+    }
+
+    private static ParamDto newParamDto(final String parameterName, final ValueType parameterType) {
+        final ParamDto argDto = new ParamDto();
+        argDto.setParameterName(parameterName);
+        argDto.setParameterType(parameterType);
+        return argDto;
+    }
+
+    //endregion
+
+    //region > addReturnValue, addReturnReference
+    public static boolean addReturnValue(
+            final ActionInvocationMementoDto aim,
+            final Class<?> returnType,
+            final Object returnVal) {
+        final ValueDto valueDto = returnValueDtoFor(aim);
+        return setValue(valueDto, returnType, returnVal);
+    }
+
+    public static void addReturnReference(
+            final ActionInvocationMementoDto aim,
+            final Bookmark bookmark) {
+        final ValueDto valueDto = returnValueDtoFor(aim);
+        OidDto argValue = asOidDto(bookmark);
+        valueDto.setReference(argValue);
+    }
+
+    //endregion
+
+
+
+
+    //region > getNumberOfParameters, getParameters, getParameterNames, getParameterTypes
+    public static int getNumberOfParameters(final ActionInvocationMementoDto aim) {
+        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderElseThrow(aim);
+        if(params == null) {
+            return 0;
+        }
+        return params.getNum();
+    }
+    public static List<ParamDto> getParameters(final ActionInvocationMementoDto aim) {
+        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderElseThrow(aim);
+        final int parameterNumber = getNumberOfParameters(aim);
+        final List<ParamDto> paramDtos = Lists.newArrayList();
+        for (int i = 0; i < parameterNumber; i++) {
+            final ParamDto paramDto = params.getParam().get(i);
+            paramDtos.add(paramDto);
+        }
+        return Collections.unmodifiableList(paramDtos);
+    }
+    public static List<String> getParameterNames(final ActionInvocationMementoDto aim) {
+        return immutableList(Iterables.transform(getParameters(aim), PARAM_DTO_TO_NAME));
+    }
+    public static List<ValueType> getParameterTypes(final ActionInvocationMementoDto aim) {
+        return immutableList(Iterables.transform(getParameters(aim), PARAM_DTO_TO_TYPE));
+    }
+    //endregion
+
+    //region > getParameter, getParameterName, getParameterType
+    public static ParamDto getParameter(final ActionInvocationMementoDto aim, final int paramNum) {
+        final int parameterNumber = getNumberOfParameters(aim);
+        if(paramNum > parameterNumber) {
+            throw new IllegalArgumentException(String.format("No such parameter %d (the memento has %d parameters)", paramNum, parameterNumber));
+        }
+        final List<ParamDto> parameters = getParameters(aim);
+        return parameters.get(paramNum);
+    }
+
+    public static ValueDto getParameterValue(final ActionInvocationMementoDto aim, final int paramNum) {
+        final ParamDto paramDto = getParameter(aim, paramNum);
+        return valueDtoFor(paramDto);
+    }
+
+
+    public static String getParameterName(final ActionInvocationMementoDto aim, final int paramNum) {
+        return PARAM_DTO_TO_NAME.apply(getParameter(aim, paramNum));
+    }
+    public static ValueType getParameterType(final ActionInvocationMementoDto aim, final int paramNum) {
+        return PARAM_DTO_TO_TYPE.apply(getParameter(aim, paramNum));
+    }
+    public static boolean isNull(final ActionInvocationMementoDto aim, int paramNum) {
+        final ParamDto paramDto = getParameter(aim, paramNum);
+        return paramDto.isNull();
+    }
+    //endregion
+
+    //region > getArg
+    public static <T> T getArg(final ActionInvocationMementoDto aim, int paramNum, Class<T> cls) {
+        final ParamDto paramDto = getParameter(aim, paramNum);
+        if(paramDto.isNull()) {
+            return null;
+        }
+        final ValueDto valueDto = valueDtoFor(paramDto);
+        final ValueType parameterType = paramDto.getParameterType();
+        switch(parameterType) {
+        case STRING:
+            return (T) valueDto.getString();
+        case BYTE:
+            return (T) valueDto.getByte();
+        case SHORT:
+            return (T) valueDto.getShort();
+        case INT:
+            return (T) valueDto.getInt();
+        case LONG:
+            return (T) valueDto.getLong();
+        case FLOAT:
+            return (T) valueDto.getFloat();
+        case DOUBLE:
+            return (T) valueDto.getDouble();
+        case BOOLEAN:
+            return (T) valueDto.isBoolean();
+        case CHAR:
+            final String aChar = valueDto.getChar();
+            if(Strings.isNullOrEmpty(aChar)) { return null; }
+            return (T) (Object)aChar.charAt(0);
+        case BIG_DECIMAL:
+            return (T) valueDto.getBigDecimal();
+        case BIG_INTEGER:
+            return (T) valueDto.getBigInteger();
+        case JODA_DATE_TIME:
+            return (T) JodaDateTimeXMLGregorianCalendarAdapter.parse(valueDto.getDateTime());
+        case JODA_LOCAL_DATE:
+            return (T) JodaLocalDateXMLGregorianCalendarAdapter.parse(valueDto.getLocalDate());
+        case JODA_LOCAL_DATE_TIME:
+            return (T) JodaLocalDateTimeXMLGregorianCalendarAdapter.parse(valueDto.getLocalDateTime());
+        case JODA_LOCAL_TIME:
+            return (T) JodaLocalTimeXMLGregorianCalendarAdapter.parse(valueDto.getLocalTime());
+        case REFERENCE:
+            return (T) valueDto.getReference();
+        }
+        throw new IllegalStateException("Parameter type was not recognised (possible bug)");
+    }
+    //endregion
+
+    //region > marshalling
+    public static ActionInvocationMementoDto fromXml(Reader reader) {
+        Unmarshaller un = null;
+        try {
+            un = getJaxbContext().createUnmarshaller();
+            return (ActionInvocationMementoDto) un.unmarshal(reader);
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static ActionInvocationMementoDto fromXml(
+            final Class<?> contextClass,
+            final String resourceName,
+            final Charset charset) throws IOException {
+        final URL url = Resources.getResource(contextClass, resourceName);
+        final String s = Resources.toString(url, charset);
+        return fromXml(new StringReader(s));
+    }
+
+    public static String toXml(final ActionInvocationMementoDto aim) {
+        final CharArrayWriter caw = new CharArrayWriter();
+        toXml(aim, caw);
+        return caw.toString();
+    }
+
+    public static void toXml(final ActionInvocationMementoDto aim, final Writer writer) {
+        Marshaller m = null;
+        try {
+            m = getJaxbContext().createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(aim, writer);
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    //endregion
+
+    //region > debugging
+    public static void dump(final ActionInvocationMementoDto aim, final PrintStream out) throws JAXBException {
+        out.println(toXml(aim));
+    }
+    //endregion
+
+    //region > helpers
+    private static void addParamNum(final ActionInvocationMementoDto.Payload.Parameters params, final ParamDto arg) {
+        params.getParam().add(arg);
+        Integer num = params.getNum();
+        if(num == null) {
+            num = 0;
+        }
+        params.setNum(num +1);
+    }
+
+    private static ActionInvocationMementoDto.Payload.Parameters getParametersHolderElseThrow(final ActionInvocationMementoDto aim) {
+        final ActionInvocationMementoDto.Payload payload = getPayloadElseThrow(aim);
+        final ActionInvocationMementoDto.Payload.Parameters parameters = payload.getParameters();
+        if(parameters == null) {
+            throw new IllegalStateException("No parameters have been added");
+        }
+        return parameters;
+    }
+
+    private static ActionInvocationMementoDto.Payload.Parameters getParametersHolderAutoCreate(final ActionInvocationMementoDto aim) {
+        final ActionInvocationMementoDto.Payload payload = getPayloadAutoCreate(aim);
+        ActionInvocationMementoDto.Payload.Parameters params = payload.getParameters();
+        if(params == null) {
+            params = new ActionInvocationMementoDto.Payload.Parameters();
+            payload.setParameters(params);
+        }
+        return params;
+    }
+
+    private static ValueDto returnValueDtoFor(final ActionInvocationMementoDto aim) {
+        final ActionInvocationMementoDto.Payload payload = getPayloadAutoCreate(aim);
+        ValueDto valueDto = payload.getReturn();
+        if(valueDto == null) {
+            valueDto = new ValueDto();
+            payload.setReturn(valueDto);
+        }
+        return valueDto;
+    }
+
+    private static ActionInvocationMementoDto.Payload getPayloadAutoCreate(final ActionInvocationMementoDto aim) {
+        ActionInvocationMementoDto.Payload payload = aim.getPayload();
+        if(payload == null) {
+            payload = new ActionInvocationMementoDto.Payload();
+            aim.setPayload(payload);
+        }
+        return payload;
+    }
+
+    private static ActionInvocationMementoDto.Payload getPayloadElseThrow(final ActionInvocationMementoDto aim) {
+        ActionInvocationMementoDto.Payload payload = aim.getPayload();
+        if(payload == null) {
+            throw new IllegalStateException("No payload has been added");
+        }
+        return payload;
+    }
+
+    private static <T> List<T> immutableList(final Iterable<T> transform) {
+        return Collections.unmodifiableList(
+                Lists.newArrayList(
+                        transform
+                )
+        );
+    }
+
+
+    private static boolean setValue(final ValueDto valueDto, final Class<?> type, final Object returnVal) {
+        if(type == String.class) {
+            final String argValue = (String) returnVal;
+            valueDto.setString(argValue);
+        } else
+        if(type == byte.class || type == Byte.class) {
+            final Byte argValue = (Byte) returnVal;
+            valueDto.setByte(argValue);
+        } else
+        if(type == short.class || type == Short.class) {
+            final Short argValue = (Short) returnVal;
+            valueDto.setShort(argValue);
+        }else
+        if(type == int.class || type == Integer.class) {
+            final Integer argValue = (Integer) returnVal;
+            valueDto.setInt(argValue);
+        }else
+        if(type == long.class || type == Long.class) {
+            final Long argValue = (Long) returnVal;
+            valueDto.setLong(argValue);
+        }else
+        if(type == char.class || type == Character.class) {
+            final Character argValue = (Character) returnVal;
+            valueDto.setChar("" + argValue);
+        }else
+        if(type == boolean.class || type == Boolean.class) {
+            final Boolean argValue = (Boolean) returnVal;
+            valueDto.setBoolean(argValue);
+        }else
+        if(type == float.class || type == Float.class) {
+            final Float argValue = (Float) returnVal;
+            valueDto.setFloat(argValue);
+        }else
+        if(type == double.class || type == Double.class) {
+            final Double argValue = (Double) returnVal;
+            valueDto.setDouble(argValue);
+        }else
+        if(type == BigInteger.class) {
+            final BigInteger argValue = (BigInteger) returnVal;
+            valueDto.setBigInteger(argValue);
+        }else
+        if(type == BigDecimal.class) {
+            final BigDecimal argValue = (BigDecimal) returnVal;
+            valueDto.setBigDecimal(argValue);
+        }else
+        if(type == DateTime.class) {
+            final DateTime argValue = (DateTime) returnVal;
+            valueDto.setDateTime(JodaDateTimeXMLGregorianCalendarAdapter.print(argValue));
+        }else
+        if(type == LocalDateTime.class) {
+            final LocalDateTime argValue = (LocalDateTime) returnVal;
+            valueDto.setLocalDateTime(JodaLocalDateTimeXMLGregorianCalendarAdapter.print(argValue));
+        }else
+        if(type == LocalDate.class) {
+            final LocalDate argValue = (LocalDate) returnVal;
+            valueDto.setLocalDate(JodaLocalDateXMLGregorianCalendarAdapter.print(argValue));
+        }else
+        if(type == LocalTime.class) {
+            final LocalTime argValue = (LocalTime) returnVal;
+            valueDto.setLocalTime(JodaLocalTimeXMLGregorianCalendarAdapter.print(argValue));
+        }else
+        {
+            // none of the supported value types
+            return false;
+        }
+        return true;
+    }
+
+    //endregion
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/applib/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java b/core/applib/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
new file mode 100644
index 0000000..e88576a
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
@@ -0,0 +1,68 @@
+/**
+ *  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.schema.utils.jaxbadapters;
+
+import javax.inject.Inject;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.bookmark.BookmarkService2;
+import org.apache.isis.schema.common.v1.BookmarkObjectState;
+import org.apache.isis.schema.common.v1.OidDto;
+
+public class PersistentEntityAdapter extends XmlAdapter<OidDto, Object> {
+
+    @Override
+    public Object unmarshal(final OidDto oidDto) throws Exception {
+
+        final String objectType = oidDto.getObjectType();
+        final String identifier = oidDto.getObjectIdentifier();
+        final Bookmark bookmark = new Bookmark(objectType, identifier);
+
+        return bookmarkService.lookup(bookmark, BookmarkService2.FieldResetPolicy.DONT_RESET);
+    }
+
+    @Override
+    public OidDto marshal(final Object domainObject) throws Exception {
+        if(domainObject == null) {
+            return null;
+        }
+        final Bookmark bookmark = getBookmarkService().bookmarkFor(domainObject);
+        final OidDto oidDto = new OidDto();
+        oidDto.setObjectIdentifier(bookmark.getIdentifier());
+        oidDto.setObjectState(convert(bookmark.getObjectState()));
+        oidDto.setObjectType(bookmark.getObjectType());
+        return oidDto;
+    }
+
+    private BookmarkObjectState convert(final Bookmark.ObjectState objectState) {
+        switch (objectState) {
+            case VIEW_MODEL:return BookmarkObjectState.VIEW_MODEL;
+            case TRANSIENT:return BookmarkObjectState.TRANSIENT;
+            case PERSISTENT:return BookmarkObjectState.PERSISTENT;
+        }
+        throw new IllegalArgumentException("Not recognized: " + objectState.name());
+    }
+
+    protected BookmarkService getBookmarkService() {
+        return bookmarkService;
+    }
+
+    @Inject
+    BookmarkService2 bookmarkService;
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/applib/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
----------------------------------------------------------------------
diff --git a/core/applib/src/test/java/org/apache/isis/schema/utils/Roundtrip.java b/core/applib/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
new file mode 100644
index 0000000..bc8a44d
--- /dev/null
+++ b/core/applib/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
@@ -0,0 +1,312 @@
+/**
+ *  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.schema.utils;
+
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.UUID;
+
+import org.hamcrest.Matchers;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+import org.joda.time.LocalTime;
+import org.junit.Test;
+
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.schema.aim.v1.ActionInvocationMementoDto;
+import org.apache.isis.schema.common.v1.OidDto;
+import org.apache.isis.schema.common.v1.ValueType;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Roundtrip {
+
+    @Test
+    public void happyCase() throws Exception {
+
+        // given
+        final ActionInvocationMementoDto aim = ActionInvocationMementoDtoUtils.newDto();
+
+        ActionInvocationMementoDtoUtils.setMetadata(
+                aim,
+                UUID.randomUUID(),
+                1,
+                new java.sql.Timestamp(new java.util.Date().getTime()),
+                "com.mycompany.myapp.Customer", "placeOrder", "com.mycompany.myapp.Customer#placeOrder",
+                "CUS", "12345", "John Customer", "freddyUser");
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aString", String.class, "Fred");
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullString", String.class, (String) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aByte", Byte.class, (Byte) (byte) 123);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullByte", Byte.class, (Byte) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aShort", Short.class, (Short) (short) 32123);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullShort", Short.class, (Short) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "anInt", Integer.class, 123454321);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullInt", Integer.class, (Integer) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aLong", Long.class, 1234567654321L);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullLong", Long.class, (Long) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aFloat", Float.class, 12345.6789F);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullFloat", Float.class, (Float) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aDouble", Double.class, 12345678.90123);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullDouble", Double.class, (Double) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBoolean", Boolean.class, true);
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBoolean", Boolean.class, (Boolean) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aChar", Character.class, 'x');
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullChar", Character.class, (Character) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBigInteger", java.math.BigInteger.class, new java.math.BigInteger("12345678901234567890"));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBigInteger", java.math.BigInteger.class, (java.math.BigInteger) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBigDecimal", java.math.BigDecimal.class, new java.math.BigDecimal("12345678901234567890"));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBigDecimal", java.math.BigDecimal.class, (java.math.BigDecimal) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaDateTime", org.joda.time.DateTime.class, new org.joda.time.DateTime(2015, 5, 23, 9, 54, 1));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaDateTime", org.joda.time.DateTime.class, (org.joda.time.DateTime) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalDate", org.joda.time.LocalDate.class, new org.joda.time.LocalDate(2015, 5, 23));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalDate", org.joda.time.LocalDate.class, (org.joda.time.LocalDate) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalDateTime", org.joda.time.LocalDateTime.class, new org.joda.time.LocalDateTime(2015, 5, 23, 9, 54, 1));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalDateTime", org.joda.time.LocalDateTime.class, (org.joda.time.LocalDateTime) null);
+
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalTime", org.joda.time.LocalTime.class, new org.joda.time.LocalTime(9, 54, 1));
+        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalTime", org.joda.time.LocalTime.class, (org.joda.time.LocalTime) null);
+
+        ActionInvocationMementoDtoUtils.addArgReference(aim, "aReference", new Bookmark("ORD", "12345"));
+        ActionInvocationMementoDtoUtils.addArgReference(aim, "nullReference", null);
+
+
+        // when
+        final CharArrayWriter caw = new CharArrayWriter();
+        ActionInvocationMementoDtoUtils.toXml(aim, caw);
+
+        ActionInvocationMementoDtoUtils.dump(aim, System.out);
+
+        final CharArrayReader reader = new CharArrayReader(caw.toCharArray());
+        final ActionInvocationMementoDto recreated = ActionInvocationMementoDtoUtils.fromXml(reader);
+
+
+        // then
+        assertThat(recreated.getMetadata().getActionIdentifier(), Matchers.is(aim.getMetadata().getActionIdentifier()));
+        assertThat(recreated.getMetadata().getTarget().getObjectType(), Matchers.is(aim.getMetadata().getTarget().getObjectType()));
+        assertThat(recreated.getMetadata().getTarget().getObjectIdentifier(), Matchers.is(aim.getMetadata().getTarget().getObjectIdentifier()));
+
+
+        int param = 0;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aString"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.STRING));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, String.class), is("Fred"));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullString"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.STRING));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, String.class), is(nullValue()));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aByte"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BYTE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, Byte.class), is((byte) 123));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BYTE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullByte"));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aShort"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.SHORT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, Short.class), is((short) 32123));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullShort"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.SHORT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("anInt"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.INT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, int.class), is((int) 123454321));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullInt"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.INT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aLong"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.LONG));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, long.class), is((long) 1234567654321L));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullLong"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.LONG));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aFloat"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.FLOAT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, float.class), is((float) 12345.6789F));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullFloat"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.FLOAT));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aDouble"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.DOUBLE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, double.class), is(12345678.90123));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullDouble"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.DOUBLE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBoolean"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BOOLEAN));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, boolean.class), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBoolean"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BOOLEAN));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aChar"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.CHAR));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, char.class), is('x'));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullChar"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.CHAR));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBigInteger"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BIG_INTEGER));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, BigInteger.class), is(new java.math.BigInteger("12345678901234567890")));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBigInteger"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BIG_INTEGER));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBigDecimal"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BIG_DECIMAL));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, BigDecimal.class), is(new java.math.BigDecimal("12345678901234567890")));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBigDecimal"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.BIG_DECIMAL));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaDateTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_DATE_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        // bit hacky... regular comparison fails but toString() works... must be some additional data that differs, not sure what tho'
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, DateTime.class).toString(), is(new DateTime(2015, 5, 23, 9, 54, 1).toString()));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaDateTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_DATE_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));;
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalDate"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_DATE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        final LocalDate actual = ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalDate.class);
+        final LocalDate expected = new LocalDate(2015, 5, 23);
+        assertThat(actual, equalTo(expected));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalDate"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_DATE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalDateTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_DATE_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalDateTime.class), is(new org.joda.time.LocalDateTime(2015, 5, 23, 9, 54, 1)));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalDateTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_DATE_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalTime.class), is(new org.joda.time.LocalTime(9, 54, 1)));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalTime"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.JODA_LOCAL_TIME));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aReference"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.REFERENCE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, OidDto.class).getObjectType(), is("ORD"));
+        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, OidDto.class).getObjectIdentifier(), is("12345"));
+
+        param++;
+        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullReference"));
+        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), Matchers.is(ValueType.REFERENCE));
+        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
+
+        param++;
+//        final int expected = param;
+//        assertThat(recreated.getParameters().getNum(), is(expected);
+//        assertThat(recreated.getParameters().getParam().size(), is(expected);
+//        assertThat(ActionInvocationMementoDtoUtils.getNumberOfParameters(recreated), is(expected);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/schema/pom.xml
----------------------------------------------------------------------
diff --git a/core/schema/pom.xml b/core/schema/pom.xml
index a05eac2..cda7e43 100644
--- a/core/schema/pom.xml
+++ b/core/schema/pom.xml
@@ -36,8 +36,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.isis.core</groupId>
-            <artifactId>isis-core-applib</artifactId>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
         </dependency>
     </dependencies>
 

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/schema/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/schema/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java b/core/schema/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java
deleted file mode 100644
index 3679fdb..0000000
--- a/core/schema/src/main/java/org/apache/isis/schema/services/jaxb/JaxbServiceDefault.java
+++ /dev/null
@@ -1,49 +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.schema.services.jaxb;
-
-import javax.inject.Inject;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.services.jaxb.JaxbService;
-import org.apache.isis.schema.utils.jaxbadapters.PersistentEntityAdapter;
-
-@DomainService(
-        nature = NatureOfService.DOMAIN
-)
-public class JaxbServiceDefault extends JaxbService.Simple {
-
-    protected void configure(final Unmarshaller unmarshaller) {
-        final PersistentEntityAdapter adapter = new PersistentEntityAdapter();
-        container.injectServicesInto(adapter);
-        unmarshaller.setAdapter(PersistentEntityAdapter.class, adapter);
-    }
-
-    protected void configure(final Marshaller marshaller) {
-        final PersistentEntityAdapter adapter = new PersistentEntityAdapter();
-        container.injectServicesInto(adapter);
-        marshaller.setAdapter(PersistentEntityAdapter.class, adapter);
-    }
-
-    @Inject
-    DomainObjectContainer container;
-}
-

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/schema/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
----------------------------------------------------------------------
diff --git a/core/schema/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java b/core/schema/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
deleted file mode 100644
index 30128b2..0000000
--- a/core/schema/src/main/java/org/apache/isis/schema/utils/ActionInvocationMementoDtoUtils.java
+++ /dev/null
@@ -1,566 +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.schema.utils;
-
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.Writer;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.sql.Timestamp;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import com.google.common.base.Function;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.io.Resources;
-
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.joda.time.LocalTime;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.schema.aim.v1.ActionInvocationMementoDto;
-import org.apache.isis.schema.aim.v1.ParamDto;
-import org.apache.isis.schema.common.v1.BookmarkObjectState;
-import org.apache.isis.schema.common.v1.OidDto;
-import org.apache.isis.schema.common.v1.ValueDto;
-import org.apache.isis.schema.common.v1.ValueType;
-import org.apache.isis.schema.utils.jaxbadapters.JavaSqlTimestampXmlGregorianCalendarAdapter;
-import org.apache.isis.schema.utils.jaxbadapters.JodaDateTimeXMLGregorianCalendarAdapter;
-import org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateTimeXMLGregorianCalendarAdapter;
-import org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateXMLGregorianCalendarAdapter;
-import org.apache.isis.schema.utils.jaxbadapters.JodaLocalTimeXMLGregorianCalendarAdapter;
-
-public final class ActionInvocationMementoDtoUtils {
-
-    //region > static
-    private static final Function<ParamDto, String> PARAM_DTO_TO_NAME = new Function<ParamDto, String>() {
-        @Override public String apply(final ParamDto input) {
-            return input.getParameterName();
-        }
-    };
-    private static final Function<ParamDto, ValueType> PARAM_DTO_TO_TYPE = new Function<ParamDto, ValueType>() {
-        @Override public ValueType apply(final ParamDto input) {
-            return input.getParameterType();
-        }
-    };
-    private static JAXBContext jaxbContext;
-    private static JAXBContext getJaxbContext() {
-        if(jaxbContext == null) {
-            try {
-                jaxbContext = JAXBContext.newInstance(ActionInvocationMementoDto.class);
-            } catch (JAXBException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return jaxbContext;
-    }
-    //endregion
-
-    public static ActionInvocationMementoDto newDto() {
-        return new ActionInvocationMementoDto();
-    }
-
-    //region > actionIdentifier, target
-
-    public static void setMetadata(
-            final ActionInvocationMementoDto aim,
-            final UUID transactionId,
-            final int sequence,
-            final Timestamp timestamp,
-            final String targetClass,
-            final String targetAction,
-            final String actionIdentifier,
-            final String targetObjectType,
-            final String targetObjectIdentifier,
-            final String title,
-            final String user) {
-        ActionInvocationMementoDto.Metadata metadata = aim.getMetadata();
-        if(metadata == null) {
-            metadata = new ActionInvocationMementoDto.Metadata();
-            aim.setMetadata(metadata);
-        }
-
-        metadata.setTransactionId(transactionId.toString());
-        metadata.setSequence(sequence);
-        metadata.setTimestamp(JavaSqlTimestampXmlGregorianCalendarAdapter.print(timestamp));
-
-        metadata.setTargetClass(targetClass);
-        metadata.setTargetAction(targetAction);
-        metadata.setActionIdentifier(actionIdentifier);
-
-        final OidDto target = new OidDto();
-        target.setObjectType(targetObjectType);
-        target.setObjectIdentifier(targetObjectIdentifier);
-        metadata.setTarget(target);
-
-        metadata.setTitle(title);
-        metadata.setUser(user);
-   }
-
-
-    //endregion
-
-    //region > addArgValue, addArgReference
-    public static boolean addArgValue(
-            final ActionInvocationMementoDto aim,
-            final String parameterName,
-            final Class<?> parameterType,
-            final Object arg) {
-
-        ParamDto paramDto = null;
-        if(parameterType == String.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.STRING, arg);
-        } else
-        if(parameterType == byte.class || parameterType == Byte.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.BYTE, arg);
-        } else
-        if(parameterType == short.class || parameterType == Short.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.SHORT, arg);
-        }else
-        if(parameterType == int.class || parameterType == Integer.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.INT, arg);
-        }else
-        if(parameterType == long.class || parameterType == Long.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.LONG, arg);
-        }else
-        if(parameterType == char.class || parameterType == Character.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.CHAR, arg);
-        }else
-        if(parameterType == boolean.class || parameterType == Boolean.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.BOOLEAN, arg);
-        }else
-        if(parameterType == float.class || parameterType == Float.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.FLOAT, arg);
-        }else
-        if(parameterType == double.class || parameterType == Double.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.DOUBLE, arg);
-        }else
-        if(parameterType == BigInteger.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.BIG_INTEGER, arg);
-        }else
-        if(parameterType == BigDecimal.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.BIG_DECIMAL, arg);
-        }else
-        if(parameterType == DateTime.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.JODA_DATE_TIME, arg);
-        }else
-        if(parameterType == LocalDateTime.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_DATE_TIME, arg);
-        }else
-        if(parameterType == LocalDate.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_DATE, arg);
-        }else
-        if(parameterType == LocalTime.class) {
-            paramDto = newParamDto(aim, parameterName, ValueType.JODA_LOCAL_TIME, arg);
-        }
-
-        if(paramDto != null) {
-            final ValueDto valueDto = valueDtoFor(paramDto);
-            setValue(valueDto, parameterType, arg);
-            return true;
-        }
-
-        // none of the supported value types
-        return false;
-    }
-
-
-    public static void addArgReference(
-            final ActionInvocationMementoDto aim,
-            final String parameterName,
-            final Bookmark bookmark) {
-        final ParamDto paramDto = newParamDto(aim, parameterName, ValueType.REFERENCE, bookmark);
-        final ValueDto valueDto = valueDtoFor(paramDto);
-        OidDto argValue = asOidDto(bookmark);
-        valueDto.setReference(argValue);
-    }
-
-
-    private static OidDto asOidDto(final Bookmark reference) {
-        OidDto argValue;
-        if(reference != null) {
-            argValue = new OidDto();
-            argValue.setObjectType(reference.getObjectType());
-            argValue.setObjectState(bookmarkObjectStateOf(reference));
-            argValue.setObjectIdentifier(reference.getIdentifier());
-        } else {
-            argValue = null;
-        }
-        return argValue;
-    }
-
-    private static BookmarkObjectState bookmarkObjectStateOf(final Bookmark reference) {
-        switch(reference.getObjectState()) {
-        case PERSISTENT: return BookmarkObjectState.PERSISTENT;
-        case TRANSIENT: return BookmarkObjectState.TRANSIENT;
-        case VIEW_MODEL: return BookmarkObjectState.VIEW_MODEL;
-        }
-        throw new IllegalArgumentException(String.format("reference.objectState '%s' not recognized", reference.getObjectState()));
-    }
-
-    private static ParamDto newParamDto(
-            final ActionInvocationMementoDto aim,
-            final String parameterName,
-            final ValueType parameterType, final Object value) {
-        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderAutoCreate(aim);
-        final ParamDto paramDto = newParamDto(parameterName, parameterType);
-        paramDto.setNull(value == null);
-        addParamNum(params, paramDto);
-        return paramDto;
-    }
-
-    // lazily creates if required
-    private static ValueDto valueDtoFor(final ParamDto paramDto) {
-        ValueDto valueDto = paramDto.getValue();
-        if(valueDto == null) {
-            valueDto = new ValueDto();
-        }
-        paramDto.setValue(valueDto);
-        return valueDto;
-    }
-
-    private static ParamDto newParamDto(final String parameterName, final ValueType parameterType) {
-        final ParamDto argDto = new ParamDto();
-        argDto.setParameterName(parameterName);
-        argDto.setParameterType(parameterType);
-        return argDto;
-    }
-
-    //endregion
-
-    //region > addReturnValue, addReturnReference
-    public static boolean addReturnValue(
-            final ActionInvocationMementoDto aim,
-            final Class<?> returnType,
-            final Object returnVal) {
-        final ValueDto valueDto = returnValueDtoFor(aim);
-        return setValue(valueDto, returnType, returnVal);
-    }
-
-    public static void addReturnReference(
-            final ActionInvocationMementoDto aim,
-            final Bookmark bookmark) {
-        final ValueDto valueDto = returnValueDtoFor(aim);
-        OidDto argValue = asOidDto(bookmark);
-        valueDto.setReference(argValue);
-    }
-
-    //endregion
-
-
-
-
-    //region > getNumberOfParameters, getParameters, getParameterNames, getParameterTypes
-    public static int getNumberOfParameters(final ActionInvocationMementoDto aim) {
-        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderElseThrow(aim);
-        if(params == null) {
-            return 0;
-        }
-        return params.getNum();
-    }
-    public static List<ParamDto> getParameters(final ActionInvocationMementoDto aim) {
-        final ActionInvocationMementoDto.Payload.Parameters params = getParametersHolderElseThrow(aim);
-        final int parameterNumber = getNumberOfParameters(aim);
-        final List<ParamDto> paramDtos = Lists.newArrayList();
-        for (int i = 0; i < parameterNumber; i++) {
-            final ParamDto paramDto = params.getParam().get(i);
-            paramDtos.add(paramDto);
-        }
-        return Collections.unmodifiableList(paramDtos);
-    }
-    public static List<String> getParameterNames(final ActionInvocationMementoDto aim) {
-        return immutableList(Iterables.transform(getParameters(aim), PARAM_DTO_TO_NAME));
-    }
-    public static List<ValueType> getParameterTypes(final ActionInvocationMementoDto aim) {
-        return immutableList(Iterables.transform(getParameters(aim), PARAM_DTO_TO_TYPE));
-    }
-    //endregion
-
-    //region > getParameter, getParameterName, getParameterType
-    public static ParamDto getParameter(final ActionInvocationMementoDto aim, final int paramNum) {
-        final int parameterNumber = getNumberOfParameters(aim);
-        if(paramNum > parameterNumber) {
-            throw new IllegalArgumentException(String.format("No such parameter %d (the memento has %d parameters)", paramNum, parameterNumber));
-        }
-        final List<ParamDto> parameters = getParameters(aim);
-        return parameters.get(paramNum);
-    }
-
-    public static ValueDto getParameterValue(final ActionInvocationMementoDto aim, final int paramNum) {
-        final ParamDto paramDto = getParameter(aim, paramNum);
-        return valueDtoFor(paramDto);
-    }
-
-
-    public static String getParameterName(final ActionInvocationMementoDto aim, final int paramNum) {
-        return PARAM_DTO_TO_NAME.apply(getParameter(aim, paramNum));
-    }
-    public static ValueType getParameterType(final ActionInvocationMementoDto aim, final int paramNum) {
-        return PARAM_DTO_TO_TYPE.apply(getParameter(aim, paramNum));
-    }
-    public static boolean isNull(final ActionInvocationMementoDto aim, int paramNum) {
-        final ParamDto paramDto = getParameter(aim, paramNum);
-        return paramDto.isNull();
-    }
-    //endregion
-
-    //region > getArg
-    public static <T> T getArg(final ActionInvocationMementoDto aim, int paramNum, Class<T> cls) {
-        final ParamDto paramDto = getParameter(aim, paramNum);
-        if(paramDto.isNull()) {
-            return null;
-        }
-        final ValueDto valueDto = valueDtoFor(paramDto);
-        switch(paramDto.getParameterType()) {
-        case STRING:
-            return (T) valueDto.getString();
-        case BYTE:
-            return (T) valueDto.getByte();
-        case SHORT:
-            return (T) valueDto.getShort();
-        case INT:
-            return (T) valueDto.getInt();
-        case LONG:
-            return (T) valueDto.getLong();
-        case FLOAT:
-            return (T) valueDto.getFloat();
-        case DOUBLE:
-            return (T) valueDto.getDouble();
-        case BOOLEAN:
-            return (T) valueDto.isBoolean();
-        case CHAR:
-            final String aChar = valueDto.getChar();
-            if(Strings.isNullOrEmpty(aChar)) { return null; }
-            return (T) (Object)aChar.charAt(0);
-        case BIG_DECIMAL:
-            return (T) valueDto.getBigDecimal();
-        case BIG_INTEGER:
-            return (T) valueDto.getBigInteger();
-        case JODA_DATE_TIME:
-            return (T) JodaDateTimeXMLGregorianCalendarAdapter.parse(valueDto.getDateTime());
-        case JODA_LOCAL_DATE:
-            return (T) JodaLocalDateXMLGregorianCalendarAdapter.parse(valueDto.getLocalDate());
-        case JODA_LOCAL_DATE_TIME:
-            return (T) JodaLocalDateTimeXMLGregorianCalendarAdapter.parse(valueDto.getLocalDateTime());
-        case JODA_LOCAL_TIME:
-            return (T) JodaLocalTimeXMLGregorianCalendarAdapter.parse(valueDto.getLocalTime());
-        case REFERENCE:
-            return (T) valueDto.getReference();
-        }
-        throw new IllegalStateException("Parameter type was not recognised (possible bug)");
-    }
-    //endregion
-
-    //region > marshalling
-    public static ActionInvocationMementoDto fromXml(Reader reader) {
-        Unmarshaller un = null;
-        try {
-            un = getJaxbContext().createUnmarshaller();
-            return (ActionInvocationMementoDto) un.unmarshal(reader);
-        } catch (JAXBException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public static ActionInvocationMementoDto fromXml(
-            final Class<?> contextClass,
-            final String resourceName,
-            final Charset charset) throws IOException {
-        final URL url = Resources.getResource(contextClass, resourceName);
-        final String s = Resources.toString(url, charset);
-        return fromXml(new StringReader(s));
-    }
-
-    public static String toXml(final ActionInvocationMementoDto aim) {
-        final CharArrayWriter caw = new CharArrayWriter();
-        toXml(aim, caw);
-        return caw.toString();
-    }
-
-    public static void toXml(final ActionInvocationMementoDto aim, final Writer writer) {
-        Marshaller m = null;
-        try {
-            m = getJaxbContext().createMarshaller();
-            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-            m.marshal(aim, writer);
-        } catch (JAXBException e) {
-            throw new RuntimeException(e);
-        }
-    }
-    //endregion
-
-    //region > debugging
-    public static void dump(final ActionInvocationMementoDto aim, final PrintStream out) throws JAXBException {
-        out.println(toXml(aim));
-    }
-    //endregion
-
-    //region > helpers
-    private static void addParamNum(final ActionInvocationMementoDto.Payload.Parameters params, final ParamDto arg) {
-        params.getParam().add(arg);
-        Integer num = params.getNum();
-        if(num == null) {
-            num = 0;
-        }
-        params.setNum(num +1);
-    }
-
-    private static ActionInvocationMementoDto.Payload.Parameters getParametersHolderElseThrow(final ActionInvocationMementoDto aim) {
-        final ActionInvocationMementoDto.Payload payload = getPayloadElseThrow(aim);
-        final ActionInvocationMementoDto.Payload.Parameters parameters = payload.getParameters();
-        if(parameters == null) {
-            throw new IllegalStateException("No parameters have been added");
-        }
-        return parameters;
-    }
-
-    private static ActionInvocationMementoDto.Payload.Parameters getParametersHolderAutoCreate(final ActionInvocationMementoDto aim) {
-        final ActionInvocationMementoDto.Payload payload = getPayloadAutoCreate(aim);
-        ActionInvocationMementoDto.Payload.Parameters params = payload.getParameters();
-        if(params == null) {
-            params = new ActionInvocationMementoDto.Payload.Parameters();
-            payload.setParameters(params);
-        }
-        return params;
-    }
-
-    private static ValueDto returnValueDtoFor(final ActionInvocationMementoDto aim) {
-        final ActionInvocationMementoDto.Payload payload = getPayloadAutoCreate(aim);
-        ValueDto valueDto = payload.getReturn();
-        if(valueDto == null) {
-            valueDto = new ValueDto();
-            payload.setReturn(valueDto);
-        }
-        return valueDto;
-    }
-
-    private static ActionInvocationMementoDto.Payload getPayloadAutoCreate(final ActionInvocationMementoDto aim) {
-        ActionInvocationMementoDto.Payload payload = aim.getPayload();
-        if(payload == null) {
-            payload = new ActionInvocationMementoDto.Payload();
-            aim.setPayload(payload);
-        }
-        return payload;
-    }
-
-    private static ActionInvocationMementoDto.Payload getPayloadElseThrow(final ActionInvocationMementoDto aim) {
-        ActionInvocationMementoDto.Payload payload = aim.getPayload();
-        if(payload == null) {
-            throw new IllegalStateException("No payload has been added");
-        }
-        return payload;
-    }
-
-    private static <T> List<T> immutableList(final Iterable<T> transform) {
-        return Collections.unmodifiableList(
-                Lists.newArrayList(
-                        transform
-                )
-        );
-    }
-
-
-    private static boolean setValue(final ValueDto valueDto, final Class<?> type, final Object returnVal) {
-        if(type == String.class) {
-            final String argValue = (String) returnVal;
-            valueDto.setString(argValue);
-        } else
-        if(type == byte.class || type == Byte.class) {
-            final Byte argValue = (Byte) returnVal;
-            valueDto.setByte(argValue);
-        } else
-        if(type == short.class || type == Short.class) {
-            final Short argValue = (Short) returnVal;
-            valueDto.setShort(argValue);
-        }else
-        if(type == int.class || type == Integer.class) {
-            final Integer argValue = (Integer) returnVal;
-            valueDto.setInt(argValue);
-        }else
-        if(type == long.class || type == Long.class) {
-            final Long argValue = (Long) returnVal;
-            valueDto.setLong(argValue);
-        }else
-        if(type == char.class || type == Character.class) {
-            final Character argValue = (Character) returnVal;
-            valueDto.setChar("" + argValue);
-        }else
-        if(type == boolean.class || type == Boolean.class) {
-            final Boolean argValue = (Boolean) returnVal;
-            valueDto.setBoolean(argValue);
-        }else
-        if(type == float.class || type == Float.class) {
-            final Float argValue = (Float) returnVal;
-            valueDto.setFloat(argValue);
-        }else
-        if(type == double.class || type == Double.class) {
-            final Double argValue = (Double) returnVal;
-            valueDto.setDouble(argValue);
-        }else
-        if(type == BigInteger.class) {
-            final BigInteger argValue = (BigInteger) returnVal;
-            valueDto.setBigInteger(argValue);
-        }else
-        if(type == BigDecimal.class) {
-            final BigDecimal argValue = (BigDecimal) returnVal;
-            valueDto.setBigDecimal(argValue);
-        }else
-        if(type == DateTime.class) {
-            final DateTime argValue = (DateTime) returnVal;
-            valueDto.setDateTime(JodaDateTimeXMLGregorianCalendarAdapter.print(argValue));
-        }else
-        if(type == LocalDateTime.class) {
-            final LocalDateTime argValue = (LocalDateTime) returnVal;
-            valueDto.setLocalDateTime(JodaLocalDateTimeXMLGregorianCalendarAdapter.print(argValue));
-        }else
-        if(type == LocalDate.class) {
-            final LocalDate argValue = (LocalDate) returnVal;
-            valueDto.setLocalDate(JodaLocalDateXMLGregorianCalendarAdapter.print(argValue));
-        }else
-        if(type == LocalTime.class) {
-            final LocalTime argValue = (LocalTime) returnVal;
-            valueDto.setLocalTime(JodaLocalTimeXMLGregorianCalendarAdapter.print(argValue));
-        }else
-        {
-            // none of the supported value types
-            return false;
-        }
-        return true;
-    }
-
-    //endregion
-
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/schema/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
----------------------------------------------------------------------
diff --git a/core/schema/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java b/core/schema/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
deleted file mode 100644
index e88576a..0000000
--- a/core/schema/src/main/java/org/apache/isis/schema/utils/jaxbadapters/PersistentEntityAdapter.java
+++ /dev/null
@@ -1,68 +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.schema.utils.jaxbadapters;
-
-import javax.inject.Inject;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.bookmark.BookmarkService2;
-import org.apache.isis.schema.common.v1.BookmarkObjectState;
-import org.apache.isis.schema.common.v1.OidDto;
-
-public class PersistentEntityAdapter extends XmlAdapter<OidDto, Object> {
-
-    @Override
-    public Object unmarshal(final OidDto oidDto) throws Exception {
-
-        final String objectType = oidDto.getObjectType();
-        final String identifier = oidDto.getObjectIdentifier();
-        final Bookmark bookmark = new Bookmark(objectType, identifier);
-
-        return bookmarkService.lookup(bookmark, BookmarkService2.FieldResetPolicy.DONT_RESET);
-    }
-
-    @Override
-    public OidDto marshal(final Object domainObject) throws Exception {
-        if(domainObject == null) {
-            return null;
-        }
-        final Bookmark bookmark = getBookmarkService().bookmarkFor(domainObject);
-        final OidDto oidDto = new OidDto();
-        oidDto.setObjectIdentifier(bookmark.getIdentifier());
-        oidDto.setObjectState(convert(bookmark.getObjectState()));
-        oidDto.setObjectType(bookmark.getObjectType());
-        return oidDto;
-    }
-
-    private BookmarkObjectState convert(final Bookmark.ObjectState objectState) {
-        switch (objectState) {
-            case VIEW_MODEL:return BookmarkObjectState.VIEW_MODEL;
-            case TRANSIENT:return BookmarkObjectState.TRANSIENT;
-            case PERSISTENT:return BookmarkObjectState.PERSISTENT;
-        }
-        throw new IllegalArgumentException("Not recognized: " + objectState.name());
-    }
-
-    protected BookmarkService getBookmarkService() {
-        return bookmarkService;
-    }
-
-    @Inject
-    BookmarkService2 bookmarkService;
-}


[3/8] isis git commit: ISIS-1373: isis-core-applib now depends on isis-core-schema, rather than other way around. Moved JaxbServiceDefault to applib.

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/4967495f/core/schema/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
----------------------------------------------------------------------
diff --git a/core/schema/src/test/java/org/apache/isis/schema/utils/Roundtrip.java b/core/schema/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
deleted file mode 100644
index 20e64b7..0000000
--- a/core/schema/src/test/java/org/apache/isis/schema/utils/Roundtrip.java
+++ /dev/null
@@ -1,311 +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.schema.utils;
-
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.UUID;
-
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.joda.time.LocalTime;
-import org.junit.Test;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.schema.aim.v1.ActionInvocationMementoDto;
-import org.apache.isis.schema.common.v1.OidDto;
-import org.apache.isis.schema.common.v1.ValueType;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class Roundtrip {
-
-    @Test
-    public void happyCase() throws Exception {
-
-        // given
-        final ActionInvocationMementoDto aim = ActionInvocationMementoDtoUtils.newDto();
-
-        ActionInvocationMementoDtoUtils.setMetadata(
-                aim,
-                UUID.randomUUID(),
-                1,
-                new java.sql.Timestamp(new java.util.Date().getTime()),
-                "com.mycompany.myapp.Customer", "placeOrder", "com.mycompany.myapp.Customer#placeOrder",
-                "CUS", "12345", "John Customer", "freddyUser");
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aString", String.class, "Fred");
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullString", String.class, (String) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aByte", Byte.class, (Byte) (byte) 123);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullByte", Byte.class, (Byte) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aShort", Short.class, (Short) (short) 32123);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullShort", Short.class, (Short) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "anInt", Integer.class, 123454321);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullInt", Integer.class, (Integer) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aLong", Long.class, 1234567654321L);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullLong", Long.class, (Long) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aFloat", Float.class, 12345.6789F);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullFloat", Float.class, (Float) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aDouble", Double.class, 12345678.90123);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullDouble", Double.class, (Double) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBoolean", Boolean.class, true);
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBoolean", Boolean.class, (Boolean) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aChar", Character.class, 'x');
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullChar", Character.class, (Character) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBigInteger", java.math.BigInteger.class, new java.math.BigInteger("12345678901234567890"));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBigInteger", java.math.BigInteger.class, (java.math.BigInteger) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aBigDecimal", java.math.BigDecimal.class, new java.math.BigDecimal("12345678901234567890"));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullBigDecimal", java.math.BigDecimal.class, (java.math.BigDecimal) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaDateTime", org.joda.time.DateTime.class, new org.joda.time.DateTime(2015, 5, 23, 9, 54, 1));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaDateTime", org.joda.time.DateTime.class, (org.joda.time.DateTime) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalDate", org.joda.time.LocalDate.class, new org.joda.time.LocalDate(2015, 5, 23));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalDate", org.joda.time.LocalDate.class, (org.joda.time.LocalDate) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalDateTime", org.joda.time.LocalDateTime.class, new org.joda.time.LocalDateTime(2015, 5, 23, 9, 54, 1));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalDateTime", org.joda.time.LocalDateTime.class, (org.joda.time.LocalDateTime) null);
-
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "aJodaLocalTime", org.joda.time.LocalTime.class, new org.joda.time.LocalTime(9, 54, 1));
-        ActionInvocationMementoDtoUtils.addArgValue(aim, "nullJodaLocalTime", org.joda.time.LocalTime.class, (org.joda.time.LocalTime) null);
-
-        ActionInvocationMementoDtoUtils.addArgReference(aim, "aReference", new Bookmark("ORD", "12345"));
-        ActionInvocationMementoDtoUtils.addArgReference(aim, "nullReference", null);
-
-
-        // when
-        final CharArrayWriter caw = new CharArrayWriter();
-        ActionInvocationMementoDtoUtils.toXml(aim, caw);
-
-        ActionInvocationMementoDtoUtils.dump(aim, System.out);
-
-        final CharArrayReader reader = new CharArrayReader(caw.toCharArray());
-        final ActionInvocationMementoDto recreated = ActionInvocationMementoDtoUtils.fromXml(reader);
-
-
-        // then
-        assertThat(recreated.getMetadata().getActionIdentifier(), is(aim.getMetadata().getActionIdentifier()));
-        assertThat(recreated.getMetadata().getTarget().getObjectType(), is(aim.getMetadata().getTarget().getObjectType()));
-        assertThat(recreated.getMetadata().getTarget().getObjectIdentifier(), is(aim.getMetadata().getTarget().getObjectIdentifier()));
-
-
-        int param = 0;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aString"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.STRING));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, String.class), is("Fred"));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullString"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.STRING));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, String.class), is(nullValue()));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aByte"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BYTE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, Byte.class), is((byte) 123));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BYTE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullByte"));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aShort"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.SHORT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, Short.class), is((short) 32123));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullShort"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.SHORT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("anInt"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.INT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, int.class), is((int) 123454321));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullInt"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.INT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aLong"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.LONG));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, long.class), is((long) 1234567654321L));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullLong"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.LONG));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aFloat"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.FLOAT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, float.class), is((float) 12345.6789F));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullFloat"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.FLOAT));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aDouble"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.DOUBLE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, double.class), is(12345678.90123));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullDouble"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.DOUBLE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBoolean"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BOOLEAN));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, boolean.class), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBoolean"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BOOLEAN));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aChar"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.CHAR));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, char.class), is('x'));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullChar"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.CHAR));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBigInteger"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BIG_INTEGER));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, BigInteger.class), is(new java.math.BigInteger("12345678901234567890")));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBigInteger"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BIG_INTEGER));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aBigDecimal"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BIG_DECIMAL));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, BigDecimal.class), is(new java.math.BigDecimal("12345678901234567890")));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullBigDecimal"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.BIG_DECIMAL));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaDateTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_DATE_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        // bit hacky... regular comparison fails but toString() works... must be some additional data that differs, not sure what tho'
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, DateTime.class).toString(), is(new DateTime(2015, 5, 23, 9, 54, 1).toString()));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaDateTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_DATE_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));;
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalDate"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_DATE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        final LocalDate actual = ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalDate.class);
-        final LocalDate expected = new LocalDate(2015, 5, 23);
-        assertThat(actual, equalTo(expected));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalDate"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_DATE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalDateTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_DATE_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalDateTime.class), is(new org.joda.time.LocalDateTime(2015, 5, 23, 9, 54, 1)));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalDateTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_DATE_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aJodaLocalTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, LocalTime.class), is(new org.joda.time.LocalTime(9, 54, 1)));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullJodaLocalTime"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.JODA_LOCAL_TIME));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("aReference"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.REFERENCE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(false));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, OidDto.class).getObjectType(), is("ORD"));
-        assertThat(ActionInvocationMementoDtoUtils.getArg(recreated, param, OidDto.class).getObjectIdentifier(), is("12345"));
-
-        param++;
-        assertThat(ActionInvocationMementoDtoUtils.getParameterName(recreated, param), is("nullReference"));
-        assertThat(ActionInvocationMementoDtoUtils.getParameterType(recreated, param), is(ValueType.REFERENCE));
-        assertThat(ActionInvocationMementoDtoUtils.isNull(recreated, param), is(true));
-
-        param++;
-//        final int expected = param;
-//        assertThat(recreated.getParameters().getNum(), is(expected);
-//        assertThat(recreated.getParameters().getParam().size(), is(expected);
-//        assertThat(ActionInvocationMementoDtoUtils.getNumberOfParameters(recreated), is(expected);
-
-    }
-
-}


[2/8] isis git commit: ISIS-1368: added new PublishingService2 API. Also updated documentation.

Posted by da...@apache.org.
ISIS-1368: added new PublishingService2 API.   Also updated documentation.


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

Branch: refs/heads/ISIS-1291
Commit: efdb1d461ad76034b537bc398d66db22146097ad
Parents: 565ac81
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Apr 11 19:15:48 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Apr 11 19:15:48 2016 +0100

----------------------------------------------------------------------
 .../main/asciidoc/guides/_rgcms_schema-aim.adoc |  4 +-
 .../guides/_rgsvc_spi_PublishingService.adoc    | 12 +++---
 .../services/publish/PublishingService.java     |  9 +++--
 .../services/publish/PublishingService2.java    | 42 ++++++++++++++++++++
 .../system/transaction/IsisTransaction.java     |  8 ++--
 5 files changed, 60 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/efdb1d46/adocs/documentation/src/main/asciidoc/guides/_rgcms_schema-aim.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgcms_schema-aim.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgcms_schema-aim.adoc
index 37fdfb6..29f9bb3 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgcms_schema-aim.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgcms_schema-aim.adoc
@@ -92,6 +92,6 @@ be serialized to/from using the same `ActionInvocationMementoDtoUtils` class.
 
 [NOTE]
 ====
-As of `1.11.0` this schema is not used directly by the framework; in particular `Command#setMemento(...)` sets a similar
-but less formal XML structure.  This may change in the future.
+As of `1.11.0` through `1.12.1` this schema is not used directly by the framework; in particular
+`Command#setMemento(...)` sets a similar but less formal XML structure.  This may change in the future.
 ====

http://git-wip-us.apache.org/repos/asf/isis/blob/efdb1d46/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_PublishingService.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_PublishingService.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_PublishingService.adoc
index a67aad5..10ca7d8 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_PublishingService.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgsvc_spi_PublishingService.adoc
@@ -6,7 +6,7 @@
 
 
 
-The `PublishingService` is intended for coarse-grained publish/subscribe for system-to-system interactions, from Apache Isis to some other system.  Here the only events published are those that action invocations and of changed objects.  A typical use case is to publish onto a pub/sub bus such as link:http://activemq.apache.org/[ActiveMQ] with link:http://camel.apache.org[Camel] to keep other systems up to date.
+The `PublishingService2` API (the `PublishingService2` subinterface has been added in `1.13.0-SNAPSHOT`) is intended for coarse-grained publish/subscribe for system-to-system interactions, from Apache Isis to some other system.  Here the only events published are those that action invocations and of changed objects.  A typical use case is to publish onto a pub/sub bus such as link:http://activemq.apache.org/[ActiveMQ] with link:http://camel.apache.org[Camel] to keep other systems up to date.
 
 
 
@@ -16,18 +16,20 @@ The SPI defined by the service is:
 
 [source,java]
 ----
-public interface PublishingService {
+public interface PublishingService2 {
     public void publish(
         EventMetadata metadata,                                 // <1>
         EventPayload payload);                                  // <2>
+    public void republish(Command);                             // <3>
     @Deprecated
-    @Programmatic
-    void setEventSerializer(EventSerializer eventSerializer);   // <3>
+    void setEventSerializer(EventSerializer eventSerializer);   // <4>
 }
 ----
 <1> standard metadata about the event, such as the user, the xref:rgcms.adoc#_rgcms_classes_mixins_HasTransactionId[`transactionId`], date/time etc
 <2> for published actions, an `EventPayloadForActionInvocation` (or subclass thereof); for published objects, an `EventPayloadForObjectChanged` (or subclass thereof)
-<3> injects in the xref:rgsvc.adoc#_rgsvc_spi_EventSerializer[`EventSerializer`] service.  This is deprecated because not every implementation is required to use an `EventSerializer` so its inclusion within the SPI of `PublishingService` was in retrospect a mistake.
+<3> (`1.13.0-SNAPSHOT`) allow a `Command` representing an action to be republished by the application (eg if an error occurred).  Note that this relies upon the `Command#getMemento()` to
+return serialized xref:rgcms.adoc#_rgcms_schema-aim[action invocation memento].
+<4> injects in the xref:rgsvc.adoc#_rgsvc_spi_EventSerializer[`EventSerializer`] service.  This is deprecated because not every implementation is required to use an `EventSerializer` so its inclusion within the SPI of `PublishingService` was in retrospect a mistake.
 
 
 Typically implementations will use the injected `EventSerializer` to convert the metadata and payload into a form to be published:

http://git-wip-us.apache.org/repos/asf/isis/blob/efdb1d46/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
index a064460..a5f4277 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
@@ -20,7 +20,7 @@ package org.apache.isis.applib.services.publish;
 
 
 import org.apache.isis.applib.annotation.Hidden;
-
+import org.apache.isis.applib.annotation.Programmatic;
 
 /**
  * Will be called whenever an publishable entity has changed its state, or an published action has been invoked.
@@ -40,10 +40,10 @@ import org.apache.isis.applib.annotation.Hidden;
  */
 public interface PublishingService {
     
-    @Hidden
-    public void publish(EventMetadata metadata, EventPayload payload);
+    @Programmatic
+    void publish(EventMetadata metadata, EventPayload payload);
     
-    public static class Stderr implements PublishingService {
+    class Stderr implements PublishingService {
 
         private EventSerializer eventSerializer = new EventSerializer.Simple();
 
@@ -63,6 +63,7 @@ public interface PublishingService {
     /**
      * @deprecated  - not every implementation will use an {@link EventSerializer}, so this ought not to have been defined in the interface.
      */
+    @Programmatic
     @Deprecated
     void setEventSerializer(EventSerializer eventSerializer);
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/efdb1d46/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
new file mode 100644
index 0000000..5c56216
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.applib.services.publish;
+
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.services.command.Command;
+
+public interface PublishingService2 extends PublishingService {
+
+    /**
+     * To support implementations that allow the republishing of commands, eg onto an JMS message bus.
+     */
+    @Programmatic
+    void republish(final Command command);
+    
+    class Stderr extends PublishingService.Stderr implements PublishingService2 {
+
+        @Override
+        public void republish(Command command) {
+            System.err.println(command.getMemento());
+        }
+
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/isis/blob/efdb1d46/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index dcd9ef6..f5e57d3 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -684,10 +684,10 @@ public class IsisTransaction implements TransactionScopedComponent {
             final String currentUser,
             final Timestamp timestampEpoch,
             final String title,
-            String targetClass,
-            String targetAction,
-            Bookmark target,
-            String memberIdentifier,
+            final String targetClass,
+            final String targetAction,
+            final Bookmark target,
+            final String memberIdentifier,
             final List<String> parameterNames,
             final List<Class<?>> parameterTypes,
             final Class<?> returnType) {


[5/8] isis git commit: ISIS-1370: removing concept of payload factories from PublishingService.

Posted by da...@apache.org.
ISIS-1370: removing concept of payload factories from PublishingService.


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

Branch: refs/heads/ISIS-1291
Commit: fec5e920899df6f95146a21b3fb4ef7b92180b7b
Parents: 4967495
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Apr 12 00:27:06 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 12 00:27:06 2016 +0100

----------------------------------------------------------------------
 .../src/main/asciidoc/guides/_rgant-Action.adoc |  2 +-
 .../asciidoc/guides/_rgant-DomainObject.adoc    |  2 +-
 .../apache/isis/applib/annotation/Action.java   |  8 ++-
 .../isis/applib/annotation/DomainObject.java    |  7 +--
 .../PublishingPayloadFactoryForAction.java      |  9 ++++
 .../PublishingPayloadFactoryForObject.java      |  9 ++++
 .../applib/services/publish/EventPayload.java   |  3 ++
 .../EventPayloadForActionInvocation.java        |  3 ++
 .../publish/EventPayloadForObjectChanged.java   |  3 ++
 .../services/publish/PublishingService.java     |  9 +++-
 .../services/publish/PublishingService2.java    | 11 ++--
 ...shingServiceWithDefaultPayloadFactories.java | 55 --------------------
 .../system/transaction/IsisTransaction.java     | 46 +++-------------
 13 files changed, 57 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/adocs/documentation/src/main/asciidoc/guides/_rgant-Action.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant-Action.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant-Action.adoc
index bde910d..6531286 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgant-Action.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant-Action.adoc
@@ -67,7 +67,7 @@ Currently this is only supported for no-arg actions.
 |`publishing-` +
 `PayloadFactory()`
 |subtype of `PublishingPayloadFactory-` `ForAction` (none)
-|specifies that a custom implementation of `PublishingPayloadFactoryForAction` be used to create the (payload of the) published event representing the action invocation
+|(deprecated in `1.13.0-SNAPSHOT`); specifies that a custom implementation of `PublishingPayloadFactoryForAction` be used to create the (payload of the) published event representing the action invocation
 
 |xref:rgant.adoc#_rgant-Action_restrictTo[`restrictTo()`]
 |`NO_RESTRICTIONS`,`PROTOTYPING` +

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject.adoc
index 7a0b7e1..3590df5 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject.adoc
@@ -84,7 +84,7 @@ The table below summarizes the annotation's attributes.
 |`publishing-` +
 `PayloadFactory()`
 |subtype of `PublishingPayloadFactory-` `ForObject` (none)
-|specifies that a custom implementation of `PublishingPayloadFactoryForObject` be used to create the (payload of the) published event representing the change to the object
+|(deprecated in `1.13.0-SNAPSHOT`); specifies that a custom implementation of `PublishingPayloadFactoryForObject` be used to create the (payload of the) published event representing the change to the object
 
 |xref:rgant.adoc#_rgant-DomainObject_removingLifecycleEvent[`removing-` +
 `LifecycleEvent()`]

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
index b94926b..7892db8 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Action.java
@@ -25,6 +25,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
+import org.apache.isis.applib.services.publish.EventMetadata;
+import org.apache.isis.applib.services.publish.EventPayload;
 
 /**
  * Domain semantics for domain object collection.
@@ -156,8 +158,10 @@ public @interface Action {
      */
     Publishing publishing() default Publishing.AS_CONFIGURED;
 
-
-    // TODO: factor out PayloadFactory.Default so similar to interaction
+    /**
+     * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
+     */
+    @Deprecated
     Class<? extends PublishingPayloadFactoryForAction> publishingPayloadFactory() default PublishingPayloadFactoryForAction.class;
 
 

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/annotation/DomainObject.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/DomainObject.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/DomainObject.java
index 0621def..87d5001 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/DomainObject.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/DomainObject.java
@@ -31,6 +31,8 @@ import org.apache.isis.applib.services.eventbus.ObjectPersistingEvent;
 import org.apache.isis.applib.services.eventbus.ObjectRemovingEvent;
 import org.apache.isis.applib.services.eventbus.ObjectUpdatedEvent;
 import org.apache.isis.applib.services.eventbus.ObjectUpdatingEvent;
+import org.apache.isis.applib.services.publish.EventMetadata;
+import org.apache.isis.applib.services.publish.EventPayload;
 
 /**
  * Domain semantics for domain objects (entities and view models; for services see {@link org.apache.isis.applib.annotation.DomainService}).
@@ -71,10 +73,9 @@ public @interface DomainObject {
      *     If not specified then a default implementation will be used.
      * </p>
      *
-     * <p>
-     *     TODO: ??? factor out PayloadFactory.Default so similar to design similar to @Action(domainEvent=...)
-     * </p>
+     * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
      */
+    @Deprecated
     Class<? extends PublishingPayloadFactoryForObject> publishingPayloadFactory() default PublishingPayloadFactoryForObject.class;
 
 

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForAction.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForAction.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForAction.java
index 4a3a93e..f62ef0f 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForAction.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForAction.java
@@ -20,10 +20,19 @@ package org.apache.isis.applib.annotation;
 
 import java.util.List;
 import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.publish.EventMetadata;
 import org.apache.isis.applib.services.publish.EventPayload;
 
+/**
+ * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
+ */
+@Deprecated
 public interface PublishingPayloadFactoryForAction {
 
+    /**
+     * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
+     */
+    @Deprecated
     @Programmatic
     public EventPayload payloadFor(Identifier actionIdentifier, Object target, List<Object> arguments, Object result);
 

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForObject.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForObject.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForObject.java
index fb3df0d..df5f9ad 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForObject.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/PublishingPayloadFactoryForObject.java
@@ -18,10 +18,19 @@
  */
 package org.apache.isis.applib.annotation;
 
+import org.apache.isis.applib.services.publish.EventMetadata;
 import org.apache.isis.applib.services.publish.EventPayload;
 
+/**
+ * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
+ */
+@Deprecated
 public interface PublishingPayloadFactoryForObject {
 
+    /**
+     * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
+     */
+    @Deprecated
     @Programmatic
     public EventPayload payloadFor(Object changedObject, PublishingChangeKind publishingChangeKind);
 

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayload.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayload.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayload.java
index 4dd96e1..740911c 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayload.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayload.java
@@ -43,7 +43,10 @@ import org.apache.isis.applib.annotation.Programmatic;
  * </ul>
  * 
  * @see EventMetadata
+ *
+ * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
  */
+@Deprecated
 public interface EventPayload {
 
     /**

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForActionInvocation.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForActionInvocation.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForActionInvocation.java
index b0f4a26..7b5c8b2 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForActionInvocation.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForActionInvocation.java
@@ -33,7 +33,10 @@ import org.apache.isis.applib.annotation.Programmatic;
  * <p>
  * This class is annotated as a domain object for the benefit of the
  * <tt>RestfulObjectsSpecEventSerializer</tt>.
+ *
+ * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
  */
+@Deprecated
 @NotPersistable
 public class EventPayloadForActionInvocation<T> implements EventPayload {
     

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForObjectChanged.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForObjectChanged.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForObjectChanged.java
index 38f9c6b..859c817 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForObjectChanged.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/EventPayloadForObjectChanged.java
@@ -28,7 +28,10 @@ import org.apache.isis.applib.annotation.Programmatic;
  * <p>
  * This class is annotated as a domain object for the benefit of the
  * <tt>RestfulObjectsSpecEventSerializer</tt>.
+ *
+ * @deprecated - {@link org.apache.isis.applib.services.publish.PublishingService#publish(EventMetadata, EventPayload)} replaced by {@link org.apache.isis.applib.services.publish.PublishingService2#publish(EventMetadata)}   .
  */
+@Deprecated
 @NotPersistable
 public class EventPayloadForObjectChanged<T> implements EventPayload {
     

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
index a5f4277..219740dd 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService.java
@@ -39,7 +39,14 @@ import org.apache.isis.applib.annotation.Programmatic;
  * To use either service, must include on the classpath and also register the service (eg in <tt>isis.properties</tt>).
  */
 public interface PublishingService {
-    
+
+    /**
+     * @deprecated - replaced by simpler {@link PublishingService2#publish(EventMetadata)}.
+     *
+     * @param metadata
+     * @param payload - will always be <tt>null</tt>; will not be called if service implements {@link PublishingService2}.
+     */
+    @Deprecated
     @Programmatic
     void publish(EventMetadata metadata, EventPayload payload);
     

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
index 5c56216..c046bcf 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/publish/PublishingService2.java
@@ -23,20 +23,15 @@ import org.apache.isis.applib.services.command.Command;
 
 public interface PublishingService2 extends PublishingService {
 
+    @Programmatic
+    void publish(EventMetadata metadata);
+
     /**
      * To support implementations that allow the republishing of commands, eg onto an JMS message bus.
      */
     @Programmatic
     void republish(final Command command);
     
-    class Stderr extends PublishingService.Stderr implements PublishingService2 {
-
-        @Override
-        public void republish(Command command) {
-            System.err.println(command.getMemento());
-        }
-
-    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
index 2dc6ab0..f794e65 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PublishingServiceWithDefaultPayloadFactories.java
@@ -27,13 +27,8 @@ import com.google.common.collect.Lists;
 
 import org.apache.isis.applib.annotation.PublishedAction;
 import org.apache.isis.applib.annotation.PublishedObject;
-import org.apache.isis.applib.annotation.PublishedObject.ChangeKind;
-import org.apache.isis.applib.services.publish.EventMetadata;
-import org.apache.isis.applib.services.publish.EventPayload;
-import org.apache.isis.applib.services.publish.ObjectStringifier;
 import org.apache.isis.applib.services.publish.PublishingService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet.CurrentInvocation;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 
@@ -43,10 +38,6 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
  */
 public class PublishingServiceWithDefaultPayloadFactories {
 
-    private final PublishingService publishingService;
-    private final PublishedObject.PayloadFactory defaultObjectPayloadFactory;
-    private final PublishedAction.PayloadFactory defaultActionPayloadFactory;
-
     private final static Function<ObjectAdapter, ObjectAdapter> NOT_DESTROYED_ELSE_EMPTY = new Function<ObjectAdapter, ObjectAdapter>() {
         public ObjectAdapter apply(ObjectAdapter adapter) {
             if(adapter == null) {
@@ -68,52 +59,6 @@ public class PublishingServiceWithDefaultPayloadFactories {
 
     };
     
-    public PublishingServiceWithDefaultPayloadFactories (
-            final PublishingService publishingService, 
-            final PublishedObject.PayloadFactory defaultObjectPayloadFactory, 
-            final PublishedAction.PayloadFactory defaultActionPayloadFactory) {
-        this.publishingService = publishingService;
-        this.defaultObjectPayloadFactory = defaultObjectPayloadFactory;
-        this.defaultActionPayloadFactory = defaultActionPayloadFactory;
-    }
-
-    public void publishObject(
-            final PublishedObject.PayloadFactory payloadFactoryIfAny, 
-            final EventMetadata metadata, 
-            final ObjectAdapter changedAdapter, 
-            final ChangeKind changeKind, 
-            final ObjectStringifier stringifier) {
-        final PublishedObject.PayloadFactory payloadFactoryToUse = 
-                payloadFactoryIfAny != null
-                ? payloadFactoryIfAny
-                : defaultObjectPayloadFactory;
-        final EventPayload payload = payloadFactoryToUse.payloadFor(
-                ObjectAdapter.Util.unwrap(undeletedElseEmpty(changedAdapter)), changeKind);
-        payload.withStringifier(stringifier);
-        publishingService.publish(metadata, payload);
-    }
-
-    public void publishAction(
-            final PublishedAction.PayloadFactory payloadFactoryIfAny, 
-            final EventMetadata metadata, 
-            final CurrentInvocation currentInvocation, 
-            final ObjectStringifier stringifier) {
-        final PublishedAction.PayloadFactory payloadFactoryToUse = 
-                payloadFactoryIfAny != null
-                ? payloadFactoryIfAny
-                : defaultActionPayloadFactory;
-        final ObjectAdapter target = currentInvocation.getTarget();
-        final ObjectAdapter result = currentInvocation.getResult();
-        final List<ObjectAdapter> parameters = currentInvocation.getParameters();
-        final EventPayload payload = payloadFactoryToUse.payloadFor(
-                currentInvocation.getIdentifiedHolder().getIdentifier(),
-                ObjectAdapter.Util.unwrap(undeletedElseEmpty(target)), 
-                ObjectAdapter.Util.unwrap(undeletedElseEmpty(parameters)), 
-                ObjectAdapter.Util.unwrap(undeletedElseEmpty(result)));
-        payload.withStringifier(stringifier);
-        publishingService.publish(metadata, payload);
-    }
-
     private static List<ObjectAdapter> undeletedElseEmpty(List<ObjectAdapter> parameters) {
         return Lists.newArrayList(Iterables.transform(parameters, NOT_DESTROYED_ELSE_EMPTY));
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/fec5e920/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index f5e57d3..ccd335a 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -71,7 +71,6 @@ import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.util.ToString;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
@@ -83,7 +82,6 @@ import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInv
 import org.apache.isis.core.metamodel.facets.actions.action.invocation.CommandUtil;
 import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
 import org.apache.isis.core.metamodel.facets.object.audit.AuditableFacet;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.facets.object.publishedobject.PublishedObjectFacet;
 import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
 import org.apache.isis.core.metamodel.spec.feature.Contributed;
@@ -94,7 +92,6 @@ import org.apache.isis.core.runtime.persistence.PersistenceConstants;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PublishingServiceWithDefaultPayloadFactories;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 
 import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
@@ -256,7 +253,7 @@ public class IsisTransaction implements TransactionScopedComponent {
     /**
      * could be null if none has been registered
      */
-    private final PublishingServiceWithDefaultPayloadFactories publishingService;
+    private final PublishingService publishingService;
 
     /**
      * Will be that of the {@link #command} if not <tt>null</tt>, otherwise will be randomly created.
@@ -316,7 +313,7 @@ public class IsisTransaction implements TransactionScopedComponent {
     // Publishing service
     // ///////////////////////////////////////////
 
-    private PublishingServiceWithDefaultPayloadFactories getPublishingServiceIfAny(ServicesInjector servicesInjector) {
+    private PublishingService getPublishingServiceIfAny(ServicesInjector servicesInjector) {
         final PublishingService publishingService = servicesInjector.lookupService(PublishingService.class);
         if(publishingService == null) {
             return null;
@@ -332,7 +329,7 @@ public class IsisTransaction implements TransactionScopedComponent {
             actionPayloadFactory = newDefaultActionPayloadFactory();
         }
         
-        return new PublishingServiceWithDefaultPayloadFactories(publishingService, objectPayloadFactory, actionPayloadFactory);
+        return publishingService;
     }
     
 
@@ -591,7 +588,7 @@ public class IsisTransaction implements TransactionScopedComponent {
                     actionTargetClass, actionTargetAction, actionTarget, actionMemberIdentifier,
                     // commandTargetClass, commandTargetAction, commandTarget, commandMemberIdentifier,
                     parameterNames, parameterTypes, returnType);
-            publishingService.publishAction(payloadFactory, metadata, currentInvocation, objectStringifier());
+            publishingService.publish(metadata, null);
         } finally {
             // ensures that cannot publish this action more than once
             ActionInvocationFacet.currentInvocation.set(null);
@@ -620,8 +617,7 @@ public class IsisTransaction implements TransactionScopedComponent {
             if(publishedObjectFacet == null) {
                 continue;
             }
-            final PublishedObject.PayloadFactory payloadFactory = publishedObjectFacet.value();
-        
+
             final RootOid enlistedAdapterOid = (RootOid) enlistedAdapter.getOid();
             final String oidStr = getOidMarshaller().marshal(enlistedAdapterOid);
             final String title = oidStr;
@@ -632,8 +628,8 @@ public class IsisTransaction implements TransactionScopedComponent {
             final Bookmark enlistedTarget = enlistedAdapterOid.asBookmark();
             
             final EventMetadata metadata = newEventMetadata(eventTypeFor, currentUser, timestamp, title, enlistedAdapterClass, null, enlistedTarget, null, null, null, null);
-        
-            publishingService.publishObject(payloadFactory, metadata, enlistedAdapter, changeKind, objectStringifier());
+
+            publishingService.publish(metadata, null);
         }
         return enlistedAdapters;
     }
@@ -651,34 +647,6 @@ public class IsisTransaction implements TransactionScopedComponent {
         throw new IllegalArgumentException("unknown ChangeKind '" + changeKind + "'");
     }
 
-    protected ObjectStringifier objectStringifier() {
-        if(objectStringifier == null) {
-            // lazily created; is threadsafe so no need to guard against race conditions
-            objectStringifier = new ObjectStringifier() {
-                @Override
-                public String toString(Object object) {
-                    if(object == null) {
-                        return null;
-                    }
-                    final ObjectAdapter adapter = IsisContext.getPersistenceSession().adapterFor(object);
-                    Oid oid = adapter.getOid();
-                    return oid != null? oid.enString(getOidMarshaller()): encodedValueOf(adapter);
-                }
-                private String encodedValueOf(ObjectAdapter adapter) {
-                    EncodableFacet facet = adapter.getSpecification().getFacet(EncodableFacet.class);
-                    return facet != null? facet.toEncodedString(adapter): adapter.toString();
-                }
-                @Override
-                public String classNameOf(Object object) {
-                    final ObjectAdapter adapter = getPersistenceSession().adapterFor(object);
-                    final String className = adapter.getSpecification().getFullIdentifier();
-                    return className;
-                }
-            };
-        }
-        return objectStringifier;
-    }
-
     private EventMetadata newEventMetadata(
             final EventType eventType,
             final String currentUser,