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 2013/08/15 14:17:57 UTC

[1/2] git commit: CAMEL-6622: Added missing configuration for mgfAlgorithm

Updated Branches:
  refs/heads/master 903327e8f -> fb43d6843


CAMEL-6622: Added missing configuration for mgfAlgorithm


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

Branch: refs/heads/master
Commit: beb75cc73f662b80dcfa8edb84f4f6014f16dd0c
Parents: 903327e
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 15 13:31:34 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 15 13:31:34 2013 +0200

----------------------------------------------------------------------
 .../model/dataformat/XMLSecurityDataFormat.java | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/beb75cc7/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
index 005971e..f7a7071 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
@@ -57,7 +57,9 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
     private String keyPassword;
     @XmlAttribute
     private String digestAlgorithm;
-    
+    @XmlAttribute
+    private String mgfAlgorithm;
+
     @XmlTransient
     private KeyStoreParameters keyOrTrustStoreParameters;
     
@@ -268,6 +270,9 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
         if (digestAlgorithm != null) {
             setProperty(dataFormat, "digestAlgorithm", this.getDigestAlgorithm());
         }
+        if (mgfAlgorithm != null) {
+            setProperty(dataFormat, "mgfAlgorithm", this.getMgfAlgorithm());
+        }
     }
 
     public String getXmlCipherAlgorithm() {
@@ -337,7 +342,11 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
     public String getKeyPassword() {
         return this.keyPassword;
     }
-    
+
+    public void setKeyPassword(String keyPassword) {
+        this.keyPassword = keyPassword;
+    }
+
     public String getDigestAlgorithm() {
         return digestAlgorithm;
     }
@@ -346,8 +355,12 @@ public class XMLSecurityDataFormat extends DataFormatDefinition implements Names
         this.digestAlgorithm = digestAlgorithm;
     }
 
