Author: ieb
Date: Wed Jul 27 12:10:12 2016
New Revision: 1754255

URL: http://svn.apache.org/viewvc?rev=1754255&view=rev
Log:
SLING-5646 MoM API and JMS implementation with example usage by Jobs 
implementation.
Squashes 27 commits from https://github.com/ieb/sling/tree/jobs_28 as follows.
Added first stab at a message oriented job subsystem
Added basic implementation for the manager keeping queue implementation details 
abstracted
Added ActiveMQ implementation for queues and topics, and fixed a number of the 
the SPI interfaces in the process
Basic Test coverate for OOT JMS Broker
Extracted a MOM API with no Jobs or JMS references, test coverage for ActiveMQ 
impl is 100% class, 93% method, 75% line
Added missing license headers, documentation and cleaned out unused  interfaces
Fixed JMS Transaction issue found by @tmaret
Coverage for the majority of the jobs code is complete
Basic unit test coverage complete, core has 94% by lines, AMQ 74%, 100% classes 
and methods
Added testing environment for a runnign server, Not working yet
Added ability for detect when the OSGi container has completed bundle startup 
without having to perform http requests
Start at IT testing with Crankstart
Fixed issues with shutdown inside a Crankstart container
Working Crankstart IT framework
Version that uses Q->Jobs->JobConsumer pattern
Added a Queue Factory to allow configuration of multiple queues between the MOM 
API and Job Subsystem and move JobConsumers to register with a Job type
Migrated Subscribers and QueueReaders to a OSGi whiteboard pattern after 
discussion on Sling Dev
Changes the JobConsumer to use a Callback rather than return a job. This was 
suggested offlist by others in Adobe as a way of improving resource consumption
Added Types to improve type safety in certain areas after suggestions offlist
Fixed issue with OSGi startup in IntelliJ caused by version 4 of the
Felix framework bundle being present inside the maven pom. Strangely a
command line build was not impacted.
Added integration test bundle to test service. Adjusted some of the APIs to 
make using the Job Sub System easier
Integration tests now starting jobs from messages
Fixed Startup to work in real Sling/AEM container. The Active MQ OSGi bundle 
contains additional dependencies that cause all sorts of problems, AMQ is now 
being embedded into the AMQ MOM Impl bundle.
Fixed Queue expriy bug and added AEM Fiddle to run jobs
Added Documentation for configuration and default sample configuration
Added Explicit requeue mechanims rather than relying on AMQ's requeue 
capabilities
Moved MoM to new Home

Added:
    sling/trunk/contrib/commons/mom/
    sling/trunk/contrib/commons/mom/api/
    sling/trunk/contrib/commons/mom/api/README.md   (with props)
    sling/trunk/contrib/commons/mom/api/pom.xml   (with props)
    sling/trunk/contrib/commons/mom/api/src/
    sling/trunk/contrib/commons/mom/api/src/main/
    sling/trunk/contrib/commons/mom/api/src/main/java/
    sling/trunk/contrib/commons/mom/api/src/main/java/org/
    sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/
    sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/
    sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java
   (with props)
    
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java
   (with props)
    sling/trunk/contrib/commons/mom/examples/
    sling/trunk/contrib/commons/mom/examples/jobs/
    sling/trunk/contrib/commons/mom/examples/jobs/core/
    sling/trunk/contrib/commons/mom/examples/jobs/core/README.md   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Types.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobBuilderImpl.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobImpl.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobManagerImpl.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobQueueConsumerFactory.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobUpdateBuilderImpl.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/JobUpdateImpl.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/ManagerSubscriber.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/OutboundJobUpdateListener.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/Utils.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/spi/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/spi/JobStarter.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/spi/JobStorage.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/spi/MapValueAdapter.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/storage/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorage.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/package-info.java
   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/
    sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/JobBuilderImplTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/JobImplTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/JobManagerImplTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/JobUpdateImplTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/ManagerSubscriberTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/QueueEntry.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/UtilsTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/storage/
    
sling/trunk/contrib/commons/mom/examples/jobs/core/src/test/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorageTest.java
   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it/
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/pom.xml   (with 
props)
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/it/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/it/services/
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/it/services/AsyncJobConsumer.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/it/services/FullySyncJob.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it-services/src/main/java/org/apache/sling/jobs/it/services/JobManagerTestComponent.java
   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it-services/testlaunch.jsp   
