Repository: camel Updated Branches: refs/heads/master 9e990ba46 -> 7c05e621f
CAMEL-9719: Camel Spring Boot Starter Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/89218fd7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/89218fd7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/89218fd7 Branch: refs/heads/master Commit: 89218fd7ff7b6b40e0306396f065e3bfc14064d4 Parents: 9e990ba Author: Claus Ibsen <[email protected]> Authored: Thu Mar 17 10:02:46 2016 +0100 Committer: Claus Ibsen <[email protected]> Committed: Thu Mar 17 11:54:25 2016 +0100 ---------------------------------------------------------------------- apache-camel/pom.xml | 12 +++ .../src/main/descriptors/common-bin.xml | 2 + .../camel-spring-boot-sample/pom.xml | 87 ++++++++++++++++++++ .../camel-spring-boot-sample/readme.adoc | 20 +++++ .../src/main/java/sample/camel/SampleBean.java | 31 +++++++ .../sample/camel/SampleCamelApplication.java | 34 ++++++++ .../java/sample/camel/SampleCamelRouter.java | 30 +++++++ .../src/main/resources/application.properties | 23 ++++++ .../camel/SampleCamelApplicationTest.java | 47 +++++++++++ .../camel-spring-boot-starter/pom.xml | 46 +++++++++++ .../src/main/resources/META-INF/spring.provides | 18 ++++ components/camel-spring-boot-starter/pom.xml | 38 +++++++++ parent/pom.xml | 21 +++++ 13 files changed, 409 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 26c86aa..00d1021 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -776,6 +776,18 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-sample</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-spring-integration</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/apache-camel/src/main/descriptors/common-bin.xml ---------------------------------------------------------------------- diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 9c1b121..c797dff 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -205,6 +205,8 @@ <include>org.apache.camel:camel-splunk</include> <include>org.apache.camel:camel-spring</include> <include>org.apache.camel:camel-spring-batch</include> + <include>org.apache.camel:camel-spring-boot</include> + <include>org.apache.camel:camel-spring-boot-starter</include> <include>org.apache.camel:camel-spring-integration</include> <include>org.apache.camel:camel-spring-javaconfig</include> <include>org.apache.camel:camel-spring-ldap</include> http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml b/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml new file mode 100644 index 0000000..48df175 --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml @@ -0,0 +1,87 @@ +<?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. +--> +<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> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter-parent</artifactId> + <version>2.17-SNAPSHOT</version> + </parent> + + <artifactId>camel-spring-boot-sample</artifactId> + <name>Camel :: Spring Boot :: Sample</name> + <description>Spring Boot Apache Camel Sample</description> + + <properties> + <spring.boot-version>${spring-boot-version}</spring.boot-version> + <camel-version>${project.version}</camel-version> + </properties> + + <!-- import Spring-Boot and Camel BOM --> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring.boot-version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-parent</artifactId> + <version>${camel-version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-stream</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring-boot-version}</version> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc b/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc new file mode 100644 index 0000000..d5d75c4 --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc @@ -0,0 +1,20 @@ += Spring Boot Camel Sample + +This example shows how to work with a simple Apache Camel application using Spring Boot. + +The example generates messages using timer trigger, writes them to standard output. + +== Camel routes + +The Camel route is located in the `SampleCamelRouter` class. In this class the route +starts from a timer, that triggers every 2nd second and calls a Spring Bean `SampleBean` +which returns a message, that is routed to a stream endpoint which writes to standard output. + +== Using Camel components + +Apache Camel provides 200+ components which you can use to integrate and route messages between many systems +and data formats. To use any of these Camel components, add the component as a dependency to your project. + +== More information + +You can find more information about Apache Camel at the website: http://camel.apache.org/ http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java new file mode 100644 index 0000000..0161acf --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java @@ -0,0 +1,31 @@ +/** + * 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 sample.camel; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("myBean") +public class SampleBean { + + @Value("greeting") + private String say; + + public String saySomething() { + return say; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java new file mode 100644 index 0000000..fe4e4dd --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java @@ -0,0 +1,34 @@ +/** + * 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 sample.camel; + +import org.apache.camel.spring.boot.CamelSpringBootApplicationController; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.ConfigurableApplicationContext; + +@SpringBootApplication +public class SampleCamelApplication { + + public static void main(String[] args) { + ConfigurableApplicationContext ctx = new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args); + + // keep the JVM running as Camel uses only daemon threads in the sample + CamelSpringBootApplicationController controller = ctx.getBean(CamelSpringBootApplicationController.class); + controller.blockMainThread(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java new file mode 100644 index 0000000..d3c2dd4 --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java @@ -0,0 +1,30 @@ +/** + * 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 sample.camel; + +import org.apache.camel.builder.RouteBuilder; + +public class SampleCamelRouter extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("timer:{{timer.name}}?period={{timer.period}}") + .transform(method("myBean", "saySomething")) + .to("stream:out"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties new file mode 100644 index 0000000..eb5bdee --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties @@ -0,0 +1,23 @@ +# +# 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. +# + +spring.main.sources: sample.camel.SampleCamelRouter + +greeting = Hello World + +timer.name = myTimer +timer.period = 2000 http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java new file mode 100644 index 0000000..e5a097c --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java @@ -0,0 +1,47 @@ +/** + * 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 sample.camel; + +import java.util.concurrent.TimeUnit; + +import org.apache.camel.CamelContext; +import org.apache.camel.builder.NotifyBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.assertTrue; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(SampleCamelApplication.class) +public class SampleCamelApplicationTest { + + @Autowired + private CamelContext camelContext; + + @Test + public void shouldProduceMessages() throws Exception { + // we expect that one or more messages is automatic done by the Camel + // route as it uses a timer to trigger + NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create(); + + assertTrue(notify.matches(10, TimeUnit.SECONDS)); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml b/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml new file mode 100644 index 0000000..bd5d6a8 --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml @@ -0,0 +1,46 @@ +<?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. +--> +<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> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter-parent</artifactId> + <version>2.17-SNAPSHOT</version> + </parent> + + <artifactId>camel-spring-boot-starter</artifactId> + <name>Camel :: Spring Boot :: Starter</name> + <description>Spring Boot Apache Camel Starter</description> + + <dependencies> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot</artifactId> + </dependency> + + </dependencies> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides b/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides new file mode 100644 index 0000000..32b9d63 --- /dev/null +++ b/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides @@ -0,0 +1,18 @@ +# +# 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. +# + +provides: camel-spring-boot \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/pom.xml b/components/camel-spring-boot-starter/pom.xml new file mode 100644 index 0000000..ae7d147 --- /dev/null +++ b/components/camel-spring-boot-starter/pom.xml @@ -0,0 +1,38 @@ +<?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. + --> +<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> + + <parent> + <artifactId>components</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.17-SNAPSHOT</version> + </parent> + + <artifactId>camel-spring-boot-starter-parent</artifactId> + <packaging>pom</packaging> + <name>Camel :: Spring-Boot :: Parent</name> + <description>Camel Spring-Boot parent</description> + + <modules> + <module>camel-spring-boot-starter</module> + <module>camel-spring-boot-sample</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 81a5c45..69cd698 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1589,6 +1589,16 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-sample</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-spring-integration</artifactId> <version>${project.version}</version> </dependency> @@ -2222,6 +2232,17 @@ <artifactId>spring-security-core</artifactId> <version>${spring-security-version}</version> </dependency> + <!-- spring-boot support --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + <version>${spring-boot-version}</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>${spring-boot-version}</version> + </dependency> <dependency> <groupId>org.scala-lang</groupId>