-    public void setKeyPassword(String keyPassword) {
-        this.keyPassword = keyPassword;
+    public String getMgfAlgorithm() {
+        return mgfAlgorithm;
+    }
+
+    public void setMgfAlgorithm(String mgfAlgorithm) {
+        this.mgfAlgorithm = mgfAlgorithm;
     }
 
     @Override


[2/2] git commit: CAMEL-6631: Introduce ScheduledPollConsumerScheduler SPI to plugin different schedulers for poll consumer components such as file/ftp etc.

Posted by da...@apache.org.
CAMEL-6631: Introduce ScheduledPollConsumerScheduler SPI to plugin different schedulers for poll consumer components such as file/ftp etc.


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

Branch: refs/heads/master
Commit: fb43d684334943beaf136a1f03b6998426027927
Parents: beb75cc
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 15 14:17:34 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 15 14:17:34 2013 +0200

----------------------------------------------------------------------
 camel-core/pom.xml                              |   1 +
 .../camel/impl/ScheduledPollEndpoint.java       |  12 +-
 .../QuartzScheduledPollConsumerScheduler.java   |  10 +-
 .../SpringScheduledPollConsumerScheduler.java   | 142 +++++++++++++++++++
 .../FileConsumerSpringSchedulerTest.java        |  49 +++++++
 .../FileConsumerSpringSchedulerTest.xml         |  36 +++++
 6 files changed, 239 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/camel-core/pom.xml
----------------------------------------------------------------------
diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index 612ae8e..42109b9 100755
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -88,6 +88,7 @@
     </camel.osgi.export.service>
     <camel.osgi.dynamic>
         org.apache.camel.spring.util;${camel.osgi.import.strict.version},
+        org.apache.camel.spring.pollingconsumer;${camel.osgi.import.strict.version},
         org.apache.camel.processor.interceptor.jpa;${camel.osgi.import.strict.version},
         org.apache.camel.pollconsumer.quartz2;${camel.osgi.import.strict.version},
         net.sf.saxon

http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
index 191f9d1..9deb698 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
@@ -31,6 +31,7 @@ import org.apache.camel.util.IntrospectionSupport;
  */
 public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
 
+    private static final String SPRING_SCHEDULER = "org.apache.camel.spring.pollingconsumer.SpringScheduledPollConsumerScheduler";
     private static final String QUARTZ_2_SCHEDULER = "org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerScheduler";
 
     protected ScheduledPollEndpoint(String endpointUri, Component component) {
@@ -119,8 +120,15 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
                 consumerProperties.put("scheduledExecutorService", scheduledExecutorService);
             }
             if (scheduler != null) {
-                // special for scheduler if its "quartz2"
-                if ("quartz2".equals(scheduler)) {
+                // special for scheduler if its "spring"
+                if ("spring".equals(scheduler)) {
+                    try {
+                        Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(SPRING_SCHEDULER);
+                        scheduler = getCamelContext().getInjector().newInstance(clazz);
+                    } catch (ClassNotFoundException e) {
+                        throw new IllegalArgumentException("Cannot load " + SPRING_SCHEDULER + " from classpath. Make sure camel-spring.jar is on the classpath.", e);
+                    }
+                } else if ("quartz2".equals(scheduler)) {
                     try {
                         Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(QUARTZ_2_SCHEDULER);
                         scheduler = getCamelContext().getInjector().newInstance(clazz);

http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java b/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
index 27e9a1e..14787a8 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
@@ -26,12 +26,9 @@ import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.ObjectHelper;
 import org.quartz.CronScheduleBuilder;
 import org.quartz.CronTrigger;
-import org.quartz.Job;
 import org.quartz.JobBuilder;
 import org.quartz.JobDataMap;
 import org.quartz.JobDetail;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import org.quartz.TriggerBuilder;
@@ -42,7 +39,7 @@ import org.slf4j.LoggerFactory;
  * A quartz based {@link ScheduledPollConsumerScheduler} which uses a {@link CronTrigger} to define when the
  * poll should be triggered.
  */
-public class QuartzScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler, Job {
+public class QuartzScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler {
 
     private static final Logger LOG = LoggerFactory.getLogger(QuartzScheduledPollConsumerScheduler.class);
     private Scheduler quartzScheduler;
@@ -143,11 +140,6 @@ public class QuartzScheduledPollConsumerScheduler extends ServiceSupport impleme
     }
 
     @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        runnable.run();
-    }
-
-    @Override
     protected void doStart() throws Exception {
         ObjectHelper.notEmpty(cron, "cron", this);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
new file mode 100644
index 0000000..50aa3be
--- /dev/null
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
@@ -0,0 +1,142 @@
+/**
+ * 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.spring.pollingconsumer;
+
+import java.util.TimeZone;
+import java.util.concurrent.ScheduledFuture;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.spi.ScheduledPollConsumerScheduler;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.concurrent.CamelThreadFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import org.springframework.scheduling.support.CronTrigger;
+
+/**
+ * A Spring based {@link ScheduledPollConsumerScheduler} which uses a {@link CronTrigger} to define when the
+ * poll should be triggered.
+ */
+public class SpringScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SpringScheduledPollConsumerScheduler.class);
+    private CamelContext camelContext;
+    private Consumer consumer;
+    private Runnable runnable;
+    private String cron;
+    private TimeZone timeZone = TimeZone.getDefault();
+    private volatile CronTrigger trigger;
+    private volatile ThreadPoolTaskScheduler taskScheduler;
+    private boolean destroyTaskScheduler;
+    private volatile ScheduledFuture future;
+
+    @Override
+    public void onInit(Consumer consumer) {
+        this.consumer = consumer;
+    }
+
+    @Override
+    public void scheduleTask(Runnable runnable) {
+        this.runnable = runnable;
+    }
+
+    @Override
+    public void unscheduleTask() {
+        if (future != null) {
+            future.cancel(false);
+            future = null;
+        }
+    }
+
+    @Override
+    public void startScheduler() {
+        // we start the scheduler in doStart
+    }
+
+    @Override
+    public boolean isSchedulerStarted() {
+        return taskScheduler != null && !taskScheduler.getScheduledExecutor().isShutdown();
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public String getCron() {
+        return cron;
+    }
+
+    public void setCron(String cron) {
+        this.cron = cron;
+    }
+
+    public TimeZone getTimeZone() {
+        return timeZone;
+    }
+
+    public void setTimeZone(TimeZone timeZone) {
+        this.timeZone = timeZone;
+    }
+
+    public ThreadPoolTaskScheduler getTaskScheduler() {
+        return taskScheduler;
+    }
+
+    public void setTaskScheduler(ThreadPoolTaskScheduler taskScheduler) {
+        this.taskScheduler = taskScheduler;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        ObjectHelper.notEmpty(cron, "cron", this);
+
+        trigger = new CronTrigger(getCron(), getTimeZone());
+
+        if (taskScheduler == null) {
+            taskScheduler = new ThreadPoolTaskScheduler();
+            CamelThreadFactory tf = new CamelThreadFactory(getCamelContext().getExecutorServiceManager().getThreadNamePattern(), "SpringScheduledPollConsumerSchedulerTask", true);
+            taskScheduler.setThreadFactory(tf);
+            taskScheduler.afterPropertiesSet();
+            destroyTaskScheduler = true;
+        }
+
+        LOG.debug("Scheduling cron trigger {}", getCron());
+        future = taskScheduler.schedule(runnable, trigger);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (future != null) {
+            future.cancel(false);
+            future = null;
+        }
+
+        if (destroyTaskScheduler) {
+            taskScheduler.destroy();
+            taskScheduler = null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/components/camel-spring/src/test/java/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.java
new file mode 100644
index 0000000..3314062
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring.pollingconsumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spring.SpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class FileConsumerSpringSchedulerTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml");
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("target/file/spring");
+        super.setUp();
+    }
+
+    @Test
+    public void testSpringScheduler() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBodyAndHeader("file:target/file/spring", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        context.startRoute("foo");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fb43d684/components/camel-spring/src/test/resources/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml
new file mode 100644
index 0000000..6318702
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- START SNIPPET: example -->
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route id="foo" autoStartup="false">
+      <from uri="file:target/file/spring?scheduler=spring&amp;scheduler.cron=0/2+*+*+*+*+?"/>
+      <to uri="log:result"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+  <!-- END SNIPPET: example -->
+
+</beans>