(with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it/.gitignore
    sling/trunk/contrib/commons/mom/examples/jobs/it/README.md   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it/pom.xml   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/jobs/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/jobs/it/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/jobs/it/CheckRootIT.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/jobs/it/Models.java
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/java/org/apache/sling/jobs/it/TestSuiteLauncherIT.java
   (with props)
    sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/crankstart-model.txt
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/provisioning-model/
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/provisioning-model/base.txt
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/provisioning-model/crankstart-test-support.txt
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/provisioning-model/jobs-runtime.txt
   (with props)
    
sling/trunk/contrib/commons/mom/examples/jobs/it/src/test/resources/sling-launchpad.txt
   (with props)
    sling/trunk/contrib/commons/mom/jms/
    sling/trunk/contrib/commons/mom/jms/.gitignore
    sling/trunk/contrib/commons/mom/jms/README.md   (with props)
    sling/trunk/contrib/commons/mom/jms/pom.xml   (with props)
    sling/trunk/contrib/commons/mom/jms/src/
    sling/trunk/contrib/commons/mom/jms/src/main/
    sling/trunk/contrib/commons/mom/jms/src/main/java/
    sling/trunk/contrib/commons/mom/jms/src/main/java/org/
    sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/
    sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/
    sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/amq/
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/amq/ActiveMQConnectionFactoryService.java
   (with props)
    sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/ConnectionFactoryService.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/JMSMessageTypes.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/JMSQueueManager.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/JMSTopicManager.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/java/org/apache/sling/jms/Json.java
   (with props)
    sling/trunk/contrib/commons/mom/jms/src/main/resources/
    sling/trunk/contrib/commons/mom/jms/src/main/resources/org/
    sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/
    sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/sling/
    sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/sling/amq/
    
sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/sling/amq/activemq.xml
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/sling/amq/credentials.properties
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/main/resources/org/apache/sling/amq/jetty.xml
   (with props)
    sling/trunk/contrib/commons/mom/jms/src/test/
    sling/trunk/contrib/commons/mom/jms/src/test/java/
    sling/trunk/contrib/commons/mom/jms/src/test/java/org/
    sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/
    sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/
    sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/amq/
    
sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/amq/ActiveMQConnectionFactoryServiceTest.java
   (with props)
    sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/jms/
    
sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/jms/JMSQueueManagerTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/jms/JMSTopicManagerTest.java
   (with props)
    
sling/trunk/contrib/commons/mom/jms/src/test/java/org/apache/sling/jms/JsonTest.java
   (with props)
    sling/trunk/contrib/commons/mom/pom.xml   (with props)
Modified:
    
sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/junit/CrankstartSetup.java

Added: sling/trunk/contrib/commons/mom/api/README.md
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/README.md?rev=1754255&view=auto
==============================================================================
--- sling/trunk/contrib/commons/mom/api/README.md (added)
+++ sling/trunk/contrib/commons/mom/api/README.md Wed Jul 27 12:10:12 2016
@@ -0,0 +1,62 @@
+# Message Oriented Middleware API ( or message passing API).
+
+This bundle contains an API to support 2 types of message passing. Pub/Sub and 
Queue.
+Pub/Sub message passing supports the publication of messages to multiple 
subscribers. Queue 
+support guaranteed delivery of a message to one and only one receiver. Pub/Sub 
messages are
+organised by a Topic name. Queues are named. There are no implementation 
details in this 
+bundle and no bindings to any one MoM implementation, although it is expected 
that this 
+API could be implemented over either JMS or a AMQP client.
+
+# Publish Subscribe
+
+Messages that are sent to a topic by publishing are received by all 
subscribers that were active at the time the message is published.
+
+To publish a message use the [TopicManager 
API](src/main/java/org/apache/sling/mom/TopicManager.java)
+
+    topicManager.publish(String topic, Map<String, Object> message);
+    
+    where:
+        topic is the name of the topic to which the message is published 
+        message is the message as a Map or Maps.
+        
+To subscribe to a topic the caller must also use the [TopicManager 
API](src/main/java/org/apache/sling/mom/TopicManager.java)
+ 
+    Subscription subscription = subscribe(Subscriber subscriber, String[] 
topicNames,MessageFilter filter);
+    
+    where:
+          subscription is a Subsctipion objects which must be disposed (call 
dispose()) when the subscription ends.
+          topicNames is an array of topic names.
+          messageFilter is a MessageFilter implementation that accepts only 
those messages the subscriber is interested in.
+          
+The API does not impose any stcuture on topic names, but the underlying 
implementation might.
+
+# Queue
+
+A Queue implementation guarantees that messages will be delivered to one and 
only once QueueReader
+in the order in which the messages were added to the Queue. The QueueReader 
implementation may
+request to re-queue messages. The implementation should retry requeued 
messages after a suitable delay.
+
+To add a message to a named queue use the [QueueManager 
API](src/main/java/org/apache/sling/mom/QueueManager.java)
+
+
+        queueManager.add(String name, Map<String, Object> message);
+        
+        where: 
+           name is the name of the queue.
+           message is the message in map of maps form.
+           
+To recieve messages from the queue ise the [QueueManager 
API](src/main/java/org/apache/sling/mom/QueueManager.java)
+
+        QueueSession queueSession =  queueManager.open( QueueReader 
queueReader, String name, MessageFilter messageFilter);
+        
+        where:
+            queueSession is a QueueSession instance that must be closed (call 
close()) when the the queue reader requires no 
+                         more messages,
+            queueReader is a QueueReader implemetnation that will get 
delivered messages from the queue.
+            name is the name of the queueu.
+            messageFilter is a message filter intended to accept messages.
+            
+The QueueManager implementation will deliver messages to the 
queueReader.onMessage(...) method. The implementation of the 
QueueReader.onMessage method
+may process the message, returning normally, or request the message is 
requeued by throwing a RequeueMessageExption.
+
+

Propchange: sling/trunk/contrib/commons/mom/api/README.md
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/commons/mom/api/README.md
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/contrib/commons/mom/api/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/pom.xml?rev=1754255&view=auto
==============================================================================
--- sling/trunk/contrib/commons/mom/api/pom.xml (added)
+++ sling/trunk/contrib/commons/mom/api/pom.xml Wed Jul 27 12:10:12 2016
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>26</version>
+        <relativePath />
+    </parent>
+
+    <artifactId>org.apache.sling.mom</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <name>Apache Sling Message oriented Middleware API</name>
+    <description>
+        An API to support message passing using queues or publish/subscribe 
patterns.
+    </description>
+
+    <scm>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/commons/mom/api</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/mom/api</developerConnection>
+        
<url>http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api</url>
+    </scm>
+
+    <properties>
+        <site.jira.version.id>12315369</site.jira.version.id>
+        <sling.java.version>7</sling.java.version>
+        <exam.version>4.4.0</exam.version>
+        <url.version>2.4.5</url.version>
+        <bundle.build.dir>${basedir}/target</bundle.build.dir>
+        
<bundle.file.name>${bundle.build.dir}/${project.build.finalName}.jar</bundle.file.name>
+        <min.port>37000</min.port>
+        <max.port>37999</max.port>
+    </properties>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+    </dependencies>
+</project>

Propchange: sling/trunk/contrib/commons/mom/api/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/commons/mom/api/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.mom;
+
+import java.util.Map;
+
+/**
+ * Created by ieb on 30/03/2016.
+ * Filter inbound messages, optionally implemented by QueueReaders.
+ */
+public interface MessageFilter {
+    /**
+     * Provides message filtering, the implementation should return true if it 
wants to get the message, false if not.
+     * It should make these checks as fast as possible with minimal overhead 
to avoid consuming resources. Do not implement
+     * this method to process the message. Implementation code calling this 
method will be very latency sensitive
+     * and subscriptions using slow implementations may get unsubscribed.
+     * @param name the name of the queue or topic the message was sent on.
+     * @param mapMessage the message content.
+     * @return true if the message is to be allowed through the filter.
+     */
+    boolean accept(Types.Name name, Map<String, Object> mapMessage);
+
+
+
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/MessageFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,39 @@
+/*
+ * 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.sling.mom;
+
+import java.util.Map;
+
+/**
+ * Created by ieb on 31/03/2016.
+ * Manages named queues allowing messages to be added to the queue and a queue 
reader to be opened to read messages from a queue.
+ */
+public interface QueueManager {
+
+    /**
+     * Add the message to a queue identified by name.
+     * @param name the name of the queue.
+     * @param message the message to post to the queue.
+     */
+    void add(Types.QueueName name, Map<String, Object> message);
+
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,51 @@
+/*
+ * 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.sling.mom;
+
+import java.util.Map;
+
+/**
+ * Created by ieb on 30/03/2016.
+ * A queue reader receives messages from the queue in the onMessage method. It 
should avoid performing processing in
+ * the onMessage method aiming to return as fast as possible.
+ *
+ * This interface should be implemented as an OSGi Service. The implementation 
of the MoM API should register any services
+ * implementing QueueReader using the OSGi Whiteboard pattern.
+ */
+public interface QueueReader  {
+
+
+    /**
+     * Configuration property name for QueueReaders implemented using a 
whiteboard pattern.
+     */
+    String QUEUE_NAME_PROP = "queue-name";
+
+    /**
+     * Receive messages from the queue. If the message cant be processed at 
this time a RequeueMessageException must be thrown to cause the message
+     * to be requeued. Any other exception will cause the message to fail 
without a retry. Messages that fail are dropped and not notified except the 
logs.
+     * Implementors should avoid failing any message without a retry.
+     * @param queueName the name of the queue
+     * @param message the message
+     * @throws RequeueMessageException when the message must be re-queued.
+     */
+    void onMessage(Types.QueueName queueName, Map<String, Object> message) 
throws RequeueMessageException;
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/QueueReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.mom;
+
+/**
+ * Created by ieb on 02/04/2016.
+ * Thown when a queue reader cant process a message and needs to indicate that 
the message sould be re-queued and retried some time later.
+ */
+public class RequeueMessageException extends Exception {
+
+    /**
+     *
+     * @param message
+     */
+    public RequeueMessageException(String message) {
+        super(message);
+    }
+
+    /**
+     *
+     * @param message
+     * @param cause
+     */
+    public RequeueMessageException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/RequeueMessageException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.mom;
+
+import java.util.Map;
+
+/**
+ * Created by ieb on 30/03/2016.
+ *
+ * To implement a topic subscriber implement this interface, register it as an 
OSGi service and the TopicManager
+ * which will implement a OSGi Whiteboard pattern will register it based on 
the values in the OSGi property "topics".
+ * The component may optionally implement MessageFilter if it wants to 
separate filtering messages sooner.
+ */
+public interface Subscriber {
+
+    /**
+     * This is a String[] OSGi property containing the topic names this 
subscriber should subscribe to.
+     */
+    String TOPIC_NAMES_PROP = "topics";
+
+    /**
+     * Will be called with each message matching the filters the TopicListener 
is registered with.
+     *
+     * @param topic
+     * @param message
+     */
+    void onMessage(Types.TopicName topic, Map<String, Object> message);
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Subscriber.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.mom;
+
+
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by ieb on 30/03/2016.
+ * Manages Topics allowing callers to publish messages onto a Topic and 
Subscribe to a topic.
+ *
+ * To create a subscriber implement the Subscriber interface and the 
implementation of TopicManager should
+ * implement the OSGi whiteboard pattern.
+ */
+public interface TopicManager {
+
+
+
+    /**
+     * Publish a message to a topic with a command name.
+     * @param name the name
+     * @param commandName the command name
+     * @param message the message
+     */
+    void publish(Types.TopicName name, Types.CommandName commandName, 
Map<String, Object> message);
+
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/TopicManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,100 @@
+/*
+ * 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.sling.mom;
+
+/**
+ * Created by ieb on 13/04/2016.
+ */
+public final class Types {
+    private Types() {
+    }
+
+    public interface Name {
+    }
+    public interface TopicName extends Name {
+    }
+    public interface QueueName extends Name {
+    }
+    public interface CommandName {
+    }
+
+    public static TopicName topicName(String topicName) {
+        return new TopicNameImpl(topicName);
+    }
+
+    public static QueueName queueName(String queueName) {
+        return new QueueNameImpl(queueName);
+    }
+
+    public static CommandName commandName(String commandName) {
+        return new CommandNameImpl(commandName);
+    }
+
+
+    private static class QueueNameImpl extends StringWrapper implements 
QueueName {
+
+        private QueueNameImpl(String value) {
+            super(value);
+        }
+    }
+
+    private static class CommandNameImpl extends StringWrapper implements 
CommandName {
+
+        private CommandNameImpl(String value) {
+            super(value);
+        }
+    }
+
+    private static class TopicNameImpl extends StringWrapper implements 
TopicName {
+
+        private TopicNameImpl(String value) {
+            super(value);
+        }
+    }
+
+    private static class StringWrapper implements Comparable<String> {
+
+
+        private String value;
+
+        private StringWrapper(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public int hashCode() {
+            return value.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return value.equals(obj.toString());
+        }
+
+        @Override
+        public int compareTo(String o) {
+            return value.compareTo(o);
+        }
+
+        public String toString() {
+            return value;
+        }
+    }
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/Types.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java
 Wed Jul 27 12:10:12 2016
@@ -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.
+ */
+
+/**
+ * Created by ieb on 30/03/2016.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.mom;
+
+import aQute.bnd.annotation.Version;
\ No newline at end of file

Propchange: 
sling/trunk/contrib/commons/mom/api/src/main/java/org/apache/sling/mom/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/commons/mom/examples/jobs/core/README.md
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/README.md?rev=1754255&view=auto
==============================================================================
--- sling/trunk/contrib/commons/mom/examples/jobs/core/README.md (added)
+++ sling/trunk/contrib/commons/mom/examples/jobs/core/README.md Wed Jul 27 
12:10:12 2016
@@ -0,0 +1,7 @@
+# Sling Jobs, not to be confused with Sling Event bundle.
+
+This Bundle provides Job processing using a message queue. It aims to do that 
using off the shelf queues. It does not 
+provide an API that allows interaction with the queue beyond that is supported 
by the ISO AMQP standard or the JMS API. Although the 
+classes here may have similar names to the API in org.apache.sling.egent.jobs, 
they are not the same. Methods present
+in org.apache.sling.egent.jobs API that are not compatible with a distributed 
message queue concept are not included, and the 
+API is designed with message passing in mind.
\ No newline at end of file

Propchange: sling/trunk/contrib/commons/mom/examples/jobs/core/README.md
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/commons/mom/examples/jobs/core/README.md
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml?rev=1754255&view=auto
==============================================================================
--- sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml (added)
+++ sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml Wed Jul 27 
12:10:12 2016
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>26</version>
+        <relativePath />
+    </parent>
+
+    <artifactId>org.apache.sling.jobs</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <name>Apache Sling Jobs Support</name>
+    <description>
+        Support for Job processing using message passing..
+    </description>
+
+    <scm>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/commons/mom/examples/jobs/core</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/mom/examples/jobs/core</developerConnection>
+        
<url>http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core</url>
+    </scm>
+
+    <properties>
+        <site.jira.version.id>12315369</site.jira.version.id>
+        <sling.java.version>7</sling.java.version>
+        <exam.version>4.4.0</exam.version>
+        <url.version>2.4.5</url.version>
+        <bundle.build.dir>${basedir}/target</bundle.build.dir>
+        
<bundle.file.name>${bundle.build.dir}/${project.build.finalName}.jar</bundle.file.name>
+        <min.port>37000</min.port>
+        <max.port>37999</max.port>
+    </properties>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.mom</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <version>6.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <!-- 16.0.0 has a bug or 2 -->
+            <version>16.0.1</version>
+        </dependency>
+      <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.cm</artifactId>
+            <version>1.5.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.10.19</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/commons/mom/examples/jobs/core/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,160 @@
+/*
+ * 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.sling.jobs;
+
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.sling.mom.TopicManager;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Largely based on org.apache.sling.event.Job.
+ * A Job contains the complete state of the Job as known in the current JVM.
+ */
+public interface Job {
+
+
+
+    /**
+     * The current job state.
+     */
+    enum JobState {
+        QUEUED,     // waiting in queue after adding or for restart after 
failing
+        ACTIVE,     // job is currently in processing
+        SUCCEEDED,  // processing finished successfully
+        STOPPED,    // processing was stopped by a user
+        GIVEN_UP,   // number of retries reached
+        ERROR,      // processing signaled CANCELLED or throw an exception
+        ANY_STATE,  // Any active state.
+        CREATED, DROPPED     // dropped jobs
+    }
+
+    /**
+     * The job queue. - immutable.
+     * @return The job queue name
+     */
+    @Nonnull
+    Types.JobQueue getQueue();
+
+    /**
+     * Unique job ID. immutable.
+     * @return The unique job ID.
+     */
+    @Nonnull
+    String getId();
+
+
+    /**
+     * The job type. A job has a type, which is used by the Job Manager to 
offer up to JobConsumers implementing a JobTypeValve
+     * to accept.
+     * @return the job type.
+     */
+    @Nonnull
+    Types.JobType getJobType();
+
+    /**
+     * @return a map of all properties.
+     */
+    @Nonnull
+    Map<String,Object> getProperties();
+
+    /**
+     * On first execution the value of this property is zero.
+     * This property is managed by the job handling.
+     */
+    int getRetryCount();
+
+    /**
+     * The property to track the retry maximum retry count for jobs.
+     * This property is managed by the job handling.
+     */
+    int getNumberOfRetries();
+
+
+    /**
+     * The time when the job started.
+     */
+    long getStarted();
+
+    /**
+     * @return  The time when the job was created.
+     */
+    long getCreated();
+
+
+    /**
+     * Get the job state
+     */
+    @Nonnull
+    JobState getJobState();
+
+    /**
+     * Set the new state.
+     * @param newState
+     */
+    void setState(@Nonnull JobState newState);
+
+
+    /**
+     * If the job is cancelled or succeeded, this method will return the 
finish date.
+     * @return The finish date or <code>null</code>
+     */
+    long getFinished();
+
+    /**
+     * This method returns the message from the last job processing, regardless
+     * whether the processing failed, succeeded or was cancelled. The message
+     * is optional and can be set by a job consumer.
+     * @return The result message or <code>null</code>
+     */
+    @Nullable
+    String getResultMessage();
+
+    @Nonnull
+    JobUpdateBuilder newJobUpdateBuilder();
+
+
+    /**
+     * @return the controller associated with this Job, if one is present in 
the current JVM otherwise null.
+     */
+    @Nullable
+    JobController getController();
+
+
+    /**
+     * Set the current job controller.
+     */
+    void setJobController(@Nonnull JobController jobController);
+
+
+    /**
+     * Remove the current job controller.
+     */
+    void removeJobController();
+
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/Job.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jobs;
+
+import javax.annotation.Nonnull;
+import java.util.Map;
+
+/**
+ */
+public interface JobBuilder {
+
+    /**
+     * Set the optional configuration properties for the job.
+     * @param props The properties of the job. All values must be {@code 
java.io.Serializable}.
+     * @return The job builder to continue building.
+     */
+    @Nonnull
+    JobBuilder addProperties(@Nonnull Map<String, Object> props);
+
+    /**
+     * Add the job for processing.
+     * @return The job or <code>null</code>
+     */
+    @Nonnull
+    Job add();
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,30 @@
+/*
+ * 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.sling.jobs;
+
+/**
+ * Created by ieb on 13/04/2016.
+ * When a job is complete, the callback gets called.
+ * This interface is implemented by the Jobs Implementation and passed into a 
JobsConsumer.
+ */
+public interface JobCallback {
+
+    void callback(Job finalJobState);
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jobs;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Components that implement JobConsumers are registered with the Job Sub 
System by an OSGi Whiteboard pattern. Once
+ * registered the component will be offered jobs matching the job types set as 
the OSGi property JobConsumer.JOB_TYPES.
+ * If the consumer accepts the job, by not throwing and exception on the 
execute method, it agrees to ensure that the job
+ * is executed. It may queue the job, but if queued it must ensure the job is 
executed. A JobConsumer should check that he
+ * dependencies required to execute the job are satisfied before accepting the 
job for execution. Queueing jobs in the job consumer
+ * to ensure that the execution threads of the JobConsumer have work available 
is ok, but queuing jobs to remove them from
+ * the job queue is to be discouraged, as it may require too much from the 
JobConsumer implementation to guarantee the contract
+ * in this interface.
+ */
+public interface JobConsumer {
+
+    String JOB_TYPES = "job.types";
+
+    /**
+     * Execute the job, given an initial state and supply a JobStateListener 
to allow the job to send updates of state change
+     * @param initialState the initial state of the Job.
+     * @param listener a listener to propagate JobUpdates.
+     * @param callback called when the job is completed.
+     * @throws RuntimeException or any subclass when the Job offered in 
initialState cant be accepted for execution.
+     */
+    @Nonnull
+    void execute(@Nonnull Job initialState, @Nonnull JobUpdateListener 
listener, @Nonnull JobCallback callback);
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.jobs;
+
+/**
+ * Created by ieb on 30/03/2016.
+ * A job controller provides a mechanism by which a running job can be sent 
control messages.
+ * Jobs when they start should register a JobController implementation with 
the JobManager so that
+ * it can act on control messages sent. Alternatively a TopicListener can be 
used to route
+ * message to the Job, bypassing the manager, although this TopicListener will 
need to filter
+ * for all messages associated with the Job.
+ */
+public interface JobController {
+
+
+    /**
+     * Stop the job as soon as appropriate.
+     */
+    void stop();
+
+    /**
+     * Abort the job immediately.
+     */
+    void abort();
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,151 @@
+/*
+ * 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.sling.jobs;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Based on org.apache.sling.event.job.JobManager but trimmed down and 
adjusted to deal with distributed job queues.
+ */
+public interface JobManager {
+
+
+
+
+
+    /**
+     * Fluent API to create, start and schedule new jobs
+     * @param queue Required queue
+     * @param  jobType required job type.
+     * @return A job builder
+     */
+    @Nonnull
+    JobBuilder newJobBuilder(@Nonnull Types.JobQueue queue, @Nonnull 
Types.JobType jobType);
+
+    /**
+     * Return a job based on the unique id.
+     *
+     * The returned job object is a snapshot of the job state taken at the 
time of the call. Updates
+     * to the job state are not reflected and the client needs to get a new 
job object using the job id.
+     *
+     * @param jobId The unique identifier from {@link Job#getId()}
+     * @return A job or <code>null</code>
+     */
+
+    @Nullable
+    Job getJobById(@Nonnull String jobId);
+
+
+    /**
+     * Find a job - either queued or active.
+     *
+     * This method searches for a job with the given topic and filter 
properties. If more than one
+     * job matches, the first one found is returned which could be any of the 
matching jobs.
+     *
+     * The returned job object is a snapshot of the job state taken at the 
time of the call. Updates
+     * to the job state are not reflected and the client needs to get a new 
job object using the job id.
+     *
+     * Even if the method return null, the Job may exist remotely and has not 
yet sent any messages.
+     *
+     * @param queue Topic is required.
+     * @param template The map acts like a template. The searched job
+     *                    must match the template (AND query).
+     * @return A job or <code>null</code>
+     */
+    @Nullable
+    Job getJob(@Nonnull Types.JobQueue queue, @Nonnull Map<String, Object> 
template);
+
+    /**
+     * The requested job types for the query.
+     * This can either be all (unfinished) jobs, all activated (started) or 
all queued jobs.
+     */
+    enum QueryType {
+        ALL,      // all means all active and all queued
+        ACTIVE,
+        QUEUED,
+        HISTORY,    // returns the complete history of cancelled and succeeded 
jobs (if available)
+        CANCELLED,  // history of cancelled jobs (STOPPED, GIVEN_UP, ERROR, 
DROPPED)
+        SUCCEEDED,  // history of succeeded jobs
+        STOPPED,    // history of stopped jobs
+        GIVEN_UP,   // history of given up jobs
+        ERROR,      // history of jobs signaled CANCELLED or throw an exception
+        DROPPED     // history of dropped jobs
+    }
+    /**
+     * Return all jobs of a given type.
+     *
+     * Based on the type parameter, either the history of jobs can be returned 
or unfinished jobs. The type
+     * parameter can further specify which category of jobs should be 
returned: for the history either
+     * succeeded jobs, cancelled jobs or both in combination can be returned. 
For unfinished jobs, either
+     * queued jobs, started jobs or the combination can be returned.
+     * If the history is returned, the result set is sorted in descending 
order, listening the newest entry
+     * first. For unfinished jobs, the result set is sorted in ascending order.
+     *
+     * The returned job objects are a snapshot of the jobs state taken at the 
time of the call. Updates
+     * to the job states are not reflected and the client needs to get new job 
objects.
+     *
+     * The Jobs returned are only jobs known to the JobManager instance.
+     *
+     * @param type Required parameter for the type. See above.
+     * @param queue Queue Name can be used as a filter, if it is non-null, 
only jobs with this topic will be returned.
+     * @param limit A positive number indicating the maximum number of jobs 
returned by the iterator. A value
+     *              of zero or less indicates that all jobs should be returned.
+     * @param templates A list of filter property maps. Each map acts like a 
template. The searched job
+     *                    must match the template (AND query). By providing 
several maps, different filters
+     *                    are possible (OR query).
+     * @return A collection of jobs - the collection might be empty.
+     */
+    @Nonnull
+    Collection<Job> findJobs(@Nonnull QueryType type, @Nonnull Types.JobQueue 
queue, long limit, @Nullable Map<String, Object>... templates);
+
+    /**
+     * Stop a job, by sending a message.
+     * When a job is stopped and the job consumer supports stopping the job 
processing, it is up
+     * to the job consumer how the stopping is handled. The job can be marked 
as finished successful,
+     * permanently failed or being retried.
+     */
+    void stopJobById(@Nonnull String jobId);
+
+    /**
+     * Aborts a job by sending an abort message, may or may not be successful.
+     *
+     *
+     * @param jobId The unique identifier from {@link Job#getId()}
+     * @return <code>true</code> if the job could be removed or does not exist 
anymore.
+     *         <code>false</code> if the job is not know to the job manager, 
however the abort message should be sent anyway.
+     */
+    boolean abortJob(@Nonnull String jobId);
+
+
+    /**
+     * Retry a cancelled job, by requeuing.
+     * If a job has failed permanently it can be requeued with this method. 
The job will be
+     * removed from the history and put into the queue again. The new job will 
get a new job id.
+     * For all other jobs calling this method has no effect and it simply 
returns <code>null</code>.
+     * @param jobId The job id.
+     * @return If the job is requeued, the new job object otherwise 
<code>null</code>
+     */
+    @Nullable
+    Job retryJobById(@Nonnull String jobId);
+
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,34 @@
+/*
+ * 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.sling.jobs;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Created by ieb on 12/04/2016.
+ */
+public interface JobTypeValve {
+
+    /**
+     * Return true if the component, normally a JobConsumer, can process the 
jobType.
+     * @param jobType
+     * @return true if can be processed.
+     */
+    boolean accept(@Nonnull Types.JobType jobType);
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobTypeValve.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,162 @@
+/*
+ * 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.sling.jobs;
+
+import org.apache.sling.mom.TopicManager;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Map;
+
+/**
+ * Job updates are messages that update the state of the job at all 
subscribers.
+ * The distribution mechanism for JobUpdate messages must ensure that the 
messages are distributed appropriately so that
+ * the queues that contain the messages allow the messages to be acted on in 
an appropriate manner. For instance if the
+ * implementation decides that it will use a message queue to queue jobs as 
JobUpdate messages, then it may need to
+ * put the JobUpdates that start a message on a separate queue from the 
JobUpdates that update, abort or stop a job, so that
+ * those messages do not get delayed by a backlog of job start messages. 
Alternatively the implementation may decide to implement
+ * a scheduler that consumes job start messages at full queue throughput and 
queue jobs into a separate implementation specific queue.
+ * <p/>
+ * The API does not specify the implementation, only that the various 
JobUpdate messages are delivered with an delay appropriate for the
+ * type of message, identified by the JobUpdateCommand type.
+ */
+public interface JobUpdate {
+
+    /**
+     * The time of the update. The implementation may choose to adjust its 
concept of time to
+     * ensure the that JobUpdates it emits guaranteed to be applied in the 
correct order. How
+     * it achieves this is an implementation detail. Consumers of JobUpdates 
should define a policy
+     * on how updates are applied. Out of sequence updates may or may not be 
applied to a job, depending on
+     * the implementation.
+     * @return the timestamp of the update.
+     */
+    long updateTimestamp();
+
+
+    /**
+     * Update messages may have a time to live. Where the update command is 
abort or stop and the job message doesn't
+     * exist on the receiver the update message may be stored until the TTL 
expires before it is applied. This allows
+     * messages sent out of order to wait till expires has been reached before 
applying the update. The rules determining
+     * how expiring messages are applied is an implementation detail.
+     * @return
+     */
+    long expires();
+
+    /**
+     * The Job type. A job type is used to identify the type of job and hence 
the JobConsumer (via JobTypeValve) that can
+     * execute the Job.
+     * @return the job type.
+     */
+    @Nonnull
+    Types.JobType getJobType();
+
+    enum JobUpdateCommand {
+        START_JOB,       // Starts the job.
+        UPDATE_JOB,     // Update the job.
+        ABORT_JOB,      // Abort the job, if the receiver is running the job, 
then it must abort it.
+        RETRY_JOB,      // Retry the job.
+        STOP_JOB        // Stop the job from running, but if already running 
let the job complete
+        ;
+
+        public org.apache.sling.mom.Types.CommandName asCommandName() {
+            return org.apache.sling.mom.Types.commandName(toString());
+        }
+    }
+
+
+    /**
+     * @return the type of update.
+     */
+    @Nonnull
+    JobUpdateCommand  getCommand();
+
+
+    /**
+     * The job queue. - immutable.
+     * @return The job queue
+     */
+    @Nonnull
+    Types.JobQueue getQueue();
+
+    /**
+     * Unique job ID. immutable.
+     * @return The unique job ID.
+     */
+    @Nonnull
+    String getId();
+
+    /**
+     *
+     * @return the new state of the job, may not have changed from the old 
state.
+     */
+    @Nonnull
+    Job.JobState getState();
+
+    enum JobPropertyAction {
+        REMOVE
+    }
+
+    /**
+     * The changed properties of the job. A property value of 
JobPropertyAction.REMOVE causes the property to be removed.
+     * Property types cant be changed in 1 message.
+     * @return the map of property changes, will be <code>null</code> if the 
update message does not contain property changes.
+     */
+    @Nonnull
+    Map<String, Object> getProperties();
+
+    /**
+     * On first execution the value of this property is zero.
+     * This property is managed by the job handling.
+     */
+    int getRetryCount();
+
+    /**
+     * The property to track the retry maximum retry count for jobs.
+     * This property is managed by the job handling.
+     */
+    int getNumberOfRetries();
+
+
+    /**
+     * The time when the job started.
+     */
+    long getStarted();
+
+    /**
+     * @return  The time when the job was created.
+     */
+    long getCreated();
+
+
+    /**
+     * If the job is cancelled or succeeded, this method will return the 
finish date.
+     * @return The finish date or <code>null</code>
+     */
+    long getFinished();
+
+    /**
+     * This method returns the message from the last job processing, regardless
+     * whether the processing failed, succeeded or was cancelled. The message
+     * is optional and can be set by a job consumer.
+     * @return The result message or <code>null</code>
+     */
+    @Nullable
+    String getResultMessage();
+
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.jobs;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Map;
+
+/**
+ * Created by ieb on 14/04/2016.
+ */
+public interface JobUpdateBuilder {
+
+    @Nonnull
+    JobUpdateBuilder command(@Nonnull JobUpdate.JobUpdateCommand command);
+
+    @Nonnull
+    JobUpdate build();
+
+    /**
+     * Set a property to update.
+     * @param name the name of the property
+     * @param value the value of the property which may be null. To remove the 
property set the value to JobUpdate.JobPropertyAction.REMOVE.
+     * @return this JobBuilder instance.
+     */
+    @Nonnull
+    JobUpdateBuilder put(@Nonnull String name, @Nullable Object value);
+
+    @Nonnull
+    JobUpdateBuilder putAll(@Nonnull Map<String, Object> properties);
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java?rev=1754255&view=auto
==============================================================================
--- 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
 (added)
+++ 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
 Wed Jul 27 12:10:12 2016
@@ -0,0 +1,34 @@
+/*
+ * 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.sling.jobs;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Listens for JobUpdate messages.
+ * Examples of a JobUpdateListener include implementations of a Job that 
consumes JobUpdateMessages, or JobConsumers that execute a Job.
+ */
+public interface JobUpdateListener {
+
+    /**
+     * Update the job state with a message.
+     * @param update
+     */
+    void update(@Nonnull JobUpdate update);
+}

Propchange: 
sling/trunk/contrib/commons/mom/examples/jobs/core/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
------------------------------------------------------------------------------
    svn:eol-style = native



Reply via email to