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 2014/11/11 15:49:06 UTC
[3/3] camel git commit: First crack at todos in CAMEL-7997
First crack at todos in CAMEL-7997
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a344ba76
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a344ba76
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a344ba76
Branch: refs/heads/master
Commit: a344ba760aa6eac7030e654cd9ec48ebc1366d8b
Parents: 12f85a7
Author: Jyrki Ruuskanen <yu...@kotikone.fi>
Authored: Mon Nov 10 20:52:06 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Nov 11 15:48:51 2014 +0100
----------------------------------------------------------------------
.../apache/camel/scr/AbstractCamelRunner.java | 16 ++-
.../java/org/apache/camel/scr/ScrHelper.java | 108 -------------------
.../apache/camel/scr/internal/ScrHelper.java | 108 +++++++++++++++++++
.../camel/scr/AbstractCamelRunnerTest.java | 8 ++
tooling/archetypes/camel-archetype-scr/pom.xml | 5 +-
.../META-INF/maven/archetype-metadata.xml | 3 -
.../main/resources/archetype-resources/pom.xml | 60 +++--------
.../src/main/java/__className__.java | 38 +++----
.../main/java/internal/__className__Route.java | 20 ----
.../src/test/java/__className__Test.java | 25 +----
.../camel-scr-example/archetype.properties | 1 -
11 files changed, 168 insertions(+), 224 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
index e4d6e93..9d583e1 100644
--- a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
+++ b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
@@ -54,9 +54,8 @@ public abstract class AbstractCamelRunner implements Runnable {
public static final String PROPERTY_PREFIX = "camel.scr.properties.prefix";
// Configured fields
- // TODO: can we make these private and have getter/setter
- public String camelContextId = "camel-runner-default";
- public volatile boolean active;
+ private String camelContextId = "camel-runner-default";
+ private boolean active = false;
protected Logger log = LoggerFactory.getLogger(getClass());
protected ModelCamelContext context;
@@ -85,7 +84,7 @@ public abstract class AbstractCamelRunner implements Runnable {
createCamelContext(bundleContext, props);
// Configure fields from properties
- configure(context, this, log);
+ configure(context, this, log, true);
setupCamelContext(bundleContext, camelContextId);
}
@@ -236,11 +235,18 @@ public abstract class AbstractCamelRunner implements Runnable {
}
public static <T> T configure(final CamelContext context, final T target, final Logger log) {
+ return configure(context, target, log, false);
+ }
+
+ public static <T> T configure(final CamelContext context, final T target, final Logger log, final boolean deep) {
Class clazz = target.getClass();
log.debug("Configuring {}", clazz.getName());
Collection<Field> fields = new ArrayList<Field>();
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
- fields.addAll(Arrays.asList(clazz.getFields()));
+ if (deep) {
+ fields.addAll(Arrays.asList(clazz.getFields()));
+ fields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
+ }
for (Field field : fields) {
try {
String propertyValue = context.resolvePropertyPlaceholders("{{" + field.getName() + "}}");
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/components/camel-scr/src/main/java/org/apache/camel/scr/ScrHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/main/java/org/apache/camel/scr/ScrHelper.java b/components/camel-scr/src/main/java/org/apache/camel/scr/ScrHelper.java
deleted file mode 100644
index d01d460..0000000
--- a/components/camel-scr/src/main/java/org/apache/camel/scr/ScrHelper.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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.scr;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Helper class.
- */
-public final class ScrHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(ScrHelper.class);
-
- private ScrHelper() {
- }
-
- public static Map<String, String> getScrProperties(String componentName) throws Exception {
- return getScrProperties(String.format("target/classes/OSGI-INF/%s.xml", componentName), componentName);
- }
-
- public static Map<String, String> getScrProperties(String xmlLocation, String componentName) throws Exception {
- Map<String, String> result = new HashMap<String, String>();
- final Document dom = readXML(new File(xmlLocation));
- final XPath xPath = XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", null).newXPath();
- xPath.setNamespaceContext(new NamespaceContext() {
- @Override
- public String getNamespaceURI(String prefix) {
- switch (prefix) {
- case "scr":
- try {
- XPathExpression scrNamespace = xPath.compile("/*/namespace::*[name()='scr']");
- Node node = (Node) scrNamespace.evaluate(dom, XPathConstants.NODE);
- return node.getNodeValue();
- } catch (XPathExpressionException e) {
- // ignore
- LOG.debug("Error evaluating xpath to obtain namespace prefix. This exception is ignored and using namespace: http://www.osgi.org/xmlns/scr/v1.1.0", e);
-
- }
- return "http://www.osgi.org/xmlns/scr/v1.1.0";
- default:
- // noop
- }
- return XMLConstants.NULL_NS_URI;
- }
-
- @Override
- public String getPrefix(String namespaceURI) {
- return null;
- }
-
- @Override
- public Iterator getPrefixes(String namespaceURI) {
- return null;
- }
- });
-
- String propertyListExpression = String.format("/components/scr:component[@name='%s']/property", componentName);
- XPathExpression propertyList = xPath.compile(propertyListExpression);
- XPathExpression propertyName = xPath.compile("@name");
- XPathExpression propertyValue = xPath.compile("@value");
- NodeList nodes = (NodeList) propertyList.evaluate(dom, XPathConstants.NODESET);
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- result.put((String) propertyName.evaluate(node, XPathConstants.STRING), (String) propertyValue.evaluate(node, XPathConstants.STRING));
- }
- return result;
- }
-
- private static Document readXML(File xml) throws Exception {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- builderFactory.setNamespaceAware(true);
- DocumentBuilder builder = builderFactory.newDocumentBuilder();
- return builder.parse(xml);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/components/camel-scr/src/main/java/org/apache/camel/scr/internal/ScrHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/main/java/org/apache/camel/scr/internal/ScrHelper.java b/components/camel-scr/src/main/java/org/apache/camel/scr/internal/ScrHelper.java
new file mode 100644
index 0000000..40a4770
--- /dev/null
+++ b/components/camel-scr/src/main/java/org/apache/camel/scr/internal/ScrHelper.java
@@ -0,0 +1,108 @@
+/**
+ * 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.scr.internal;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Helper class.
+ */
+public final class ScrHelper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ScrHelper.class);
+
+ private ScrHelper() {
+ }
+
+ public static Map<String, String> getScrProperties(String componentName) throws Exception {
+ return getScrProperties(String.format("target/classes/OSGI-INF/%s.xml", componentName), componentName);
+ }
+
+ public static Map<String, String> getScrProperties(String xmlLocation, String componentName) throws Exception {
+ Map<String, String> result = new HashMap<String, String>();
+ final Document dom = readXML(new File(xmlLocation));
+ final XPath xPath = XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", null).newXPath();
+ xPath.setNamespaceContext(new NamespaceContext() {
+ @Override
+ public String getNamespaceURI(String prefix) {
+ switch (prefix) {
+ case "scr":
+ try {
+ XPathExpression scrNamespace = xPath.compile("/*/namespace::*[name()='scr']");
+ Node node = (Node) scrNamespace.evaluate(dom, XPathConstants.NODE);
+ return node.getNodeValue();
+ } catch (XPathExpressionException e) {
+ // ignore
+ LOG.debug("Error evaluating xpath to obtain namespace prefix. This exception is ignored and using namespace: http://www.osgi.org/xmlns/scr/v1.1.0", e);
+
+ }
+ return "http://www.osgi.org/xmlns/scr/v1.1.0";
+ default:
+ // noop
+ }
+ return XMLConstants.NULL_NS_URI;
+ }
+
+ @Override
+ public String getPrefix(String namespaceURI) {
+ return null;
+ }
+
+ @Override
+ public Iterator getPrefixes(String namespaceURI) {
+ return null;
+ }
+ });
+
+ String propertyListExpression = String.format("/components/scr:component[@name='%s']/property", componentName);
+ XPathExpression propertyList = xPath.compile(propertyListExpression);
+ XPathExpression propertyName = xPath.compile("@name");
+ XPathExpression propertyValue = xPath.compile("@value");
+ NodeList nodes = (NodeList) propertyList.evaluate(dom, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ result.put((String) propertyName.evaluate(node, XPathConstants.STRING), (String) propertyValue.evaluate(node, XPathConstants.STRING));
+ }
+ return result;
+ }
+
+ private static Document readXML(File xml) throws Exception {
+ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+ builderFactory.setNamespaceAware(true);
+ DocumentBuilder builder = builderFactory.newDocumentBuilder();
+ return builder.parse(xml);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java b/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
index b6d9cbd..7d61846 100644
--- a/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
+++ b/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
@@ -27,6 +27,7 @@ import org.junit.runners.JUnit4;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -46,6 +47,13 @@ public class AbstractCamelRunnerTest {
}
@Test
+ public void testDeepConfigure() throws Exception {
+ ConcreteCamelRunner integration = new ConcreteCamelRunner();
+ integration.activate(null, integration.getDefaultProperties());
+ assertEquals("Overriding camelContextId failed (deep configure)", integration.getDefaultProperties().get("camelContextId"), integration.getContext().getName());
+ }
+
+ @Test
public void testActivateDeactivate() {
ConcreteCamelRunner integration = new ConcreteCamelRunner();
try {
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/pom.xml b/tooling/archetypes/camel-archetype-scr/pom.xml
index d362b2e..164fccd 100644
--- a/tooling/archetypes/camel-archetype-scr/pom.xml
+++ b/tooling/archetypes/camel-archetype-scr/pom.xml
@@ -29,12 +29,11 @@
<groupId>org.apache.camel.archetypes</groupId>
<artifactId>camel-archetype-scr</artifactId>
<name>Camel :: Archetypes :: OSGi Service Component Runtime bundle</name>
- <description>Creates a new Camel SCR bundle project for Red Hat JBoss Fuse 6.1.</description>
+ <description>Creates a new Camel SCR bundle project for Karaf</description>
<packaging>maven-archetype</packaging>
<properties>
- <jboss-fuse-version>6.1.0.redhat-379</jboss-fuse-version>
- <target-camel-version>2.12.0.redhat-610379</target-camel-version>
+ <target-camel-version>${project.version}</target-camel-version>
</properties>
<build>
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-scr/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index c8e6ae3..20b2b96 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -32,9 +32,6 @@
</requiredProperty>
<requiredProperty key="groupId"/>
<requiredProperty key="className"/>
- <requiredProperty key="jboss-fuse-version">
- <defaultValue>${jboss-fuse-version}</defaultValue>
- </requiredProperty>
<requiredProperty key="target-camel-version">
<defaultValue>${target-camel-version}</defaultValue>
</requiredProperty>
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/pom.xml
index e380f46..abc6b21 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/pom.xml
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/pom.xml
@@ -44,6 +44,7 @@ This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archet
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <camel-version>${target-camel-version}</camel-version>
</properties>
<distributionManagement>
@@ -59,47 +60,27 @@ This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archet
</snapshotRepository>
</distributionManagement>
- <repositories>
- <repository>
- <id>fusesource.m2</id>
- <name>JBoss FS Public Repository Group</name>
- <url>https://repo.fusesource.com/nexus/content/groups/public</url>
- <layout>default</layout>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
<dependencyManagement>
<dependencies>
<dependency>
- <!-- This gives us the versions of Fuse components -->
- <groupId>org.jboss.fuse.bom</groupId>
- <artifactId>jboss-fuse-parent</artifactId>
- <version>${jboss-fuse-version}</version>
- <type>pom</type>
- <scope>import</scope>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.6</version>
</dependency>
<dependency>
- <!-- camel-core-osgi doesn't seem to be included in the above bill of materials -->
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core-osgi</artifactId>
- <version>${target-camel-version}</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.7</version>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
</dependency>
<dependency>
- <groupId>com.jayway.restassured</groupId>
- <artifactId>rest-assured</artifactId>
- <version>2.3.0</version>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -108,6 +89,7 @@ This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archet
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
+ <version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
@@ -137,16 +119,7 @@ This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archet
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.jayway.restassured</groupId>
- <artifactId>rest-assured</artifactId>
+ <version>${camel-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -222,8 +195,7 @@ This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archet
<Export-Package/>
<Private-Package>
${groupId},
- ${groupId}.*,
- org.apache.camel.scr
+ ${groupId}.*
</Private-Package>
</instructions>
</configuration>
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/__className__.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/__className__.java b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/__className__.java
index d3c76da..8af72d0 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/__className__.java
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/__className__.java
@@ -20,39 +20,39 @@
// This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archetypeVersion}
package ${groupId};
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.camel.scr.AbstractCamelRunner;
import ${groupId}.internal.${className}Route;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.spi.ComponentResolver;
import org.apache.felix.scr.annotations.*;
-import java.util.ArrayList;
-import java.util.List;
-
@Component(label = ${className}.COMPONENT_LABEL, description = ${className}.COMPONENT_DESCRIPTION, immediate = true, metatype = true)
@Properties({
- @Property(name = "camelContextId", value = "${artifactId}"),
- @Property(name = "camelRouteId", value = "foo/timer-log"),
- @Property(name = "active", value = "true"),
- @Property(name = "from", value = "timer:foo?period=5000"),
- @Property(name = "to", value = "log:foo?showHeaders=true"),
- @Property(name = "summaryLogging", value = "false"),
- @Property(name = "messageOk", value = "Success: {{from}} -> {{to}}"),
- @Property(name = "messageError", value = "Failure: {{from}} -> {{to}}"),
- @Property(name = "maximumRedeliveries", value = "0"),
- @Property(name = "redeliveryDelay", value = "5000"),
- @Property(name = "backOffMultiplier", value = "2"),
- @Property(name = "maximumRedeliveryDelay", value = "60000")
+ @Property(name = "camelContextId", value = "${artifactId}"),
+ @Property(name = "camelRouteId", value = "foo/timer-log"),
+ @Property(name = "active", value = "true"),
+ @Property(name = "from", value = "timer:foo?period=5000"),
+ @Property(name = "to", value = "log:foo?showHeaders=true"),
+ @Property(name = "summaryLogging", value = "false"),
+ @Property(name = "messageOk", value = "Success: {{from}} -> {{to}}"),
+ @Property(name = "messageError", value = "Failure: {{from}} -> {{to}}"),
+ @Property(name = "maximumRedeliveries", value = "0"),
+ @Property(name = "redeliveryDelay", value = "5000"),
+ @Property(name = "backOffMultiplier", value = "2"),
+ @Property(name = "maximumRedeliveryDelay", value = "60000")
})
@References({
- @Reference(name = "camelComponent",referenceInterface = ComponentResolver.class,
- cardinality = ReferenceCardinality.MANDATORY_MULTIPLE, policy = ReferencePolicy.DYNAMIC,
- policyOption = ReferencePolicyOption.GREEDY, bind = "gotCamelComponent", unbind = "lostCamelComponent")
+ @Reference(name = "camelComponent",referenceInterface = ComponentResolver.class,
+ cardinality = ReferenceCardinality.MANDATORY_MULTIPLE, policy = ReferencePolicy.DYNAMIC,
+ policyOption = ReferencePolicyOption.GREEDY, bind = "gotCamelComponent", unbind = "lostCamelComponent")
})
public class ${className} extends AbstractCamelRunner {
public static final String COMPONENT_LABEL = "${groupId}.${className}";
- public static final String COMPONENT_DESCRIPTION = "This is the current configuration for ${artifactId}.";
+ public static final String COMPONENT_DESCRIPTION = "This is the description for ${artifactId}.";
@Override
protected List<RoutesBuilder>getRouteBuilders() {
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/internal/__className__Route.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/internal/__className__Route.java b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/internal/__className__Route.java
index 10e50df..a44921d 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/internal/__className__Route.java
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/main/java/internal/__className__Route.java
@@ -21,7 +21,6 @@
package ${groupId}.internal;
import org.apache.camel.LoggingLevel;
-import org.apache.camel.builder.PredicateBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.commons.lang.Validate;
@@ -62,27 +61,8 @@ public class ${className}Route extends RouteBuilder {
.maximumRedeliveryDelay(maximumRedeliveryDelay));
from("{{from}}")
- .startupOrder(2)
.routeId(camelRouteId)
- .onCompletion()
- .to("direct:processCompletion")
- .end()
- .removeHeaders("*", "breadcrumbId")
.to("{{to}}");
-
- from("direct:processCompletion")
- .startupOrder(1)
- .routeId(camelRouteId + ".completion")
- .choice()
- .when(PredicateBuilder.and(simple("${exception} == null"), PredicateBuilder.constant(summaryLogging)))
- .to("log:" + camelRouteId +".success?groupInterval=60000")
- .when(PredicateBuilder.and(simple("${exception} == null"), PredicateBuilder.constant(!summaryLogging)))
- .log("{{messageOk}}")
- .when(PredicateBuilder.constant(summaryLogging))
- .to("log:" + camelRouteId +".failure?groupInterval=60000")
- .otherwise()
- .log(LoggingLevel.ERROR, "{{messageError}}")
- .endChoice();
}
public void checkProperties() {
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/java/__className__Test.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/java/__className__Test.java b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/java/__className__Test.java
index 26b82cc..505e20f 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/java/__className__Test.java
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/java/__className__Test.java
@@ -20,13 +20,14 @@
// This file was generated from ${archetypeGroupId}/${archetypeArtifactId}/${archetypeVersion}
package ${groupId};
-import org.apache.camel.scr.ScrHelper;
+import java.util.List;
+
+import org.apache.camel.scr.internal.ScrHelper;
import org.apache.camel.builder.AdviceWithRouteBuilder;
import org.apache.camel.component.mock.MockComponent;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.model.RouteDefinition;
-import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -37,12 +38,6 @@ import org.slf4j.LoggerFactory;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.util.List;
-
-import static com.jayway.restassured.RestAssured.*;
-import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
-import static org.hamcrest.Matchers.*;
-
@RunWith(JUnit4.class)
public class ${className}Test {
@@ -88,7 +83,7 @@ public class ${className}Test {
// Replace "from" endpoint with direct:start
replaceFromWith("direct:start");
// Mock and skip result endpoint
- mockEndpointsAndSkip("log:*");
+ mockEndpoints("log:*");
}
});
@@ -96,24 +91,12 @@ public class ${className}Test {
// resultEndpoint.expectedMessageCount(1); // If you want to just check the number of messages
resultEndpoint.expectedBodiesReceived("hello"); // If you want to check the contents
- // You can also take the expected result from an external file
- // String result = IOUtils.toString(context.getClassResolver().loadResourceAsStream("testdata/out/result.txt"));
- // resultEndpoint.expectedBodiesReceived(result.replaceAll("\r?\n", "\n"));
-
// Start the integration
integration.run();
// Send the test message
context.createProducerTemplate().sendBody("direct:start", "hello");
- // You can also send an external file
- // context.createProducerTemplate.sendBody("direct:start", context.getClassResolver().loadResourceAsStream("testdata/in/input.xml"));
-
- // REST/HTTP services can be easily tested with RestAssured:
- // get(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(204).body(isEmptyOrNullString());
- // given().param("status").get(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(200).body(equalTo("active"));
- // given().auth().basic("testuser", "testpass").body("hello").when().post(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(200).body(equalTo("response"));
-
resultEndpoint.assertIsSatisfied();
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a344ba76/tooling/archetypes/camel-archetype-scr/src/test/resources/projects/camel-scr-example/archetype.properties
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/test/resources/projects/camel-scr-example/archetype.properties b/tooling/archetypes/camel-archetype-scr/src/test/resources/projects/camel-scr-example/archetype.properties
index ed25df3..397e986 100644
--- a/tooling/archetypes/camel-archetype-scr/src/test/resources/projects/camel-scr-example/archetype.properties
+++ b/tooling/archetypes/camel-archetype-scr/src/test/resources/projects/camel-scr-example/archetype.properties
@@ -22,5 +22,4 @@ className = CamelScrExample
archetypeGroupId = ${project.groupId}
archetypeArtifactId = ${project.artifactId}
archetypeVersion = ${project.version}
-jboss-fuse-version = ${jboss-fuse-version}
target-camel-version = ${target-camel-version}
\ No newline at end of file