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 2015/09/28 10:39:41 UTC
camel git commit: CAMEL-9173: camel-archetype-scr - simpler example
generated that are similar to what we do in the other archetypes.
Repository: camel
Updated Branches:
refs/heads/master 1f27ebc30 -> 3d8ff95b9
CAMEL-9173: camel-archetype-scr - simpler example generated that are similar to what we do in the other archetypes.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3d8ff95b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3d8ff95b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3d8ff95b
Branch: refs/heads/master
Commit: 3d8ff95b97220a90ae61082b34f031d7b02b23fd
Parents: 1f27ebc
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 28 10:41:25 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 28 10:41:25 2015 +0200
----------------------------------------------------------------------
.../resources/archetype-resources/ReadMe.txt | 5 +-
.../main/resources/archetype-resources/pom.xml | 257 +++++++++----------
.../src/main/java/__className__.java | 13 +-
.../main/java/internal/__className__Route.java | 47 +---
.../src/test/java/__className__Test.java | 6 +-
.../src/test/resources/log4j.properties | 21 +-
6 files changed, 136 insertions(+), 213 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/ReadMe.txt
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/ReadMe.txt
index a981b75..9924764 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/ReadMe.txt
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/ReadMe.txt
@@ -15,14 +15,11 @@ To deploy this project in Apache Karaf (2.4.x)
# Install camel-scr feature
features:install camel-scr
- # Install commons-lang, used in the example route to validate parameters
- osgi:install mvn:commons-lang/commons-lang/${commons-lang-version}
-
# Install and start your bundle
osgi:install -s mvn:${groupId}/${artifactId}/${version}
# See how it's running
- log:tail -n 10
+ log:tail
Press ctrl-c to stop watching the log.
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/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 1a1e0f3..78f4019 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
@@ -1,157 +1,130 @@
<?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.
-## ------------------------------------------------------------------------
+ ## ------------------------------------------------------------------------
+ ## 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>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <packaging>bundle</packaging>
- <version>${version}</version>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>bundle</packaging>
+ <version>${version}</version>
- <name>A Camel Route</name>
- <url>http://www.myorganization.org</url>
+ <name>Camel SCR route</name>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-scr</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j-version}</version>
+ </dependency>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <version>${camel-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-scr</artifactId>
- <version>${camel-version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang-version}</version>
- </dependency>
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <version>${camel-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <!-- logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j-version}</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j-version}</version>
- </dependency>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin-version}</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin-version}</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
- <!-- testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <version>${camel-version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>${maven-scr-plugin-version}</version>
+ <executions>
+ <execution>
+ <id>generate-scr-scrdescriptor</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin-version}</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>${maven-resources-plugin-version}</version>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin-version}</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin-version}</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>${maven-release-plugin-version}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-gitexe</artifactId>
- <version>${maven-scm-provider-gitexe-version}</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>versions-maven-plugin</artifactId>
- <version>${versions-maven-plugin-version}</version>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- <version>${maven-scr-plugin-version}</version>
- <executions>
- <execution>
- <id>generate-scr-scrdescriptor</id>
- <phase>compile</phase>
- <goals>
- <goal>scr</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${maven-bundle-plugin-version}</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package/>
- <Private-Package>
- ${package},
- ${package}.*
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <!-- to generate the MANIFEST-FILE of the bundle -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${maven-bundle-plugin-version}</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+ <Private-Package>${package}.*</Private-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/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 c07f61f..c381dc0 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
@@ -31,16 +31,10 @@ import org.apache.felix.scr.annotations.*;
@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 = "camelRouteId", value = "foo"),
@Property(name = "active", value = "true"),
@Property(name = "from", value = "timer:foo?period=5000"),
- @Property(name = "to", value = "log:foo?showHeaders=true"),
- @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 = "to", value = "log:foo")
})
@References({
@Reference(name = "camelComponent",referenceInterface = ComponentResolver.class,
@@ -55,7 +49,8 @@ public class ${className} extends AbstractCamelRunner {
@Override
protected List<RoutesBuilder>getRouteBuilders() {
List<RoutesBuilder>routesBuilders = new ArrayList<>();
- routesBuilders.add(new ${className}Route(registry));
+ routesBuilders.add(new ${className}Route());
return routesBuilders;
}
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/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 bd4dd56..fce8e85 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
@@ -19,62 +19,17 @@
## ------------------------------------------------------------------------
package ${package}.internal;
-import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spi.Registry;
-import org.apache.commons.lang.Validate;
public class ${className}Route extends RouteBuilder {
- Registry registry;
-
// Configured fields
private String camelRouteId;
- private Integer maximumRedeliveries;
- private Long redeliveryDelay;
- private Double backOffMultiplier;
- private Long maximumRedeliveryDelay;
-
- public ${className}Route(final Registry registry) {
- this.registry = registry;
- }
@Override
public void configure() throws Exception {
- checkProperties();
-
- errorHandler(defaultErrorHandler()
- .retryAttemptedLogLevel(LoggingLevel.WARN)
- .maximumRedeliveries(maximumRedeliveries)
- .redeliveryDelay(redeliveryDelay)
- .backOffMultiplier(backOffMultiplier)
- .maximumRedeliveryDelay(maximumRedeliveryDelay));
-
- from("{{from}}")
- .startupOrder(2)
- .routeId(camelRouteId)
- .onCompletion()
- .to("direct:processCompletion")
- .end()
- .removeHeaders("CamelHttp*")
+ from("{{from}}").routeId(camelRouteId)
.to("{{to}}");
-
- from("direct:processCompletion")
- .startupOrder(1)
- .routeId(camelRouteId + ".completion")
- .choice()
- .when(simple("${exception} == null"))
- .log("{{messageOk}}")
- .otherwise()
- .log(LoggingLevel.ERROR, "{{messageError}}")
- .end();
}
- public void checkProperties() {
- Validate.notNull(camelRouteId, "camelRouteId property is not set");
- Validate.notNull(maximumRedeliveries, "maximumRedeliveries property is not set");
- Validate.notNull(redeliveryDelay, "redeliveryDelay property is not set");
- Validate.notNull(backOffMultiplier, "backOffMultiplier property is not set");
- Validate.notNull(maximumRedeliveryDelay, "maximumRedeliveryDelay property is not set");
- }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/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 dd5c67e..f3e2702 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
@@ -64,9 +64,6 @@ public class ${className}Test {
// Disable JMX for test
context.disableJMX();
-
- // Fake a component for test
- // context.addComponent("amq", new MockComponent());
}
@After
@@ -90,8 +87,7 @@ public class ${className}Test {
});
MockEndpoint resultEndpoint = context.getEndpoint("mock:log:foo", MockEndpoint.class);
- // resultEndpoint.expectedMessageCount(1); // If you want to just check the number of messages
- resultEndpoint.expectedBodiesReceived("hello"); // If you want to check the contents
+ resultEndpoint.expectedBodiesReceived("hello");
// Start the integration
integration.run();
http://git-wip-us.apache.org/repos/asf/camel/blob/3d8ff95b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/resources/log4j.properties b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/resources/log4j.properties
index 6c1da8d..330a162 100644
--- a/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/resources/log4j.properties
+++ b/tooling/archetypes/camel-archetype-scr/src/main/resources/archetype-resources/src/test/resources/log4j.properties
@@ -1,6 +1,3 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
## ------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
@@ -17,11 +14,21 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ------------------------------------------------------------------------
-
+#
+# The logging properties used for testing
+#
log4j.rootLogger=INFO, out
-${symbol_pound}log4j.logger.org.apache.camel=DEBUG
-log4j.logger.${groupId}=DEBUG
+
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
log4j.appender.out=org.apache.log4j.ConsoleAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-${symbol_pound}log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
+log4j.appender.file.file=target/camel-test.log