camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [02/14] camel git commit: Initial commit
Date Mon, 01 Jun 2015 07:10:16 GMT
Initial commit


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

Branch: refs/heads/master
Commit: 352a306b12b9f00585b4f4d20bf570f594f685b6
Parents: 0b4a167
Author: Mike Kennedy <michael.kennedy@ucr.edu>
Authored: Sat May 30 23:18:56 2015 -0700
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Jun 1 08:55:11 2015 +0200

----------------------------------------------------------------------
 components/camel-slack/pom.xml                  | 46 ++++++++++
 .../camel/component/slack/SlackComponent.java   | 49 ++++++++++
 .../camel/component/slack/SlackEndpoint.java    | 94 ++++++++++++++++++++
 .../camel/component/slack/SlackProducer.java    |  4 +
 4 files changed, 193 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/352a306b/components/camel-slack/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-slack/pom.xml b/components/camel-slack/pom.xml
new file mode 100644
index 0000000..121826b
--- /dev/null
+++ b/components/camel-slack/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+        <artifactId>components</artifactId>
+        <groupId>org.apache.camel</groupId>
+        <version>2.16-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-slack</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: Slack</name>
+    <description>Camel Slack Support</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/352a306b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponent.java
b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponent.java
new file mode 100644
index 0000000..af5ca6c
--- /dev/null
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponent.java
@@ -0,0 +1,49 @@
+package org.apache.camel.component.slack;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class SlackComponent extends DefaultComponent {
+
+    private static final transient Logger LOG = LoggerFactory.getLogger(SlackComponent.class);
+
+    private String webhookUrl;
+
+    /**
+     * Create a slack endpoint
+     *
+     * @param uri the full URI of the endpoint
+     * @param channelName the channel or username that the message should be sent to
+     * @param parameters the optional parameters passed in
+     * @return the camel endpoint
+     * @throws Exception
+     */
+    @Override
+    protected Endpoint createEndpoint(String uri, String channelName, Map<String, Object>
parameters) throws Exception {
+        Endpoint endpoint = new SlackEndpoint(uri, channelName, this);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+
+    /**
+     * Getter for the incoming webhook URL
+     *
+     * @return String containing the incoming webhook URL
+     */
+    public String getWebhookUrl() {
+        return webhookUrl;
+    }
+
+    /**
+     * Setter for the incoming webhook URL
+     *
+     * @param webhookUrl the incoming webhook URL
+     */
+    public void setWebhookUrl(String webhookUrl) {
+        this.webhookUrl = webhookUrl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/352a306b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java
b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java
new file mode 100644
index 0000000..6e51579
--- /dev/null
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackEndpoint.java
@@ -0,0 +1,94 @@
+package org.apache.camel.component.slack;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SlackEndpoint extends DefaultEndpoint {
+
+    private static final transient Logger LOG = LoggerFactory.getLogger(SlackEndpoint.class);
+
+    private String webhookUrl;
+    private String username;
+    private String channel;
+    private String iconUrl;
+    private String iconEmoji;
+
+    /**
+     * Constructor for SlackEndpoint
+     *
+     * @param uri the full component url
+     * @param channelName the channel or username the message is directed at
+     * @param component the component that was created
+     */
+    public SlackEndpoint(String uri, String channelName, SlackComponent component) {
+        super(uri, component);
+        this.webhookUrl = component.getWebhookUrl();
+        this.channel = channelName;
+    }
+
+    /**
+     * Creates a SlackProducer
+     *
+     * @return SlackProducer
+     * @throws Exception
+     */
+    @Override
+    public Producer createProducer() throws Exception {
+        SlackProducer producer = new SlackProducer(this);
+        return producer;
+    }
+
+    /**
+     * Unsupported operation
+     *
+     * @param processor
+     * @return
+     * @throws java.lang.UnsupportedOperationException
+     */
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("You cannot consume slack messages from this
endpoint: " + getEndpointUri());
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public String getWebhookUrl() {
+        return webhookUrl;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getChannel() {
+        return channel;
+    }
+
+    public String getIconUrl() {
+        return iconUrl;
+    }
+
+    public void setIconUrl(String iconUrl) {
+        this.iconUrl = iconUrl;
+    }
+
+    public String getIconEmoji() {
+        return iconEmoji;
+    }
+
+    public void setIconEmoji(String iconEmoji) {
+        this.iconEmoji = iconEmoji;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/352a306b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
new file mode 100644
index 0000000..f3a5b1c
--- /dev/null
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java
@@ -0,0 +1,4 @@
+package org.apache.camel.component.slack;
+
+public class SlackProducer {
+}


Mime
View raw message