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 2014/02/02 19:15:54 UTC

[3/4] git commit: ISIS-672: introducing quartz scheduler job to todo app

ISIS-672: introducing quartz scheduler job to todo app

Refactorings in support of:
* removed ReifiableAction#sequence property
* removed the ReifiableActionPK class (since pk is no longer composite)
* renamed BackgroundTaskService to BackgroundActionService
  ditto for *Contributions and *Repository
* increased length of ReifiableActionJdo#exception property
* added  BackgroundActionServiceJdoContributions#siblingActions
* removed IsisTransaction#publishedEventSequence field, instead require that PublishingServiceJdo also has a ReifiableActionContext configured
  - ie force the generation of sequence # to be done by ReifiableActionContext
* new BackgroundService#newActionInvocationMemento to hide details of how the mementoservice is used by BackgroundServiceDefault

Quartz scheduler suport:
* AbstractIsisJob
* quartz servlet config in ToDo app
* example BackgroundActionExecutionJob


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

Branch: refs/heads/master
Commit: d78f24540986c30dec4e02b0ec3c38512cf37e69
Parents: 115971f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sun Feb 2 16:42:56 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sun Feb 2 16:42:56 2014 +0000

----------------------------------------------------------------------
 .../jdo/applib/service/JdoColumnLength.java     |   2 +-
 .../background/BackgroundActionServiceJdo.java  |  76 ++++++++++
 ...BackgroundActionServiceJdoContributions.java |  64 ++++++++
 .../BackgroundActionServiceJdoRepository.java   |  63 ++++++++
 .../background/BackgroundTaskServiceJdo.java    |  78 ----------
 .../BackgroundTaskServiceJdoContributions.java  |  47 ------
 .../BackgroundTaskServiceJdoRepository.java     |  56 -------
 .../service/publish/PublishedEventJdo.java      |   3 +-
 .../service/publish/PublishingServiceJdo.java   |  33 ++++
 .../reifiableaction/ReifiableActionJdo.java     |  65 +++-----
 .../reifiableaction/ReifiableActionJdoPK.java   | 102 -------------
 .../background/ActionInvocationMemento.java     |   4 +-
 .../background/BackgroundActionService.java     |  21 +++
 .../services/background/BackgroundService.java  |   3 +
 .../background/BackgroundTaskService.java       |  23 ---
 .../reifiableaction/ReifiableAction.java        |  24 +--
 .../reifiableaction/ReifiableActionDefault.java |  15 --
 .../background/BackgroundServiceDefault.java    |  30 ++--
 .../system/persistence/PersistenceSession.java  |   4 +-
 .../system/transaction/IsisTransaction.java     |  23 +--
 .../dom/src/main/java/dom/todo/ToDoItem.java    |   3 +-
 .../quickstart_wicket_restful_jdo/pom.xml       |  16 ++
 .../launch/ToDoApp-PROTOTYPE-jrebel.launch      |   2 +-
 .../webapp/pom.xml                              |  11 ++
 .../src/main/java/webapp/admin/Admin.java       |   4 +-
 .../java/webapp/scheduler/AbstractIsisJob.java  | 119 +++++++++++++++
 .../scheduler/BackgroundActionExecutionJob.java | 149 +++++++++++++++++++
 .../webapp/scheduler/SchedulerConstants.java    |  27 ++++
 .../webapp/scheduler/quartz-config.xml          |  41 +++++
 .../webapp/scheduler/quartz.properties          |   6 +
 .../src/main/webapp/WEB-INF/isis.properties     |   8 +-
 .../webapp/src/main/webapp/WEB-INF/web.xml      |  20 +++
 .../src/main/webapp/WEB-INF/isis.properties     |   8 +-
 33 files changed, 716 insertions(+), 434 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
