You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2016/04/07 11:17:29 UTC

svn commit: r1738113 - in /sling/trunk/bundles/commons/org.apache.sling.commons.messaging: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/commons/ src/main/ja...

Author: olli
Date: Thu Apr  7 09:17:29 2016
New Revision: 1738113

URL: http://svn.apache.org/viewvc?rev=1738113&view=rev
Log:
SLING-5643 Provide a simple messaging API

Added:
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/README.md
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/pom.xml
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Failure.java
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/MessageService.java
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Result.java
    sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/package-info.java

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/README.md
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/README.md?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/README.md (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/README.md Thu Apr  7 09:17:29 2016
@@ -0,0 +1,23 @@
+Apache Sling Commons Messaging
+==============================
+
+Simple API for sending *message*​s to *recipient*​s.
+
+`MessageService`
+----------------
+  * `send(String, String)` - takes a *message*​ and a *recipient*, e.g.
+    * send("A Message to You, Rudy", "rudy@ghosttown") - send a mail to Rudy in Ghost Town
+    * send("Hello Apache!", "+1.919.573.9199") - send a fax to the ASF
+  * `send(String, String, Map)` - takes a *message*, a *recipient* and additional *data* useful for the underlying implementation to process and/or send the message
+
+`Result<T>`
+-----------
+  * `getMessage():T` - should return a serialized form of the sent *message*
+  * `hasFailures():boolean` - should return `true` in case of failures, `false` otherwise
+  * `getFailures():Collection<Failure>` - should return the failures occurred when processing or sending the message
+
+`Failure`
+---------
+ * `getCode():String` - should return a failure code when available, e.g. an [SMTP Status Code](https://tools.ietf.org/html/rfc5248)
+ * `getType():String` - should return a failure type when available, e.g. invalid input (message too big) or transport failure (host unavailable)
+ * `getMessage():String` - should return a human readable failure message

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/pom.xml?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/pom.xml (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/pom.xml Thu Apr  7 09:17:29 2016
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>sling</artifactId>
+    <version>27-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <artifactId>org.apache.sling.commons.messaging</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Sling Commons Messaging</name>
+  <description>Apache Sling Commons Messaging</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <sling.java.version>8</sling.java.version>
+  </properties>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/org.apache.sling.commons.messaging</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/org.apache.sling.commons.messaging</developerConnection>
+    <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- OSGi -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>osgi.annotation</artifactId>
+      <version>6.0.1</version>
+      <scope>provided</scope>
+    </dependency>
+    <!-- JSR 305-->
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Failure.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Failure.java?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Failure.java (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Failure.java Thu Apr  7 09:17:29 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.commons.messaging;
+
+import javax.annotation.CheckForNull;
+
+import org.osgi.annotation.versioning.ProviderType;
+
+@ProviderType
+public interface Failure {
+
+    /**
+     * @return a failure code when available
+     */
+    @CheckForNull String getCode();
+
+    /**
+     * @return a failure type when available
+     */
+    @CheckForNull String getType();
+
+    /**
+     * @return a human readable failure message
+     */
+    @CheckForNull String getMessage();
+
+}

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/MessageService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/MessageService.java?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/MessageService.java (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/MessageService.java Thu Apr  7 09:17:29 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.commons.messaging;
+
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.annotation.Nonnull;
+
+import org.osgi.annotation.versioning.ProviderType;
+
+@ProviderType
+public interface MessageService {
+
+    /**
+     * @param message   the message to send
+     * @param recipient the recipient of the message
+     * @return result of sending the message
+     */
+    Future<Result> send(@Nonnull final String message, @Nonnull final String recipient);
+
+    /**
+     * @param message   the message to send
+     * @param recipient the recipient of the message
+     * @param data      additional information (e.g. attachments) and/or parameters (e.g. sender) for the message
+     * @return result of sending the message
+     */
+    Future<Result> send(@Nonnull final String message, @Nonnull final String recipient, @Nonnull final Map data);
+
+}

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Result.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Result.java?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Result.java (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/Result.java Thu Apr  7 09:17:29 2016
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.commons.messaging;
+
+import java.util.Collection;
+
+import javax.annotation.CheckForNull;
+
+import org.osgi.annotation.versioning.ProviderType;
+
+@ProviderType
+public interface Result<T> {
+
+    /**
+     * @return serialized form of the sent message
+     */
+    @CheckForNull T getMessage();
+
+    /**
+     * @return <code>true</code> in case of failures, <code>false</code> otherwise
+     */
+    boolean hasFailures();
+
+    /**
+     * @return the failures occurred when processing or sending the message
+     */
+    @CheckForNull Collection<Failure> getFailures();
+
+}

Added: sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/package-info.java?rev=1738113&view=auto
==============================================================================
--- sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/package-info.java (added)
+++ sling/trunk/bundles/commons/org.apache.sling.commons.messaging/src/main/java/org/apache/sling/commons/messaging/package-info.java Thu Apr  7 09:17:29 2016
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+@Version("1.0.0")
+package org.apache.sling.commons.messaging;
+
+import org.osgi.annotation.versioning.Version;