camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] git commit: Fix for CAMEL-7511 Expose the component options for Camel Quartz2
Date Mon, 16 Jun 2014 18:42:17 GMT
Repository: camel
Updated Branches:
  refs/heads/master 85ced0668 -> 675bd5304


Fix for CAMEL-7511 Expose the component options for Camel Quartz2


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

Branch: refs/heads/master
Commit: 3956583c7aec40f89b75cf77f4ed5c20085c3ee2
Parents: bd4f8d1
Author: Kevin Earls <kevin@kevinearls.com>
Authored: Mon Jun 16 15:44:31 2014 +0200
Committer: Kevin Earls <kevin@kevinearls.com>
Committed: Mon Jun 16 15:45:08 2014 +0200

----------------------------------------------------------------------
 .../component/quartz2/QuartzComponent.java      |  7 +--
 .../camel/component/quartz2/QuartzEndpoint.java | 11 ++++
 ...ponentConfigurationAndDocumentationTest.java | 55 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3956583c/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
index f24046d..a6cab8f 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.StartupListener;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
  * of the code, but mostly has been re-written in attempt to be more easier to maintain,
and use Quartz more
  * fully.</p>
  */
-public class QuartzComponent extends DefaultComponent implements StartupListener {
+public class QuartzComponent extends UriEndpointComponent implements StartupListener {
     private static final Logger LOG = LoggerFactory.getLogger(QuartzComponent.class);
     private SchedulerFactory schedulerFactory;
     private Scheduler scheduler;
@@ -60,10 +60,11 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
     private boolean enableJmx = true;
 
     public QuartzComponent() {
+        super(QuartzEndpoint.class);
     }
 
     public QuartzComponent(CamelContext camelContext) {
-        super(camelContext);
+        super(camelContext, QuartzEndpoint.class);
     }
 
     public int getStartDelayedSeconds() {

http://git-wip-us.apache.org/repos/asf/camel/blob/3956583c/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
index 1aeb9d0..5f42839 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
@@ -28,6 +28,8 @@ import org.apache.camel.Route;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.processor.loadbalancer.LoadBalancer;
 import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.quartz.Job;
 import org.quartz.JobBuilder;
 import org.quartz.JobDataMap;
@@ -48,21 +50,30 @@ import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
  * call back into {@link #onConsumerStart(QuartzConsumer)} to add/resume or {@link #onConsumerStop(QuartzConsumer)}
  * to pause the scheduler trigger.
  */
+@UriEndpoint(scheme = "quartz2", consumerClass = QuartzComponent.class)
 public class QuartzEndpoint extends DefaultEndpoint {
     private static final Logger LOG = LoggerFactory.getLogger(QuartzEndpoint.class);
     private TriggerKey triggerKey;
+    @UriParam
     private String cron;
     private LoadBalancer consumerLoadBalancer;
     private Map<String, Object> triggerParameters;
     private Map<String, Object> jobParameters;
+    @UriParam
     private boolean stateful;
+    @UriParam
     private boolean fireNow;
+    @UriParam
     private boolean deleteJob = true;
+    @UriParam
     private boolean pauseJob;
+    @UriParam
     private boolean durableJob;
+    @UriParam
     private boolean recoverableJob;
     /** In case of scheduler has already started, we want the trigger start slightly after
current time to
      * ensure endpoint is fully started before the job kicks in. */
+    @UriParam
     private long triggerStartDelay = 500; // in millis second
 
     // An internal variables to track whether a job has been in scheduler or not, and has
it paused or not.

http://git-wip-us.apache.org/repos/asf/camel/blob/3956583c/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/Quartz2ComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/Quartz2ComponentConfigurationAndDocumentationTest.java
b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/Quartz2ComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..93e99af
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/Quartz2ComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.quartz2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class Quartz2ComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        QuartzComponent comp = context.getComponent("quartz2", QuartzComponent.class);
+        EndpointConfiguration conf = comp.createConfiguration("quartz2://myGroup/myTimerName?durableJob=true&recoverableJob=true&cron=0/2+*+*+*+*+?");
+
+        assertEquals("true", conf.getParameter("durableJob"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"cron\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"fireNow\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("quartz2");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}


Mime
View raw message