You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/06/06 20:30:35 UTC

svn commit: r1132722 [1/2] - in /camel/trunk: apache-camel/ apache-camel/src/main/descriptors/ components/ components/camel-apns/ components/camel-apns/src/ components/camel-apns/src/main/ components/camel-apns/src/main/java/ components/camel-apns/src/...

Author: davsclaus
Date: Mon Jun  6 18:30:33 2011
New Revision: 1132722

URL: http://svn.apache.org/viewvc?rev=1132722&view=rev
Log:
CAMEL-3868: New camel-apns component. Thanks to Alexis Kinsella for donation to Apache.

Added:
    camel/trunk/components/camel-apns/   (with props)
    camel/trunk/components/camel-apns/pom.xml   (with props)
    camel/trunk/components/camel-apns/src/
    camel/trunk/components/camel-apns/src/main/
    camel/trunk/components/camel-apns/src/main/java/
    camel/trunk/components/camel-apns/src/main/java/org/
    camel/trunk/components/camel-apns/src/main/java/org/apache/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java   (with props)
    camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java   (with props)
    camel/trunk/components/camel-apns/src/main/resources/
    camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt   (with props)
    camel/trunk/components/camel-apns/src/main/resources/META-INF/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/apns
    camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt   (with props)
    camel/trunk/components/camel-apns/src/test/
    camel/trunk/components/camel-apns/src/test/java/
    camel/trunk/components/camel-apns/src/test/java/com/
    camel/trunk/components/camel-apns/src/test/java/com/notnoop/
    camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/
    camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/
    camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/
    camel/trunk/components/camel-apns/src/test/java/org/apache/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerWithoutTokensHeaderTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ApnsServiceFactoryTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/spring/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/spring/SpringApnsConsumerTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/ApnsUtils.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/AssertUtilsTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/StringUtilsTest.java   (with props)
    camel/trunk/components/camel-apns/src/test/resources/
    camel/trunk/components/camel-apns/src/test/resources/log4j.properties   (with props)
    camel/trunk/components/camel-apns/src/test/resources/org/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/camel/component/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/camel/component/apns/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/
    camel/trunk/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/SpringApnsConsumerTest-context.xml   (with props)
Modified:
    camel/trunk/apache-camel/pom.xml
    camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
    camel/trunk/components/pom.xml
    camel/trunk/parent/pom.xml

Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1132722&r1=1132721&r2=1132722&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Mon Jun  6 18:30:33 2011
@@ -57,6 +57,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-apns</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-atom</artifactId>
     </dependency>
     <dependency>

Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1132722&r1=1132721&r2=1132722&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Mon Jun  6 18:30:33 2011
@@ -35,6 +35,7 @@
       <includes>
         <include>org.apache.camel:camel-ahc</include>
         <include>org.apache.camel:camel-amqp</include>
+        <include>org.apache.camel:camel-apns</include>
         <include>org.apache.camel:camel-atom</include>
         <include>org.apache.camel:camel-aws</include>
         <include>org.apache.camel:camel-bam</include>

Propchange: camel/trunk/components/camel-apns/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun  6 18:30:33 2011
@@ -0,0 +1,9 @@
+.project
+.checkstyle
+.pmd
+.classpath
+target
+.settings
+eclipse-classes
+*.i??
+classes