index bd7de06..f8bea84 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
@@ -45,7 +45,7 @@ public final class JdoColumnLength {
         public final static int TARGET_CLASS = 50;
         public final static int TARGET_ACTION = 50;
         public final static int ARGUMENTS = 1024;
-        public final static int EXCEPTION = 2000;
+        public final static int EXCEPTION = 16000;
         public static final int NATURE = 20;
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdo.java
new file mode 100644
index 0000000..08973cd
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdo.java
@@ -0,0 +1,76 @@
+/**
+ *  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.objectstore.jdo.applib.service.background;
+
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.AbstractService;
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.services.background.ActionInvocationMemento;
+import org.apache.isis.applib.services.background.BackgroundActionService;
+import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
+import org.apache.isis.applib.services.reifiableaction.ReifiableAction.Nature;
+import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
+
+@Named("Background Actions")
+public class BackgroundActionServiceJdo extends AbstractService implements BackgroundActionService {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = LoggerFactory.getLogger(BackgroundActionServiceJdo.class);
+    
+    @Programmatic
+    @Override
+    public void schedule(
+            final ActionInvocationMemento aim, 
+            final ReifiableAction parentAction, 
+            final String targetClassName, 
+            final String targetActionName, 
+            final String targetArgs) {
+        
+        final UUID transactionId = UUID.randomUUID();
+        final String user = parentAction.getUser();
+
+        final ReifiableActionJdo backgroundAction = newTransientInstance(ReifiableActionJdo.class);
+
+        backgroundAction.setParent(parentAction);
+        
+        backgroundAction.setTransactionId(transactionId);
+
+        backgroundAction.setUser(user);
+        backgroundAction.setTimestamp(Clock.getTimeAsJavaSqlTimestamp());
+
+        backgroundAction.setNature(Nature.BACKGROUND);
+
+        backgroundAction.setTargetClass(targetClassName);
+        backgroundAction.setTargetAction(targetActionName);
+        backgroundAction.setTargetStr(aim.getTarget().toString());
+        backgroundAction.setActionIdentifier(aim.getActionId());
+
+        backgroundAction.setArguments(targetArgs);
+        backgroundAction.setMemento(aim.asMementoString());
+        
+        parentAction.setReify(true);
+        
+        persist(backgroundAction);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoContributions.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoContributions.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoContributions.java
new file mode 100644
index 0000000..8110b1f
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoContributions.java
@@ -0,0 +1,64 @@
+/**
+ *  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.objectstore.jdo.applib.service.background;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.ActionSemantics.Of;
+import org.apache.isis.applib.annotation.NotContributed;
+import org.apache.isis.applib.annotation.NotContributed.As;
+import org.apache.isis.applib.annotation.NotInServiceMenu;
+import org.apache.isis.applib.annotation.Render;
+import org.apache.isis.applib.annotation.Render.Type;
+import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
+import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
+
+
+public class BackgroundActionServiceJdoContributions extends AbstractFactoryAndRepository {
+
+    @ActionSemantics(Of.SAFE)
+    @NotInServiceMenu
+    @NotContributed(As.ACTION)
+    @Render(Type.EAGERLY)
+    public List<ReifiableActionJdo> backgroundActions(final ReifiableActionJdo parent) {
+        return backgroundActionRepository.findByParent(parent);
+    }
+
+    @ActionSemantics(Of.SAFE)
+    @NotInServiceMenu
+    @NotContributed(As.ACTION)
+    @Render(Type.EAGERLY)
+    public List<ReifiableActionJdo> siblingActions(final ReifiableActionJdo siblingAction) {
+        final ReifiableAction parent = siblingAction.getParent();
+        if(parent == null || !(parent instanceof ReifiableActionJdo)) {
+            return Collections.emptyList();
+        }
+        final ReifiableActionJdo parentJdo = (ReifiableActionJdo) parent;
+        final List<ReifiableActionJdo> siblingActions = backgroundActionRepository.findByParent(parentJdo);
+        siblingActions.remove(siblingAction);
+        return siblingActions;
+    }
+    
+    // //////////////////////////////////////
+
+    @javax.inject.Inject
+    private BackgroundActionServiceJdoRepository backgroundActionRepository;
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoRepository.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoRepository.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoRepository.java
new file mode 100644
index 0000000..f71bea0
--- /dev/null
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundActionServiceJdoRepository.java
@@ -0,0 +1,63 @@
+/**
+ *  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.objectstore.jdo.applib.service.background;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.query.QueryDefault;
+import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
+
+public class BackgroundActionServiceJdoRepository extends AbstractFactoryAndRepository {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = LoggerFactory.getLogger(BackgroundActionServiceJdoRepository.class);
+
+    @Programmatic
+    public List<ReifiableActionJdo> listAll() {
+        return allInstances(ReifiableActionJdo.class);
+    }
+
+    @Programmatic
+    public List<ReifiableActionJdo> findByTransactionId(final UUID transactionId) {
+        return allMatches(
+                new QueryDefault<ReifiableActionJdo>(ReifiableActionJdo.class, 
+                        "findBackgroundActionByTransactionId", 
+                        "transactionId", transactionId));
+    }
+
+    @Programmatic
+    public List<ReifiableActionJdo> findByParent(ReifiableActionJdo parent) {
+        return allMatches(
+                new QueryDefault<ReifiableActionJdo>(ReifiableActionJdo.class, 
+                        "findBackgroundActionsByParent", 
+                        "parent", parent));
+    }
+
+    @Programmatic
+    public List<ReifiableActionJdo> findBackgroundActionsToStart() {
+        return allMatches(
+                new QueryDefault<ReifiableActionJdo>(ReifiableActionJdo.class, 
+                        "findBackgroundActionsToStart"));
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdo.java
deleted file mode 100644
index a6886f0..0000000
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdo.java
+++ /dev/null
@@ -1,78 +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.objectstore.jdo.applib.service.background;
-
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractService;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.services.background.ActionInvocationMemento;
-import org.apache.isis.applib.services.background.BackgroundTaskService;
-import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
-import org.apache.isis.applib.services.reifiableaction.ReifiableAction.Nature;
-import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
-
-@Named("Background Tasks")
-public class BackgroundTaskServiceJdo extends AbstractService implements BackgroundTaskService {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(BackgroundTaskServiceJdo.class);
-    
-    @Programmatic
-    @Override
-    public void schedule(
-            final ActionInvocationMemento aim, 
-            final ReifiableAction parentAction, 
-            final String targetClassName, 
-            final String targetActionName, 
-            final String targetArgs) {
-        
-        final UUID transactionId = UUID.randomUUID();
-        final Integer sequence = 0;
-        final String user = parentAction.getUser();
-
-        final ReifiableActionJdo backgroundAction = newTransientInstance(ReifiableActionJdo.class);
-
-        backgroundAction.setParent(parentAction);
-        
-        backgroundAction.setTransactionId(transactionId);
-        backgroundAction.setSequence(sequence);
-
-        backgroundAction.setUser(user);
-        backgroundAction.setTimestamp(Clock.getTimeAsJavaSqlTimestamp());
-
-        backgroundAction.setNature(Nature.BACKGROUND);
-
-        backgroundAction.setTargetClass(targetClassName);
-        backgroundAction.setTargetAction(targetActionName);
-        backgroundAction.setTargetStr(aim.getTarget().toString());
-        backgroundAction.setActionIdentifier(aim.getActionId());
-
-        backgroundAction.setArguments(targetArgs);
-        backgroundAction.setMemento(aim.asMementoString());
-        
-        parentAction.setReify(true);
-        
-        persist(backgroundAction);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoContributions.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoContributions.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoContributions.java
deleted file mode 100644
index 2558f13..0000000
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoContributions.java
+++ /dev/null
@@ -1,47 +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.objectstore.jdo.applib.service.background;
-
-import java.util.List;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.ActionSemantics;
-import org.apache.isis.applib.annotation.Render;
-import org.apache.isis.applib.annotation.ActionSemantics.Of;
-import org.apache.isis.applib.annotation.NotContributed;
-import org.apache.isis.applib.annotation.NotContributed.As;
-import org.apache.isis.applib.annotation.NotInServiceMenu;
-import org.apache.isis.applib.annotation.Render.Type;
-import org.apache.isis.applib.services.HasTransactionId;
-import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
-
-
-public class BackgroundTaskServiceJdoContributions extends AbstractFactoryAndRepository {
-
-    @ActionSemantics(Of.SAFE)
-    @NotInServiceMenu
-    @NotContributed(As.ACTION)
-    @Render(Type.EAGERLY)
-    public List<ReifiableActionJdo> backgroundTasks(final ReifiableActionJdo parent) {
-        return backgroundTaskRepository.findByParent(parent);
-    }
-
-    // //////////////////////////////////////
-
-    @javax.inject.Inject
-    private BackgroundTaskServiceJdoRepository backgroundTaskRepository;
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoRepository.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoRepository.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoRepository.java
deleted file mode 100644
index 063b7f7..0000000
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/background/BackgroundTaskServiceJdoRepository.java
+++ /dev/null
@@ -1,56 +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.objectstore.jdo.applib.service.background;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.query.QueryDefault;
-import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
-
-public class BackgroundTaskServiceJdoRepository extends AbstractFactoryAndRepository {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(BackgroundTaskServiceJdoRepository.class);
-
-    @Programmatic
-    public List<ReifiableActionJdo> listAll() {
-        return allInstances(ReifiableActionJdo.class);
-    }
-
-    @Programmatic
-    public List<ReifiableActionJdo> findByTransactionId(final UUID transactionId) {
-        return allMatches(
-                new QueryDefault<ReifiableActionJdo>(ReifiableActionJdo.class, 
-                        "findBackgroundTasksByTransactionId", 
-                        "transactionId", transactionId));
-    }
-
-    @Programmatic
-    public List<ReifiableActionJdo> findByParent(ReifiableActionJdo parent) {
-        return allMatches(
-                new QueryDefault<ReifiableActionJdo>(ReifiableActionJdo.class, 
-                        "findBackgroundTasksByParent", 
-                        "parent", parent));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
index 25ab672..3f086a3 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
@@ -23,8 +23,6 @@ import java.util.UUID;
 
 import javax.jdo.annotations.IdentityType;
 
-import org.datanucleus.management.jmx.ManagementManager;
-
 import org.apache.isis.applib.DomainObjectContainer;
 import org.apache.isis.applib.annotation.ActionSemantics;
 import org.apache.isis.applib.annotation.ActionSemantics.Of;
@@ -73,6 +71,7 @@ public class PublishedEventJdo implements HasTransactionId {
     }
     
 
+    
     // //////////////////////////////////////
     // user (property)
     // //////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
index 97fb3d6..97354aa 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
@@ -19,12 +19,24 @@
 
 package org.apache.isis.objectstore.jdo.applib.service.publish;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.hamcrest.Matcher;
+
 import org.apache.isis.applib.AbstractService;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.publish.EventMetadata;
 import org.apache.isis.applib.services.publish.EventPayload;
 import org.apache.isis.applib.services.publish.EventSerializer;
 import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.applib.services.reifiableaction.ReifiableActionContext;
 
 /**
  * An implementation of {@link PublishingService} that persists events as
@@ -32,7 +44,25 @@ import org.apache.isis.applib.services.publish.PublishingService;
  */
 public class PublishingServiceJdo extends AbstractService implements PublishingService {
 
+    
+    @Programmatic
+    @PostConstruct
+    public void init(Map<String,String> props) {
+        ensureDependenciesInjected();
+    }
+    
+    // //////////////////////////////////////
+    
+    private void ensureDependenciesInjected() {
+        if(this.reifiableActionContext == null) {
+            throw new IllegalStateException(this.getClassName() + " requires ReifiableAactionContext service to be configured");
+        }
+        if(this.eventSerializer == null) {
+            throw new IllegalStateException(this.getClassName() + " requires EventSerializer service to be configured");
+        }
+    }
 
+    
     @Override
     @Programmatic
     public void publish(final EventMetadata metadata, final EventPayload payload) {
@@ -57,4 +87,7 @@ public class PublishingServiceJdo extends AbstractService implements PublishingS
         this.eventSerializer = eventSerializer;
     }
 
+    
+    @javax.inject.Inject
+    private ReifiableActionContext reifiableActionContext;
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdo.java
index a1045d3..ca4a15e 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdo.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdo.java
@@ -22,9 +22,8 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import javax.jdo.annotations.Column;
 import javax.jdo.annotations.IdentityType;
-import javax.jdo.annotations.Persistent;
+import javax.jdo.annotations.NotPersistent;
 
 import com.google.common.collect.Maps;
 
@@ -56,8 +55,7 @@ import org.apache.isis.objectstore.jdo.applib.service.Util;
 
 @javax.jdo.annotations.PersistenceCapable(
         identityType=IdentityType.APPLICATION, 
-        table="IsisReifiableAction",
-        objectIdClass=ReifiableActionJdoPK.class)
+        table="IsisReifiableAction")
 @javax.jdo.annotations.Queries( {
     @javax.jdo.annotations.Query(
             name="findByTransactionId", language="JDOQL",  
@@ -66,12 +64,26 @@ import org.apache.isis.objectstore.jdo.applib.service.Util;
                     + "WHERE transactionId == :transactionId "
                     + "&& nature == 'USER_INVOCATION'"),
     @javax.jdo.annotations.Query(
-            name="findBackgroundTasksByParent", language="JDOQL",  
+            name="findBackgroundActionByTransactionId", language="JDOQL",  
+            value="SELECT "
+                    + "FROM org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo "
+                    + "WHERE transactionId == :transactionId "
+                    + "&& nature == 'BACKGROUND'"),
+    @javax.jdo.annotations.Query(
+            name="findBackgroundActionsByParent", language="JDOQL",  
             value="SELECT "
                     + "FROM org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo "
                     + "WHERE parent == :parent "
                     + "&& nature == 'BACKGROUND'"),
     @javax.jdo.annotations.Query(
+            name="findBackgroundActionsToStart", language="JDOQL",  
+            value="SELECT "
+                    + "FROM org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo "
+                    + "WHERE nature == 'BACKGROUND' "
+                    + "&& startedAt == null "
+                    + "ORDER BY timestamp ASC "
+                    ),
+    @javax.jdo.annotations.Query(
             name="findCurrent", language="JDOQL",  
             value="SELECT "
                     + "FROM org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo "
@@ -82,6 +94,7 @@ import org.apache.isis.objectstore.jdo.applib.service.Util;
             value="SELECT "
                     + "FROM org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo "
                     + "WHERE completedAt != null "
+                    + "&& nature == 'USER_INVOCATION' "
                     + "ORDER BY timestamp DESC")
 })
 @ObjectType("IsisReifiableAction")
@@ -179,11 +192,10 @@ public class ReifiableActionJdo implements ReifiableAction {
     private ReifiableAction parent;
     
     @Override
-    @javax.jdo.annotations.Persistent(columns={
-            @javax.jdo.annotations.Column(name="parentSequence", allowsNull="true"),
-            @javax.jdo.annotations.Column(name="parentTransactionId", allowsNull="true")
-    })
+    @javax.jdo.annotations.Persistent
+    @javax.jdo.annotations.Column(name="parentTransactionId", allowsNull="true")
     @Hidden(where=Where.PARENTED_TABLES)
+    @MemberOrder(name="Identifiers",sequence = "40")
     public ReifiableAction getParent() {
         return parent;
     }
@@ -207,7 +219,7 @@ public class ReifiableActionJdo implements ReifiableAction {
     @javax.jdo.annotations.PrimaryKey
     @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.TRANSACTION_ID)
     @TypicalLength(JdoColumnLength.TRANSACTION_ID)
-    @MemberOrder(name="Identifiers",sequence = "40")
+    @MemberOrder(name="Identifiers",sequence = "50")
     @Override
     public UUID getTransactionId() {
         return transactionId;
@@ -226,38 +238,6 @@ public class ReifiableActionJdo implements ReifiableAction {
 
     
     // //////////////////////////////////////
-    // sequence (property)
-    // //////////////////////////////////////
-
-    private int sequence;
-
-    /**
-     * The 0-based additional identifier of a published event within the given {@link #getTransactionId() transaction}.
-     * 
-     * <p>
-     * The combination of ({@link #getTransactionId() transactionId}, {@link #getSequence() sequence}) makes up the
-     * primary key.
-     * 
-     * <p>
-     * For {@link Nature#USER_INITIATED user-initiated} actions, this will always be <tt>0</tt>
-     */
-    @javax.jdo.annotations.PrimaryKey
-    @MemberOrder(name="Identifiers", sequence = "50")
-    public int getSequence() {
-        return sequence;
-    }
-
-    public void setSequence(final int sequence) {
-        this.sequence = sequence;
-    }
-    
-    public boolean hideSequence() {
-        return Nature.USER_INITIATED.equals(getNature());
-    }
-
-
-
-    // //////////////////////////////////////
     // targetClass (property)
     // //////////////////////////////////////
 
@@ -607,6 +587,7 @@ public class ReifiableActionJdo implements ReifiableAction {
     
     private boolean reify;
 
+    @NotPersistent
     @Programmatic
     public boolean isReify() {
         return reify;

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdoPK.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdoPK.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdoPK.java
deleted file mode 100644
index 3d3479d..0000000
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/reifiableaction/ReifiableActionJdoPK.java
+++ /dev/null
@@ -1,102 +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.objectstore.jdo.applib.service.reifiableaction;
-
-import java.io.Serializable;
-import java.util.StringTokenizer;
-import java.util.UUID;
-
-public class ReifiableActionJdoPK implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private static final String SEPARATOR = "_";
-
-    public UUID transactionId;
-    public int sequence;
-
-    // //////////////////////////////////////
-
-    
-    public ReifiableActionJdoPK() {
-    }
-    
-    public ReifiableActionJdoPK(final String value) {
-        final StringTokenizer token = new StringTokenizer (value, SEPARATOR);
-        this.transactionId = UUID.fromString(token.nextToken());
-        this.sequence = Integer.parseInt(token.nextToken());
-    }
-
-    // //////////////////////////////////////
-
-    public UUID getTransactionId() {
-        return transactionId;
-    }
-    public void setTransactionId(UUID transactionId) {
-        this.transactionId = transactionId;
-    }
-    
-    // //////////////////////////////////////
-
-    public int getSequence() {
-        return sequence;
-    }
-    public void setSequence(int sequence) {
-        this.sequence = sequence;
-    }
-    
-    // //////////////////////////////////////
-
-    
-    
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + sequence;
-        result = prime * result + ((transactionId == null) ? 0 : transactionId.hashCode());
-        return result;
-    }
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        ReifiableActionJdoPK other = (ReifiableActionJdoPK) obj;
-        if (sequence != other.sequence)
-            return false;
-        if (transactionId == null) {
-            if (other.transactionId != null)
-                return false;
-        } else if (!transactionId.equals(other.transactionId))
-            return false;
-        return true;
-    }
-    
-    // //////////////////////////////////////
-
-    
-    @Override
-    public String toString() {
-        return transactionId + SEPARATOR + sequence;
-    }
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/background/ActionInvocationMemento.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/ActionInvocationMemento.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/ActionInvocationMemento.java
index 652a27f..89e02eb 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/ActionInvocationMemento.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/ActionInvocationMemento.java
@@ -15,8 +15,8 @@ import org.apache.isis.applib.services.memento.MementoService.Memento;
  * 
  * <p>
  * Provided as a mechanism by which implementations of {@link BackgroundService} can 
- * hand-off work to the {@link BackgroundTaskService} through 
- * {@link BackgroundTaskService#execute(ActionInvocationMemento)}.   This is used by the
+ * hand-off work to the {@link BackgroundActionService} through 
+ * {@link BackgroundActionService#execute(ActionInvocationMemento)}.   This is used by the
  * default implementation of <tt>BackgroundServiceDefault</tt> in Isis' core-runtime.
  * 
  * <p>

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundActionService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundActionService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundActionService.java
new file mode 100644
index 0000000..4077208
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundActionService.java
@@ -0,0 +1,21 @@
+package org.apache.isis.applib.services.background;
+
+import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
+
+
+/**
+ * Execute a {@link ActionInvocationMemento memento-ized} action as a
+ * decoupled task.
+ * 
+ * <p>
+ * Separate from {@link BackgroundService} primarily so that the default
+ * implementation, <tt>BackgroundServiceDefault</tt> (in core-runtime) can
+ * delegate to different implementations of this service.
+ */
+public interface BackgroundActionService {
+
+    void schedule(
+            final ActionInvocationMemento aim, 
+            final ReifiableAction reifiableAction, 
+            final String targetClassName, final String targetActionName, final String targetArgs);
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
index 7a813fc..da27d30 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundService.java
@@ -32,4 +32,7 @@ public interface BackgroundService {
     @Programmatic
     ActionInvocationMemento asActionInvocationMemento(Method m, Object domainObject, Object[] args);
 
+    @Programmatic
+    ActionInvocationMemento newActionInvocationMemento(String memento);
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundTaskService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundTaskService.java b/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundTaskService.java
deleted file mode 100644
index 6cca4c5..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/services/background/BackgroundTaskService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.isis.applib.services.background;
-
-import java.lang.reflect.Method;
-
-import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
-
-
-/**
- * Execute a {@link ActionInvocationMemento memento-ized} action as a
- * decoupled task.
- * 
- * <p>
- * Separate from {@link BackgroundService} primarily so that the default
- * implementation, <tt>BackgroundServiceDefault</tt> (in core-runtime) can
- * delegate to different implementations of this service.
- */
-public interface BackgroundTaskService {
-
-    void schedule(
-            final ActionInvocationMemento aim, 
-            final ReifiableAction reifiableAction, 
-            final String targetClassName, final String targetActionName, final String targetArgs);
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableAction.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableAction.java b/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableAction.java
index e9baad3..237b331 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableAction.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableAction.java
@@ -27,7 +27,7 @@ import org.apache.isis.applib.annotation.Reified;
 import org.apache.isis.applib.clock.Clock;
 import org.apache.isis.applib.services.HasTransactionId;
 import org.apache.isis.applib.services.background.BackgroundService;
-import org.apache.isis.applib.services.background.BackgroundTaskService;
+import org.apache.isis.applib.services.background.BackgroundActionService;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
 import org.apache.isis.applib.services.reifiableaction.spi.ReifiableActionService;
@@ -38,24 +38,6 @@ public interface ReifiableAction extends HasTransactionId {
     // //////////////////////////////////////
 
     /**
-     * The 0-based additional identifier of an action within the given {@link #getTransactionId() transaction}.
-     * 
-     * <p>
-     * The combination of ({@link #getTransactionId() transactionId}, {@link #getSequence() sequence}) makes up the
-     * primary key.
-     * 
-     * <p>
-     * For {@link Nature#USER_INITIATED user-initiated} actions, this will always take the value <tt>0</tt>.
-     */
-    @Disabled
-    public int getSequence();
-
-    public void setSequence(final int sequence);
-
-
-    // //////////////////////////////////////
-
-    /**
      * The user that initiated the action.
      */
     @Disabled
@@ -256,7 +238,7 @@ public interface ReifiableAction extends HasTransactionId {
 
 
     /**
-     * For actions created through the {@link BackgroundService} and {@link BackgroundTaskService},
+     * For actions created through the {@link BackgroundService} and {@link BackgroundActionService},
      * captures the parent action.
      */
     @Optional
@@ -313,7 +295,7 @@ public interface ReifiableAction extends HasTransactionId {
      * <p>
      * This is most commonly done if the action being invoked has been explicitly annotated to be reified, eg
      * using the {@link Reified} annotation.  But it might also happen as a hint from another domain service.
-     * For example, a {@link BackgroundTaskService} implementations that creates persisted background tasks ought to be
+     * For example, a {@link BackgroundActionService} implementations that creates persisted background tasks ought to be
      * associated (via the {@link ReifiableAction#getTransactionId() transactionId}) to a persisted
      * {@link ReifiableAction}.  The app can then provide a mechanism for the end-user to query for their
      * running background actions from this original {@link ReifiableAction}.

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableActionDefault.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableActionDefault.java b/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableActionDefault.java
index 193f3ed..ab48611 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableActionDefault.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/reifiableaction/ReifiableActionDefault.java
@@ -287,19 +287,4 @@ public class ReifiableActionDefault implements ReifiableAction {
     }
     
     
-    // //////////////////////////////////////
-    
-    private int sequence;
-    
-    @Override
-    public int getSequence() {
-        return sequence;
-    }
-    
-    @Override
-    public void setSequence(int sequence) {
-        this.sequence = sequence;
-    }
-    
-
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/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 17cf1ee..160c3cf 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
@@ -5,10 +5,8 @@ import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
 
 import java.lang.reflect.Method;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 
 import javassist.util.proxy.MethodFilter;
 import javassist.util.proxy.MethodHandler;
@@ -17,14 +15,12 @@ import javassist.util.proxy.ProxyObject;
 
 import javax.annotation.PostConstruct;
 
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
 import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.services.HasTransactionId;
 import org.apache.isis.applib.services.background.ActionInvocationMemento;
+import org.apache.isis.applib.services.background.BackgroundActionService;
 import org.apache.isis.applib.services.background.BackgroundService;
-import org.apache.isis.applib.services.background.BackgroundTaskService;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.bookmark.BookmarkService;
 import org.apache.isis.applib.services.reifiableaction.ReifiableAction;
@@ -32,7 +28,6 @@ import org.apache.isis.applib.services.reifiableaction.ReifiableActionContext;
 import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.lang.ArrayExtensions;
-import org.apache.isis.core.commons.lang.StringExtensions;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -67,9 +62,9 @@ public class BackgroundServiceDefault implements BackgroundService {
     }
     
     private void ensureDependenciesInjected() {
-        Ensure.ensureThatState(this.bookmarkService, is(not(nullValue())), "bookmark service required");
-        Ensure.ensureThatState(this.backgroundTaskService, is(not(nullValue())), "background task service required");
-        Ensure.ensureThatState(this.reifiableActionContext, is(not(nullValue())), "reifiable action context service required");
+        Ensure.ensureThatState(this.bookmarkService, is(not(nullValue())), "BookmarkService domain service must be configured");
+        Ensure.ensureThatState(this.backgroundActionService, is(not(nullValue())), "BackgroundActionService domain service must be configured");
+        Ensure.ensureThatState(this.reifiableActionContext, is(not(nullValue())), "ReifiableActionContext domain service must be configured");
     }
 
 
@@ -176,7 +171,7 @@ public class BackgroundServiceDefault implements BackgroundService {
                                 argTypes,
                                 argObjs);
                
-                backgroundTaskService.schedule(aim, reifiableAction, targetClassName, targetActionName, targetArgs);
+                backgroundActionService.schedule(aim, reifiableAction, targetClassName, targetActionName, targetArgs);
                 
                 return null;
             }
@@ -220,8 +215,12 @@ public class BackgroundServiceDefault implements BackgroundService {
         return aim;
     }
 
-    
-    
+
+    @Override
+    public ActionInvocationMemento newActionInvocationMemento(String mementoStr) {
+        return new ActionInvocationMemento(mementoService, mementoStr);
+    }
+
     // //////////////////////////////////////
 
     private BookmarkService bookmarkService;
@@ -232,12 +231,12 @@ public class BackgroundServiceDefault implements BackgroundService {
         this.bookmarkService = bookmarkService;
     }
     
-    private BackgroundTaskService backgroundTaskService;
+    private BackgroundActionService backgroundActionService;
     /**
      * Mandatory service.
      */
-    public void injectBackgroundTaskService(BackgroundTaskService backgroundTaskService) {
-        this.backgroundTaskService = backgroundTaskService;
+    public void injectBackgroundActionService(BackgroundActionService backgroundActionService) {
+        this.backgroundActionService = backgroundActionService;
     }
 
     private ReifiableActionContext reifiableActionContext;
@@ -261,4 +260,5 @@ public class BackgroundServiceDefault implements BackgroundService {
     }
 
 
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index 30ee827..f51feaa 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -242,7 +242,7 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
         
         startRequestOnRequestScopedServices(registeredServices);
 
-        createReifiableAactionIfConfigured();
+        createReifiableActionIfConfigured();
         
         createServiceAdapters(registeredServices);
         
@@ -301,7 +301,7 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
         }
     }
 
-    private void createReifiableAactionIfConfigured() {
+    private void createReifiableActionIfConfigured() {
         final ReifiableActionContext reifiableActionContext = getServiceOrNull(ReifiableActionContext.class);
         if(reifiableActionContext == null) {
             return;

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/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 55abdc5..8118e4a 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
@@ -46,7 +46,6 @@ 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.HasTransactionId;
 import org.apache.isis.applib.services.audit.AuditingService3;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.publish.EventMetadata;
@@ -189,7 +188,7 @@ public class IsisTransaction implements TransactionScopedComponent {
     private final UpdateNotifier updateNotifier;
 
     /**
-     * the 'owning' interaction, if configured.
+     * the 'owning' reifiable action, (if service configured).
      */
     private final ReifiableAction reifiableAction;
 
@@ -206,15 +205,10 @@ public class IsisTransaction implements TransactionScopedComponent {
      * Will be that of the {@link #reifiableAction} if not <tt>null</tt>, otherwise will be randomly created.
      */
     private final UUID transactionId;
-    /**
-     * Only used if {@link #reifiableAction} is <tt>null</tt>; generates sequence within the {@link #transactionId}
-     */
-    private int publishedEventSequence;
-    
+        
     private State state;
     private IsisException abortCause;
 
-
     public IsisTransaction(
             final IsisTransactionManager transactionManager, 
             final org.apache.isis.core.commons.authentication.MessageBroker messageBroker, 
@@ -231,11 +225,12 @@ public class IsisTransaction implements TransactionScopedComponent {
         this.transactionManager = transactionManager;
         this.messageBroker = messageBroker;
         this.updateNotifier = updateNotifier;
+        
         this.auditingService3 = auditingService3;
         this.publishingService = publishingService;
 
         // determine whether this xactn is taking place in the context of an
-        // existing interaction in which a previous xactn has already occurred.
+        // existing reifiable action in which a previous xactn has already occurred.
         // if so, reuse that transactionId.
         UUID previousTransactionId = null;
         if(reifiableActionContext != null) {
@@ -561,12 +556,10 @@ public class IsisTransaction implements TransactionScopedComponent {
     }
 
     private int nextEventSequence() {
-        if(reifiableAction != null) {
-            return reifiableAction.next("publishedEvent");
-        } else {
-            return publishedEventSequence++;
-        }
-            
+        if(reifiableAction == null) {
+            throw new IllegalStateException("ReifiableActionContext service is required to support Publishing.");
+        } 
+        return reifiableAction.next("publishedEvent");
     }
 
     public void auditChangedProperty(

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
index f5bfdc6..7743243 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
@@ -618,7 +618,6 @@ public class ToDoItem implements Comparable<ToDoItem> /*, Locatable*/ { // GMAP3
     @Prototype
     public ToDoItem completeInBackground() {
         backgroundService.execute(this).slowCompleted(5000);
-        backgroundService.execute(this).slowCompleted(2000);
         container.informUser("Task '" + getDescription() + "' scheduled for completion");
         return this;
     }
@@ -630,7 +629,7 @@ public class ToDoItem implements Comparable<ToDoItem> /*, Locatable*/ { // GMAP3
             Thread.sleep(millis);
         } catch (InterruptedException e) {
         }
-        completed();
+        setComplete(true);
         container.informUser("Completed " + this.getDescription() + "!");
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/pom.xml b/example/application/quickstart_wicket_restful_jdo/pom.xml
index 6337822..6992d03 100644
--- a/example/application/quickstart_wicket_restful_jdo/pom.xml
+++ b/example/application/quickstart_wicket_restful_jdo/pom.xml
@@ -40,6 +40,8 @@
         <datanucleus-accessplatform-jdo-rdbms.version>3.3.6</datanucleus-accessplatform-jdo-rdbms.version>
         <datanucleus-maven-plugin.version>3.3.2</datanucleus-maven-plugin.version>
         
+        <quartz-scheduler.version>2.2.1</quartz-scheduler.version>
+        
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 	</properties>
@@ -333,6 +335,20 @@
             </dependency>
 
 
+
+            <!-- quartz scheduler integration -->
+
+            <dependency>
+                <groupId>org.quartz-scheduler</groupId>
+                <artifactId>quartz</artifactId>
+                <version>${quartz-scheduler.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.quartz-scheduler</groupId>
+                <artifactId>quartz-jobs</artifactId>
+                <version>${quartz-scheduler.version}</version>
+            </dependency>
+
             <!-- 3rd party extensions -->
 
             <!--

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/ide/eclipse/launch/ToDoApp-PROTOTYPE-jrebel.launch
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/ide/eclipse/launch/ToDoApp-PROTOTYPE-jrebel.launch b/example/application/quickstart_wicket_restful_jdo/webapp/ide/eclipse/launch/ToDoApp-PROTOTYPE-jrebel.launch
index 5a07818..fb34b64 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/ide/eclipse/launch/ToDoApp-PROTOTYPE-jrebel.launch
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/ide/eclipse/launch/ToDoApp-PROTOTYPE-jrebel.launch
@@ -20,5 +20,5 @@
 <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--port 8080 --type SERVER_PROTOTYPE"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="quickstart_wicket_restful_jdo-webapp"/>
 <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="${jrebel_args} -Drebel.log=true -Drebel.plugins=c:/github/danhaywood/isis-jrebel-plugin/target/danhaywood-isis-jrebel-plugin-1.0.0-SNAPSHOT.jar -Disis-jrebel-plugin.packagePrefix=dom.todo,org.apache.isis.objectstore.jdo.applib -Disis-jrebel-plugin.loggingLevel=debug"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="${jrebel_args} -Drebel.log=true -Drebel.plugins=c:/github/danhaywood/isis-jrebel-plugin/target/danhaywood-isis-jrebel-plugin-1.0.0-SNAPSHOT.jar -Disis-jrebel-plugin.packagePrefix=dom.todo,org.apache.isis.objectstore.jdo.applib -Disis-jrebel-plugin.loggingLevel=warn -XX:MaxPermSize=128m"/>
 </launchConfiguration>

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/pom.xml b/example/application/quickstart_wicket_restful_jdo/webapp/pom.xml
index 05d242d..00d7a49 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/pom.xml
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/pom.xml
@@ -266,6 +266,17 @@
         </dependency>
 
 
+        <!-- quartz scheduler integration -->
+
+        <dependency>
+            <groupId>org.quartz-scheduler</groupId>
+            <artifactId>quartz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.quartz-scheduler</groupId>
+            <artifactId>quartz-jobs</artifactId>
+        </dependency>
+
         <!-- 3rd party dependency -->
         <!-- 
         GMAP3: uncomment to use https://github.com/danhaywood/isis-wicket-gmap3

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/admin/Admin.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/admin/Admin.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/admin/Admin.java
index 38028c5..0ebf88c 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/admin/Admin.java
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/admin/Admin.java
@@ -28,7 +28,7 @@ import org.apache.isis.applib.annotation.Named;
 import org.apache.isis.applib.annotation.Prototype;
 import org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo;
 import org.apache.isis.objectstore.jdo.applib.service.audit.AuditingServiceJdoRepository;
-import org.apache.isis.objectstore.jdo.applib.service.background.BackgroundTaskServiceJdoRepository;
+import org.apache.isis.objectstore.jdo.applib.service.background.BackgroundActionServiceJdoRepository;
 import org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo;
 import org.apache.isis.objectstore.jdo.applib.service.publish.PublishingServiceJdoRepository;
 import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
@@ -127,7 +127,7 @@ public class Admin extends AbstractService {
     private ReifiableActionServiceJdoRepository interactionRepository;
     
     @javax.inject.Inject
-    private BackgroundTaskServiceJdoRepository backgroundTaskRepository;
+    private BackgroundActionServiceJdoRepository backgroundTaskRepository;
     
     @javax.inject.Inject
     private AuditingServiceJdoRepository auditEntryRepository;

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/AbstractIsisJob.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/AbstractIsisJob.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/AbstractIsisJob.java
new file mode 100644
index 0000000..1413ea4
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/AbstractIsisJob.java
@@ -0,0 +1,119 @@
+/**
+ *  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 webapp.scheduler;
+
+import java.util.List;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.core.runtime.system.session.IsisSession;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
+
+public abstract class AbstractIsisJob implements Job {
+
+    private boolean executing;
+
+    /**
+     * Sets up an {@link IsisSession} then delegates to the {@link #doExecute(JobExecutionContext) hook}. 
+     */
+    public void execute(final JobExecutionContext context) throws JobExecutionException {
+        final AuthenticationSession authSession = newAuthSession(context);
+        try {
+            if(executing) {
+                return;
+            }
+            executing = true;
+
+            IsisContext.openSession(authSession);
+            PersistenceSession persistenceSession = IsisContext.getPersistenceSession();
+            persistenceSession.getServicesInjector().injectServicesInto(this);
+            IsisTransactionManager transactionManager = persistenceSession.getTransactionManager();
+            transactionManager.executeWithinTransaction(new TransactionalClosure() {
+                
+                @Override
+                public void preExecute() {
+                }
+                
+                @Override
+                public void execute() {
+                    doExecute(context);
+                }
+                
+                @Override
+                public void onSuccess() {
+                }
+                
+                @Override
+                public void onFailure() {
+                }
+            });
+        } finally {
+            executing = false;
+            IsisContext.closeSession();
+        }
+    }
+
+    AuthenticationSession newAuthSession(JobExecutionContext context) {
+        String user = getKey(context, SchedulerConstants.USER_KEY);
+        String rolesStr = getKey(context, SchedulerConstants.ROLES_KEY);
+        String[] roles = Iterables.toArray(
+                Splitter.on(",").split(rolesStr), String.class);
+        return new SimpleSession(user, roles);
+    }
+
+    
+    /**
+     * Mandatory hook.
+     */
+    protected abstract void doExecute(JobExecutionContext context);
+
+    /**
+     * Helper method for benefit of subclasses
+     */
+    protected String getKey(JobExecutionContext context, String key) {
+        return context.getMergedJobDataMap().getString(key);
+    }
+
+    /**
+     * Helper method for benefit of subclasses
+     */
+    protected <T> T getService(Class<T> cls) {
+        List<Object> services = IsisContext.getServices();
+        for (Object service : services) {
+            if(cls.isAssignableFrom(service.getClass())) {
+                return asT(service);
+            }
+        }
+        throw new IllegalArgumentException("No service of type '" + cls.getName() + "' was found");
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T asT(Object service) {
+        return (T) service;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/BackgroundActionExecutionJob.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/BackgroundActionExecutionJob.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/BackgroundActionExecutionJob.java
new file mode 100644
index 0000000..bc9dbee
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/BackgroundActionExecutionJob.java
@@ -0,0 +1,149 @@
+/*
+ *
+ *  Copyright 2012-2014 Eurocommercial Properties NV
+ *
+ *
+ *  Licensed 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 webapp.scheduler;
+
+import java.util.List;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+
+import org.quartz.JobExecutionContext;
+
+import org.apache.isis.applib.clock.Clock;
+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.bookmark.BookmarkService;
+import org.apache.isis.applib.services.reifiableaction.ReifiableActionContext;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+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.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.objectstore.jdo.applib.service.background.BackgroundActionServiceJdoRepository;
+import org.apache.isis.objectstore.jdo.applib.service.reifiableaction.ReifiableActionJdo;
+
+public class BackgroundActionExecutionJob extends AbstractIsisJob {
+
+    protected void doExecute(JobExecutionContext context) {
+        final BackgroundActionServiceJdoRepository backgroundActionRepo = getService(BackgroundActionServiceJdoRepository.class);
+        final List<ReifiableActionJdo> findBackgroundActionsToStart = backgroundActionRepo.findBackgroundActionsToStart(); 
+        for (final ReifiableActionJdo backgroundAction : findBackgroundActionsToStart) {
+
+            try {
+                reifiableActionContext.setReifiableAction(backgroundAction);
+
+                backgroundAction.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
+                
+                final String memento = backgroundAction.getMemento();
+                final ActionInvocationMemento aim = backgroundService.newActionInvocationMemento(memento);
+                final String actionId = aim.getActionId();
+    
+                final Bookmark targetBookmark = aim.getTarget();
+                final Object targetObject = bookmarkService.lookup(targetBookmark);
+                
+                final ObjectAdapter targetAdapter = adapterFor(targetObject);
+                final ObjectSpecification specification = targetAdapter.getSpecification();
+    
+                ObjectAction objectAction = findAction(specification, actionId);
+    
+                if(objectAction != null) {
+                    
+                    final ObjectAdapter[] argAdapters = argAdaptersFor(aim);
+                    ObjectAdapter resultAdapter = objectAction.execute(targetAdapter, argAdapters);
+                    if(resultAdapter != null) {
+                        Bookmark resultBookmark = bookmarkService.bookmarkFor(resultAdapter.getObject());
+                        backgroundAction.setResult(resultBookmark);
+                    }
+                }
+
+            } catch (Exception e) {
+                backgroundAction.setException(Throwables.getStackTraceAsString(e));
+            } finally {
+                backgroundAction.setCompletedAt(Clock.getTimeAsJavaSqlTimestamp());
+            }
+
+        }
+    }
+
+    private ObjectAction findAction(final ObjectSpecification specification, final String actionId) {
+        final List<ObjectAction> objectActions = specification.getObjectActions(Contributed.INCLUDED);
+        for (final ObjectAction objectAction : objectActions) {
+            if(objectAction.getIdentifier().toClassAndNameIdentityString().equals(actionId)) {
+                return objectAction;
+            }
+        }
+        return null;
+    }
+
+    private ObjectAdapter[] argAdaptersFor(final ActionInvocationMemento aim) throws ClassNotFoundException {
+        final int numArgs = aim.getNumArgs();
+        final List<ObjectAdapter> argumentAdapters = Lists.newArrayList();
+        for(int i=0; i<numArgs; i++) {
+            final ObjectAdapter argAdapter = argAdapterFor(aim, i);
+            argumentAdapters.add(argAdapter);
+        }
+        return argumentAdapters.toArray(new ObjectAdapter[]{});
+    }
+
+    private ObjectAdapter argAdapterFor(final ActionInvocationMemento aim, int num) throws ClassNotFoundException {
+        final Class<?> argType = aim.getArgType(num);
+        final Object arg = aim.getArg(num, argType);
+        if(arg == null) {
+            return null;
+        } 
+        if(Bookmark.class != argType) {
+            return adapterFor(arg);
+        } 
+        final Bookmark argBookmark = (Bookmark)arg;
+        final RootOid rootOid = RootOidDefault.create(argBookmark);
+        return getAdapterManager().adapterFor(rootOid);
+    }
+
+    private ObjectAdapter adapterFor(final Object targetObject) {
+        return getAdapterManager().adapterFor(targetObject);
+    }
+
+    // //////////////////////////////////////
+
+    
+    protected AdapterManager getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
+    }
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+    
+    // //////////////////////////////////////
+
+    
+    @javax.inject.Inject
+    private BackgroundService backgroundService;
+
+    @javax.inject.Inject
+    private BookmarkService bookmarkService;
+
+    @javax.inject.Inject
+    private ReifiableActionContext reifiableActionContext;
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/SchedulerConstants.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/SchedulerConstants.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/SchedulerConstants.java
new file mode 100644
index 0000000..87b6767
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/scheduler/SchedulerConstants.java
@@ -0,0 +1,27 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package webapp.scheduler;
+
+
+public final class SchedulerConstants {
+
+    private SchedulerConstants(){}
+    
+    public static final String USER_KEY = SchedulerConstants.class.getPackage().getName() + ".user";
+    public static final String ROLES_KEY = SchedulerConstants.class.getPackage().getName() + ".roles";
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz-config.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz-config.xml b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz-config.xml
new file mode 100644
index 0000000..df5f4fe
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz-config.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<job-scheduling-data
+	xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData 
+http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
+	version="1.8">
+
+	<schedule>
+		<job>
+			<name>BackgroundActionExecutionJob</name>
+			<group>Isis</group>
+			<description>Poll and execute any background actions persisted by the BackgroundActionServiceJdo domain service</description>
+			<job-class>webapp.scheduler.BackgroundActionExecutionJob</job-class>
+			<job-data-map>
+				<entry>
+					<key>webapp.scheduler.user</key>
+					<value>scheduler_user</value>
+				</entry>
+				<entry>
+					<key>webapp.scheduler.roles</key>
+					<value>admin_role</value>
+				</entry>
+			</job-data-map>
+		</job>
+
+		<!--
+		cron format: 
+		http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06
+	 	-->
+		<trigger>
+			<cron>
+				<name>BackgroundActionExecutionJobEveryTenSeconds</name>
+				<job-name>BackgroundActionExecutionJob</job-name>
+				<job-group>Isis</job-group>
+				<cron-expression>0/10 * * * * ?</cron-expression>
+			</cron>
+		</trigger>
+
+	</schedule>
+</job-scheduling-data>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz.properties
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz.properties b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz.properties
new file mode 100644
index 0000000..da9158d
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/resources/webapp/scheduler/quartz.properties
@@ -0,0 +1,6 @@
+org.quartz.scheduler.instanceName = SchedulerQuartzConfigXml
+org.quartz.threadPool.threadCount = 1
+org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
+org.quartz.plugin.jobInitializer.class =org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin 
+org.quartz.plugin.jobInitializer.fileNames = webapp/scheduler/quartz-config.xml 
+org.quartz.plugin.jobInitializer.failOnFileNotFound = true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
index 6ab096e..220389e 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
@@ -195,13 +195,13 @@ isis.services = \
                 org.apache.isis.objectstore.jdo.applib.service.audit.AuditingServiceJdoContributions,\
                 org.apache.isis.objectstore.jdo.applib.service.audit.AuditingServiceJdoRepository,\
                 \
-                # Core implementation of BackgroundService (depends on: MementoService & BackgroundTaskService), \
+                # Core implementation of BackgroundService (depends on: MementoService & BackgroundActionService), \
                 org.apache.isis.core.runtime.services.background.BackgroundServiceDefault,\
                 \
                 # JDO implementation of the BackgroundTaskService (depends on: ReifiableActionContext service), \
-                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundTaskServiceJdo,\
-                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundTaskServiceJdoContributions,\
-                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundTaskServiceJdoRepository,\
+                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundActionServiceJdo,\
+                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundActionServiceJdoContributions,\
+                org.apache.isis.objectstore.jdo.applib.service.background.BackgroundActionServiceJdoRepository,\
                 \
                 # JDO implementation of the PublishingService, \
                 org.apache.isis.objectstore.jdo.applib.service.publish.PublishingServiceJdo,\

http://git-wip-us.apache.org/repos/asf/isis/blob/d78f2454/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/web.xml b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/web.xml
index 1c07e08..25d7f89 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/web.xml
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/web.xml
@@ -289,4 +289,24 @@
     </resource-ref>
      -->
 
+
+    <servlet>
+         <servlet-name>QuartzInitializer</servlet-name>
+         <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
+         <init-param>
+             <param-name>config-file</param-name>
+             <param-value>webapp/scheduler/quartz.properties</param-value>
+         </init-param>
+         <init-param>
+             <param-name>shutdown-on-unload</param-name>
+             <param-value>true</param-value>
+         </init-param>
+         <init-param>
+             <param-name>start-scheduler-on-load</param-name>
+             <param-value>true</param-value>
+         </init-param>
+         <load-on-startup>1</load-on-startup>
+     </servlet>
+
+
 </web-app>