Repository: camel Updated Branches: refs/heads/master 3d14a21d9 -> 56945ab9b
Fix for CAMEL-7510 Expose the component options for Camel Quartz Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/329a40c0 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/329a40c0 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/329a40c0 Branch: refs/heads/master Commit: 329a40c00efdb2eea8c002974083e51ae1ec3d5b Parents: f44ff09 Author: Kevin Earls <ke...@kevinearls.com> Authored: Wed Aug 6 10:19:11 2014 +0200 Committer: Kevin Earls <ke...@kevinearls.com> Committed: Wed Aug 6 10:19:11 2014 +0200 ---------------------------------------------------------------------- .../camel/component/quartz/QuartzComponent.java | 6 ++- .../camel/component/quartz/QuartzEndpoint.java | 6 +++ ...ponentConfigurationAndDocumentationTest.java | 57 ++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/329a40c0/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java index a0eb2b3..b3002f6 100644 --- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java +++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java @@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.camel.CamelContext; import org.apache.camel.StartupListener; import org.apache.camel.impl.DefaultComponent; +import org.apache.camel.impl.UriEndpointComponent; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.IOHelper; import org.apache.camel.util.IntrospectionSupport; @@ -54,7 +55,7 @@ import org.slf4j.LoggerFactory; * * @version */ -public class QuartzComponent extends DefaultComponent implements StartupListener { +public class QuartzComponent extends UriEndpointComponent implements StartupListener { private static final Logger LOG = LoggerFactory.getLogger(QuartzComponent.class); private Scheduler scheduler; private final List<JobToAdd> jobsToAdd = new ArrayList<JobToAdd>(); @@ -84,10 +85,11 @@ public class QuartzComponent extends DefaultComponent implements StartupListener } public QuartzComponent() { + super(QuartzEndpoint.class); } public QuartzComponent(final CamelContext context) { - super(context); + super(context, QuartzEndpoint.class); } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/329a40c0/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java index e7fd032..eda07b0 100644 --- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java +++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java @@ -26,6 +26,8 @@ import org.apache.camel.ShutdownableService; 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.apache.camel.support.ServiceSupport; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.ServiceHelper; @@ -42,6 +44,7 @@ import org.slf4j.LoggerFactory; * * @version */ +@UriEndpoint(scheme = "quartz", consumerClass = QuartzConsumer.class) public class QuartzEndpoint extends DefaultEndpoint implements ShutdownableService { private static final Logger LOG = LoggerFactory.getLogger(QuartzEndpoint.class); @@ -49,8 +52,11 @@ public class QuartzEndpoint extends DefaultEndpoint implements ShutdownableServi private Trigger trigger; private JobDetail jobDetail = new JobDetail(); private volatile boolean started; + @UriParam private volatile boolean stateful; + @UriParam private boolean deleteJob = true; + @UriParam private boolean pauseJob; public QuartzEndpoint(final String endpointUri, final QuartzComponent component) { http://git-wip-us.apache.org/repos/asf/camel/blob/329a40c0/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzComponentConfigurationAndDocumentationTest.java b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzComponentConfigurationAndDocumentationTest.java new file mode 100644 index 0000000..98e38e6 --- /dev/null +++ b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzComponentConfigurationAndDocumentationTest.java @@ -0,0 +1,57 @@ +/** + * 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.quartz; + +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 QuartzComponentConfigurationAndDocumentationTest extends CamelTestSupport { + + @Override + public boolean isUseRouteBuilder() { + return false; + } + + @Test + public void testComponentConfiguration() throws Exception { + QuartzComponent comp = context.getComponent("quartz", QuartzComponent.class); + EndpointConfiguration conf = comp.createConfiguration("quartz://myGroup/myName?trigger.repeatCount=3" + + "&stateful=true&deleteJob=false"); + + assertEquals("true", conf.getParameter("stateful")); + assertEquals("false", conf.getParameter("deleteJob")); + + ComponentConfiguration compConf = comp.createComponentConfiguration(); + String json = compConf.createParameterJsonSchema(); + assertNotNull(json); + + assertTrue(json.contains("\"stateful\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"deleteJob\": { \"type\": \"boolean\" }")); + } + + @Test + public void testComponentDocumentation() throws Exception { + CamelContext context = new DefaultCamelContext(); + String html = context.getComponentDocumentation("quartz"); + assertNotNull("Should have found some auto-generated HTML if on Java 7", html); + } + +}