Added: camel/trunk/components/camel-apns/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/pom.xml?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/pom.xml (added)
+++ camel/trunk/components/camel-apns/pom.xml Mon Jun  6 18:30:33 2011
@@ -0,0 +1,120 @@
+<?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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>2.8-SNAPSHOT</version>
+    <relativePath>../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-apns</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Camel :: APNS</name>
+  <description>A Camel Apple Push Notification Server Component</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.component.apns.*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+
+    <!-- Camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <!-- Apns -->
+    <dependency>
+      <groupId>com.notnoop.apns</groupId>
+      <artifactId>apns</artifactId>
+      <version>${java-apns-version}</version>
+      <exclusions>
+         <exclusion>
+           <groupId>ch.qos.logback</groupId>
+           <artifactId>logback-classic</artifactId>
+         </exclusion>
+       </exclusions>
+    </dependency>
+
+    <!-- Camel for test -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Spring -->
+    <!-- Use of Spring for tests -->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Logging -->
+    <!-- Use logging for test -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Junit -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- for testing apns -->
+    <dependency>
+      <groupId>com.notnoop.apns</groupId>
+      <artifactId>apns</artifactId>
+      <version>${java-apns-version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>

Propchange: camel/trunk/components/camel-apns/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-apns/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apns;
+
+import java.util.Map;
+
+import com.notnoop.apns.ApnsService;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Represents the component that manages {@link ApnsEndpoint}. It holds the list
+ * of named apns endpoints.
+ */
+public class ApnsComponent extends DefaultComponent {
+
+    private ApnsService apnsService;
+
+    public ApnsComponent() {
+        super();
+    }
+
+    public ApnsComponent(ApnsService apnsService) {
+        super();
+        ObjectHelper.notNull(apnsService, "apnsService");
+        this.apnsService = apnsService;
+    }
+
+    public ApnsComponent(CamelContext context) {
+        super(context);
+    }
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        ApnsEndpoint endpoint = new ApnsEndpoint(uri, this);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+
+    public ApnsService getApnsService() {
+        return apnsService;
+    }
+
+    public void setApnsService(ApnsService apnsService) {
+        this.apnsService = apnsService;
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,102 @@
+/**
+ * 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.camel.component.apns;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.apns.model.InactiveDevice;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+public class ApnsConsumer extends ScheduledPollConsumer {
+
+    // TODO: Is the delay relay 3600 seconds?
+    private static final int DEFAULT_CONSUME_INITIAL_DELAY = 10;
+    private static final int DEFAULT_CONSUME_DELAY = 3600;
+    private static final boolean DEFAULT_APNS_FIXED_DELAY = true;
+
+    public ApnsConsumer(ApnsEndpoint apnsEndpoint, Processor processor) {
+        super(apnsEndpoint, processor);
+
+        setInitialDelay(DEFAULT_CONSUME_INITIAL_DELAY);
+        setDelay(DEFAULT_CONSUME_DELAY);
+        setUseFixedDelay(DEFAULT_APNS_FIXED_DELAY);
+    }
+
+    protected int poll() throws Exception {
+        List<InactiveDevice> inactiveDeviceList = getInactiveDevices();
+
+        Iterator<InactiveDevice> it = inactiveDeviceList.iterator();
+
+        while (it.hasNext()) {
+            InactiveDevice inactiveDevice = it.next();
+
+            Exchange e = getEndpoint().createExchange();
+            e.getIn().setBody(inactiveDevice);
+            getProcessor().process(e);
+        }
+
+        return inactiveDeviceList.size();
+    }
+
+    private List<InactiveDevice> getInactiveDevices() {
+        ApnsEndpoint ae = getEndpoint();
+
+        Map<String, Date> inactiveDeviceMap = ae.getApnsService().getInactiveDevices();
+
+        List<InactiveDevice> inactiveDeviceList = new ArrayList<InactiveDevice>();
+        for (Entry<String, Date> inactiveDeviceEntry : inactiveDeviceMap.entrySet()) {
+            String deviceToken = inactiveDeviceEntry.getKey();
+            Date date = inactiveDeviceEntry.getValue();
+
+            InactiveDevice inactiveDevice = new InactiveDevice(deviceToken, date);
+            inactiveDeviceList.add(inactiveDevice);
+        }
+
+        return inactiveDeviceList;
+    }
+
+    @Override
+    public ApnsEndpoint getEndpoint() {
+        return (ApnsEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        // only add as consumer if not already registered
+        if (!getEndpoint().getConsumers().contains(this)) {
+            if (!getEndpoint().getConsumers().isEmpty()) {
+                throw new IllegalStateException("Endpoint " + getEndpoint().getEndpointUri() + " only allows 1 active consumer but you attempted to start a 2nd consumer.");
+            }
+            getEndpoint().getConsumers().add(this);
+        }
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        getEndpoint().getConsumers().remove(this);
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,80 @@
+/**
+ * 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.camel.component.apns;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import com.notnoop.apns.ApnsService;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.impl.ScheduledPollEndpoint;
+
+/**
+ * Represents a direct endpoint that synchronously invokes the consumers of the
+ * endpoint when a producer sends a message to it.
+ */
+public class ApnsEndpoint extends ScheduledPollEndpoint {
+
+    private CopyOnWriteArraySet<DefaultConsumer> consumers = new CopyOnWriteArraySet<DefaultConsumer>();
+
+    private String tokens;
+
+    public ApnsEndpoint(String uri, ApnsComponent component) {
+        super(uri, component);
+    }
+
+    public String getTokens() {
+        return tokens;
+    }
+
+    public void setTokens(String tokens) {
+        this.tokens = tokens;
+    }
+
+    private ApnsComponent getApnsComponent() {
+        return (ApnsComponent)getComponent();
+    }
+
+    public ApnsService getApnsService() {
+        return getApnsComponent().getApnsService();
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    protected Set<DefaultConsumer> getConsumers() {
+        return consumers;
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+
+        ApnsConsumer apnsConsumer = new ApnsConsumer(this, processor);
+        configureConsumer(apnsConsumer);
+
+        return apnsConsumer;
+    }
+
+    public Producer createProducer() throws Exception {
+        return new ApnsProducer(this);
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,127 @@
+/**
+ * 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.camel.component.apns;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import com.notnoop.apns.APNS;
+import com.notnoop.exceptions.ApnsException;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.apns.model.ApnsConstants;
+import org.apache.camel.component.apns.model.MessageType;
+import org.apache.camel.component.apns.util.StringUtils;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class ApnsProducer extends DefaultProducer {
+
+    private ApnsEndpoint endpoint;
+    private List<String> tokenList;
+
+    public ApnsProducer(ApnsEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        initiate(endpoint);
+    }
+
+    private void initiate(ApnsEndpoint apnsEndpoint) {
+        configureTokens(apnsEndpoint);
+    }
+
+    private void configureTokens(ApnsEndpoint apnsEndpoint) {
+        if (ObjectHelper.isNotEmpty(apnsEndpoint.getTokens())) {
+            this.tokenList = extractTokensFromString(apnsEndpoint.getTokens());
+        }
+    }
+
+    public boolean isTokensConfiguredUsingUri() {
+        return tokenList != null;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        notify(exchange);
+    }
+
+    private void notify(Exchange exchange) throws ApnsException {
+        String message = exchange.getIn().getBody(String.class);
+
+        Collection<String> tokens = null;
+        if (isTokensConfiguredUsingUri()) {
+            if (hasTokensHeader(exchange)) {
+                throw new IllegalArgumentException("Tokens already configured on endpoint " + ApnsConstants.HEADER_TOKENS);
+            }
+            tokens = new ArrayList<String>(tokenList);
+        } else {
+            String tokensHeader = getHeaderTokens(exchange);
+            tokens = extractTokensFromString(tokensHeader);
+        }
+
+        MessageType messageType = getHeaderMessageType(exchange, MessageType.STRING);
+
+        String payload;
+        if (messageType == MessageType.STRING) {
+            payload = APNS.newPayload().alertBody(message).build();
+        } else {
+            payload = message;
+        }
+
+        endpoint.getApnsService().push(tokens, payload);
+    }
+
+    public String getHeaderTokens(Exchange exchange) {
+        return exchange.getIn().getHeader(ApnsConstants.HEADER_TOKENS, String.class);
+    }
+
+    public MessageType getHeaderMessageType(Exchange exchange, MessageType defaultMessageType) {
+        String messageTypeStr = (String)exchange.getIn().getHeader(ApnsConstants.HEADER_MESSAGE_TYPE);
+
+        if (messageTypeStr == null) {
+            return defaultMessageType;
+        }
+
+        MessageType messageType = MessageType.valueOf(messageTypeStr);
+        return messageType;
+    }
+
+    private boolean hasTokensHeader(Exchange exchange) {
+        return getHeaderTokens(exchange) != null;
+    }
+
+    private List<String> extractTokensFromString(String tokensStr) {
+        tokensStr = StringUtils.trim(tokensStr);
+        if (tokensStr.isEmpty()) {
+            throw new IllegalArgumentException("No token specified");
+        }
+
+        String[] tokenArray = tokensStr.split(";");
+        int tokenArrayLength = tokenArray.length;
+        for (int i = 0; i < tokenArrayLength; i++) {
+            String token = tokenArray[i];
+            tokenArray[i] = token.trim();
+            int tokenLength = token.length();
+            if (tokenLength != 64) {
+                throw new IllegalArgumentException("Token has wrong size['" + tokenLength + "']: " + token);
+            }
+        }
+        List<String> tokens = Arrays.asList(tokenArray);
+        return tokens;
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,256 @@
+/**
+ * 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.camel.component.apns.factory;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import javax.net.ssl.SSLContext;
+
+import com.notnoop.apns.APNS;
+import com.notnoop.apns.ApnsDelegate;
+import com.notnoop.apns.ApnsService;
+import com.notnoop.apns.ApnsServiceBuilder;
+import com.notnoop.apns.ReconnectPolicy;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.component.apns.model.ConnectionStrategy;
+import org.apache.camel.component.apns.model.ReconnectionPolicy;
+import org.apache.camel.component.apns.util.AssertUtils;
+import org.apache.camel.component.apns.util.ParamUtils;
+import org.apache.camel.component.apns.util.ResourceUtils;
+import org.apache.camel.util.ObjectHelper;
+
+public class ApnsServiceFactory implements CamelContextAware {
+
+    private static final int DEFAULT_POOL_SIZE = 10;
+    private static final int MIN_POOL_SIZE = 1;
+    private static final int MAX_POOL_SIZE = 30;
+
+    private CamelContext camelContext;
+    private String certificatePath;
+    private String certificatePassword;
+    private ConnectionStrategy connectionStrategy;
+    private ReconnectionPolicy reconnectionPolicy;
+    private SSLContext sslContext;
+    private int poolSize = DEFAULT_POOL_SIZE;
+    private String gatewayHost;
+    private int gatewayPort;
+    private String feedbackHost;
+    private int feedbackPort;
+    private ApnsDelegate apnsDelegate;
+
+    public ApnsServiceFactory() {
+        super();
+    }
+
+    public ApnsServiceFactory(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    public String getFeedbackHost() {
+        return feedbackHost;
+    }
+
+    public void setFeedbackHost(String feedbackHost) {
+        this.feedbackHost = feedbackHost;
+    }
+
+    public String getGatewayHost() {
+        return gatewayHost;
+    }
+
+    public void setGatewayHost(String gatewayHost) {
+        this.gatewayHost = gatewayHost;
+    }
+
+    public int getGatewayPort() {
+        return gatewayPort;
+    }
+
+    public void setGatewayPort(int gatewayPort) {
+        this.gatewayPort = gatewayPort;
+    }
+
+    public int getFeedbackPort() {
+        return feedbackPort;
+    }
+
+    public void setFeedbackPort(int feedbackPort) {
+        this.feedbackPort = feedbackPort;
+    }
+
+    public int getPoolSize() {
+        return poolSize;
+    }
+
+    public void setPoolSize(int poolSize) {
+        this.poolSize = poolSize;
+    }
+
+    public String getCertificatePath() {
+        return certificatePath;
+    }
+
+    public void setCertificatePath(String certificatePath) {
+        this.certificatePath = certificatePath;
+    }
+
+    public String getCertificatePassword() {
+        return certificatePassword;
+    }
+
+    public void setCertificatePassword(String certificatePassword) {
+        this.certificatePassword = certificatePassword;
+    }
+
+    public ReconnectionPolicy getReconnectionPolicy() {
+        return reconnectionPolicy;
+    }
+
+    public void setReconnectionPolicy(ReconnectionPolicy reconnectionPolicy) {
+        this.reconnectionPolicy = reconnectionPolicy;
+    }
+
+    public ConnectionStrategy getConnectionStrategy() {
+        return connectionStrategy;
+    }
+
+    public void setConnectionStrategy(ConnectionStrategy connectionStrategy) {
+        this.connectionStrategy = connectionStrategy;
+    }
+
+    public SSLContext getSslContext() {
+        return sslContext;
+    }
+
+    public void setSslContext(SSLContext sslContext) {
+        this.sslContext = sslContext;
+    }
+
+    public ApnsDelegate getApnsDelegate() {
+        return apnsDelegate;
+    }
+
+    public ApnsService getApnsService() {
+        ApnsServiceBuilder builder = APNS.newService();
+
+        configureConnectionStrategy(builder);
+        configureReconnectionPolicy(builder);
+        configureApnsDelegate(builder);
+        configureApnsDestinations(builder);
+        try {
+            configureApnsCertificate(builder);
+        } catch (FileNotFoundException e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        ApnsService apnsService = builder.build();
+        return apnsService;
+    }
+
+    private void configureApnsCertificate(ApnsServiceBuilder builder) throws FileNotFoundException {
+        if (getSslContext() != null) {
+            builder.withSSLContext(getSslContext());
+            return;
+        }
+
+        ObjectHelper.notNull(getCamelContext(), "camelContext");
+        ObjectHelper.notEmpty(getCertificatePath(), "certificatePath");
+        ObjectHelper.notEmpty(getCertificatePassword(), "certificatePassword");
+
+        InputStream certificateInputStream = null;
+        try {
+            certificateInputStream = camelContext.getClassResolver().loadResourceAsStream(getCertificatePath());
+            if (certificateInputStream == null) {
+                throw new FileNotFoundException("Cannot load " + getCertificatePath() + " from classpath");
+            }
+            builder.withCert(certificateInputStream, getCertificatePassword()).withProductionDestination();
+        } finally {
+            ResourceUtils.close(certificateInputStream);
+        }
+    }
+
+    private void configureApnsDestinations(ApnsServiceBuilder builder) {
+        ParamUtils.checkDestination(getGatewayHost(), getGatewayPort(), "gateway");
+        ParamUtils.checkDestination(getFeedbackHost(), getFeedbackPort(), "feedback");
+
+        if (ObjectHelper.isNotEmpty(getGatewayHost())) {
+            builder.withGatewayDestination(getGatewayHost(), getGatewayPort());
+        }
+        if (ObjectHelper.isNotEmpty(getFeedbackHost())) {
+            builder.withFeedbackDestination(getFeedbackHost(), getFeedbackPort());
+        }
+    }
+
+    private void configureApnsDelegate(ApnsServiceBuilder builder) {
+        if (apnsDelegate != null) {
+            builder.withDelegate(apnsDelegate);
+        }
+    }
+
+    private void configureConnectionStrategy(ApnsServiceBuilder builder) {
+        if (getConnectionStrategy() == ConnectionStrategy.POOL) {
+            AssertUtils.isTrue(poolSize >= MIN_POOL_SIZE, "Pool size needs to be greater than: " + MIN_POOL_SIZE);
+            AssertUtils.isTrue(poolSize <= MAX_POOL_SIZE, "Pool size needs to be lower than: " + MAX_POOL_SIZE);
+        }
+
+        if (getConnectionStrategy() == null) {
+            return;
+        }
+
+        switch (getConnectionStrategy()) {
+        case NON_BLOCKING:
+            builder.asNonBlocking();
+            break;
+        case QUEUE:
+            builder.asQueued();
+            break;
+        case POOL:
+            builder.asPool(getPoolSize());
+            break;
+        default:
+            break;
+        }
+    }
+
+    private void configureReconnectionPolicy(ApnsServiceBuilder builder) {
+        if (getReconnectionPolicy() == null) {
+            return;
+        }
+
+        switch (getReconnectionPolicy()) {
+        case EVERY_HALF_HOUR:
+            builder.withReconnectPolicy(ReconnectPolicy.Provided.EVERY_HALF_HOUR);
+            break;
+        case EVERY_NOTIFICATION:
+            builder.withReconnectPolicy(ReconnectPolicy.Provided.EVERY_NOTIFICATION);
+            break;
+        default:
+            builder.withReconnectPolicy(ReconnectPolicy.Provided.NEVER);
+            break;
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apns.model;
+
+public final class ApnsConstants {
+
+    public static final String HEADER_TOKENS = "CamelApnsTokens";
+    public static final String HEADER_MESSAGE_TYPE = "CamelApnsMessageType";
+
+    private ApnsConstants() {
+    }
+    
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,23 @@
+/**
+ * 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.camel.component.apns.model;
+
+public enum ConnectionStrategy {
+
+    SIMPLE, QUEUE, POOL, NON_BLOCKING;
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,53 @@
+/**
+ * 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.camel.component.apns.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class InactiveDevice implements Serializable {
+
+    private String deviceToken;
+    private Date date;
+
+    public InactiveDevice(String deviceToken, Date date) {
+        super();
+        this.deviceToken = deviceToken;
+        this.date = date;
+    }
+
+    public String getDeviceToken() {
+        return deviceToken;
+    }
+
+    public void setDeviceToken(String deviceToken) {
+        this.deviceToken = deviceToken;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    @Override
+    public String toString() {
+        return "InactiveDevice[" + deviceToken + ", " + date + "]";
+    }
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,23 @@
+/**
+ * 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.camel.component.apns.model;
+
+public enum MessageType {
+
+    STRING, PAYLOAD;
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java Mon Jun  6 18:30:33 2011
@@ -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.camel.component.apns.model;
+
+public enum ReconnectionPolicy {
+
+    /**
+     * Only reconnect if absolutely needed, e.g. when the connection is dropped.
+     * This is the recommended mode. Apple recommends using a persistent
+     * connection. This improves the latency of sending push notification
+     * messages. The down-side is that once the connection is closed
+     * ungracefully (e.g. because Apple server drops it), the library wouldn't
+     * detect such failure and not warn against the messages sent after the drop
+     * before the detection.
+     */
+    NEVER,
+
+    /**
+     * Makes a new connection if the current connection has lasted for more than
+     * half an hour. This is the sweat-spot in my experiments between dropped
+     * connections while minimizing latency.
+     */
+    EVERY_HALF_HOUR,
+
+    /**
+     * Makes a new connection for every message being sent. This option ensures
+     * that each message is actually delivered to Apple. If you send <strong>a
+     * lot</strong> of messages though, Apple may consider your requests to be a
+     * DoS attack.
+     */
+    EVERY_NOTIFICATION;
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,37 @@
+/**
+ * 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.camel.component.apns.util;
+
+public final class AssertUtils {
+
+    private AssertUtils() {
+        super();
+    }
+
+    public static void notNull(Object object, String message) {
+        if (object == null) {
+            throw new IllegalArgumentException("[Assert not null] " + message);
+        }
+    }
+
+    public static void isTrue(boolean booleanValue, String message) {
+        if (!booleanValue) {
+            throw new IllegalArgumentException("[Assert is true] " + message);
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,40 @@
+/**
+ * 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.camel.component.apns.util;
+
+public final class ParamUtils {
+
+    private ParamUtils() {
+        super();
+    }
+
+    public static void checkNotNull(Object param, String paramValue) {
+        AssertUtils.notNull(paramValue, param + " cannot be null");
+    }
+
+    public static void checkNotEmpty(String paramValue, String paramName) {
+        AssertUtils.notNull(paramValue, paramName + " cannot be null");
+        AssertUtils.isTrue(StringUtils.isNotEmpty(paramValue), paramName + " cannot be empty");
+    }
+
+    public static void checkDestination(String host, int port, String paramName) {
+        if ((StringUtils.isEmpty(host) && port != 0) || (StringUtils.isNotEmpty(host) && port == 0)) {
+            throw new IllegalArgumentException(paramName + "host and port parameters are not coherent: host=" + host + ", port=" + port);
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,74 @@
+/**
+ * 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.camel.component.apns.util;
+
+import java.io.BufferedInputStream;
+import java.io.Closeable;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.notnoop.exceptions.RuntimeIOException;
+
+public final class ResourceUtils {
+
+    private static final String CLASSPATH_PREFIX = "classpath:";
+
+    private ResourceUtils() {
+        super();
+    }
+
+    public static boolean isClasspathResource(String path) {
+        return path.startsWith(CLASSPATH_PREFIX);
+    }
+
+    public static String getClasspathResourcePath(String path) {
+        return path.substring(CLASSPATH_PREFIX.length());
+    }
+
+    public static InputStream getInputStream(String path) {
+
+        InputStream is = null;
+
+        if (isClasspathResource(path)) {
+            String classpathResourcePath = ResourceUtils.getClasspathResourcePath(path);
+            is = ResourceUtils.class.getResourceAsStream(classpathResourcePath);
+            if (is == null) {
+                throw new RuntimeIOException("Certificate stream is null: '" + classpathResourcePath + "'");
+            }
+        } else {
+            try {
+                is = new BufferedInputStream(new FileInputStream(path));
+            } catch (FileNotFoundException e) {
+                throw new RuntimeIOException(e);
+            }
+        }
+
+        return is;
+    }
+
+    public static void close(Closeable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (IOException e) { /* Nothing to do */
+            }
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java (added)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java Mon Jun  6 18:30:33 2011
@@ -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.camel.component.apns.util;
+
+public final class StringUtils {
+
+    private StringUtils() {
+        super();
+    }
+
+    public static boolean isNotEmpty(String stringValue) {
+        if (stringValue == null) {
+            return false;
+        }
+        return stringValue.length() > 0;
+    }
+
+    public static boolean isEmpty(String stringValue) {
+        return !isNotEmpty(stringValue);
+    }
+
+    public static String trim(String stringValue) {
+        if (stringValue == null) {
+            return stringValue;
+        }
+        return stringValue.trim();
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt (added)
+++ camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt Mon Jun  6 18:30:33 2011
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Propchange: camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/resources/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/apns
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/apns?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/apns (added)
+++ camel/trunk/components/camel-apns/src/main/resources/META-INF/services/org/apache/camel/component/apns Mon Jun  6 18:30:33 2011
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.helyx.camel.apns.ApnsComponent

Added: camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt (added)
+++ camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt Mon Jun  6 18:30:33 2011
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/main/resources/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java (added)
+++ camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,29 @@
+/**
+ * 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 com.notnoop.apns.internal;
+
+public final class ApnsFeedbackParsingUtilsAcessor {
+
+    private ApnsFeedbackParsingUtilsAcessor() {
+        super();
+    }
+    
+    public static byte[] pack(byte[]... args) {
+        return ApnsFeedbackParsingUtils.pack(args);
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java (added)
+++ camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,103 @@
+/**
+ * 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.camel.component.apns;
+
+import com.notnoop.apns.ApnsService;
+import com.notnoop.apns.utils.ApnsServerStub;
+import com.notnoop.apns.utils.FixedCertificates;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.apns.factory.ApnsServiceFactory;
+import org.apache.camel.component.apns.model.InactiveDevice;
+import org.apache.camel.component.apns.util.ApnsUtils;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Unit test that we can produce JMS message from files
+ */
+public class ApnsConsumerTest extends CamelTestSupport {
+
+    ApnsServerStub server;
+
+    public ApnsConsumerTest() {
+        super();
+    }
+
+    @Before
+    public void startup() throws InterruptedException {
+        server = ApnsServerStub.prepareAndStartServer(FixedCertificates.TEST_GATEWAY_PORT, FixedCertificates.TEST_FEEDBACK_PORT);
+    }
+
+    @After
+    public void stop() {
+        server.stop();
+    }
+
+    @Test(timeout = 5000)
+    public void testConsumer() throws Exception {
+
+        byte[] deviceTokenBytes = ApnsUtils.createRandomDeviceTokenBytes();
+        String deviceToken = ApnsUtils.encodeHexToken(deviceTokenBytes);
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().isInstanceOf(InactiveDevice.class);
+
+        byte[] feedBackBytes = ApnsUtils.generateFeedbackBytes(deviceTokenBytes);
+        server.toSend.write(feedBackBytes);
+
+        Thread.sleep(1000);
+
+        assertMockEndpointsSatisfied();
+
+        InactiveDevice inactiveDevice = (InactiveDevice)mock.getExchanges().get(0).getIn().getBody();
+        assertNotNull(inactiveDevice);
+        assertNotNull(inactiveDevice.getDate());
+        assertNotNull(inactiveDevice.getDeviceToken());
+        assertEquals(deviceToken, inactiveDevice.getDeviceToken());
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
+        ApnsService apnsService = apnsServiceFactory.getApnsService();
+
+        ApnsComponent apnsComponent = new ApnsComponent(apnsService);
+
+        camelContext.addComponent("apns", apnsComponent);
+
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("apns:consumer?initialDelay=500&delay=500&timeUnit=MILLISECONDS")
+                        .to("log:apns?showAll=true&multiline=true")
+                        .to("mock:result");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java?rev=1132722&view=auto
==============================================================================
--- camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java (added)
+++ camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java Mon Jun  6 18:30:33 2011
@@ -0,0 +1,91 @@
+/**
+ * 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.camel.component.apns;
+
+import com.notnoop.apns.APNS;
+import com.notnoop.apns.ApnsService;
+import com.notnoop.apns.EnhancedApnsNotification;
+import com.notnoop.apns.utils.ApnsServerStub;
+import com.notnoop.apns.utils.FixedCertificates;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.apns.factory.ApnsServiceFactory;
+import org.apache.camel.component.apns.model.ApnsConstants;
+import org.apache.camel.component.apns.util.ApnsUtils;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test that we can produce JMS message from files
+ */
+public class ApnsProducerTest extends CamelTestSupport {
+
+    private static final String FAKE_TOKEN = "19308314834701ACD8313AEBD92AEFDE192120371FE13982392831701318B943";
+
+    private ApnsServerStub server;
+
+    public ApnsProducerTest() {
+        super();
+    }
+
+    @Before
+    public void startup() {
+        server = ApnsServerStub.prepareAndStartServer(FixedCertificates.TEST_GATEWAY_PORT, FixedCertificates.TEST_FEEDBACK_PORT);
+    }
+
+    @After
+    public void stop() {
+        server.stop();
+    }
+
+    @Test(timeout = 3000)
+    public void testProducer() throws Exception {
+        String message = "Hello World";
+        String messagePayload = APNS.newPayload().alertBody(message).build();
+
+        EnhancedApnsNotification apnsNotification = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
+        server.stopAt(apnsNotification.length());
+
+        template.sendBody("direct:test", message);
+
+        server.messages.acquire();
+        assertArrayEquals(apnsNotification.marshall(), server.received.toByteArray());
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
+        ApnsService apnsService = apnsServiceFactory.getApnsService();
+
+        ApnsComponent apnsComponent = new ApnsComponent(apnsService);
+        camelContext.addComponent("apns", apnsComponent);
+
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:test").setHeader(ApnsConstants.HEADER_TOKENS, constant(FAKE_TOKEN)).to("apns:notify");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date