Repository: camel Updated Branches: refs/heads/master f6d04c8df -> a30e54e89
CAMEL-9723: Move spring-boot-starter-sample to examples so we can collapse the camel-spring-boot-starter module Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a30e54e8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a30e54e8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a30e54e8 Branch: refs/heads/master Commit: a30e54e89d526b276bd19ba5f05d2cfad3941abb Parents: f6d04c8 Author: Claus Ibsen <[email protected]> Authored: Thu Mar 17 15:40:45 2016 +0100 Committer: Claus Ibsen <[email protected]> Committed: Thu Mar 17 15:45:54 2016 +0100 ---------------------------------------------------------------------- apache-camel/pom.xml | 4 - .../camel-spring-boot-sample/pom.xml | 99 -------------------- .../camel-spring-boot-sample/readme.adoc | 20 ---- .../src/main/java/sample/camel/SampleBean.java | 38 -------- .../sample/camel/SampleCamelApplication.java | 35 ------- .../java/sample/camel/SampleCamelRouter.java | 37 -------- .../src/main/resources/application.properties | 28 ------ .../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 | 54 ++++++----- .../src/main/resources/META-INF/spring.provides | 18 ++++ .../camel-example-spring-boot-starter/pom.xml | 99 ++++++++++++++++++++ .../readme.adoc | 20 ++++ .../src/main/java/sample/camel/SampleBean.java | 38 ++++++++ .../sample/camel/SampleCamelApplication.java | 35 +++++++ .../java/sample/camel/SampleCamelRouter.java | 37 ++++++++ .../src/main/resources/application.properties | 28 ++++++ .../camel/SampleCamelApplicationTest.java | 47 ++++++++++ examples/pom.xml | 1 + parent/pom.xml | 5 - 21 files changed, 354 insertions(+), 400 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 00d1021..24f2e9c 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -784,10 +784,6 @@ </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/a30e54e8/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 deleted file mode 100644 index 583da36..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?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> - - <!-- spring-web --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - - <!-- camel --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-stream</artifactId> - </dependency> - - <!-- test --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-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/a30e54e8/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 deleted file mode 100644 index d5d75c4..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= 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/a30e54e8/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 deleted file mode 100644 index ec7b3dd..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java +++ /dev/null @@ -1,38 +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 sample.camel; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * A bean that returns a message when you call the {@link #saySomething()} method. - * <p/> - * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt> - * that we use in the Camel route to lookup this bean. - */ -@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/a30e54e8/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 deleted file mode 100644 index 6c6c9ef..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java +++ /dev/null @@ -1,35 +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 sample.camel; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * A sample Spring Boot application that starts the Camel routes. - */ -@SpringBootApplication -public class SampleCamelApplication { - - /** - * A main method to start this application. - */ - public static void main(String[] args) { - SpringApplication.run(SampleCamelApplication.class, args); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/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 deleted file mode 100644 index 4e0422e..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java +++ /dev/null @@ -1,37 +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 sample.camel; - -import org.apache.camel.builder.RouteBuilder; -import org.springframework.stereotype.Component; - -/** - * A simple Camel route that triggers from a timer and calls a bean and prints to system out. - * <p/> - * Use <tt>@Component</tt> to make Camel auto detect this route when starting. - */ -@Component -public class SampleCamelRouter extends RouteBuilder { - - @Override - public void configure() throws Exception { - from("timer:hello?period={{timer.period}}") - .transform(method("myBean", "saySomething")) - .to("stream:out"); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/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 deleted file mode 100644 index 1d32a64..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties +++ /dev/null @@ -1,28 +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. -# - -# the name of Camel -camel.springboot.name = SampleCamel - -# properties used in the Camel route and beans -# -------------------------------------------- - -# what to say -greeting = Hello World - -# how often to trigger the timer -timer.period = 2000 http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/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 deleted file mode 100644 index e5a097c..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java +++ /dev/null @@ -1,47 +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 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/a30e54e8/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 deleted file mode 100644 index bd5d6a8..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?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/a30e54e8/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 deleted file mode 100644 index 32b9d63..0000000 --- a/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +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. -# - -provides: camel-spring-boot \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/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 index ae7d147..9fd1852 100644 --- a/components/camel-spring-boot-starter/pom.xml +++ b/components/camel-spring-boot-starter/pom.xml @@ -1,38 +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 + 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 + 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"> + 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> + <artifactId>components</artifactId> <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> + <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> - <modules> - <module>camel-spring-boot-starter</module> - <module>camel-spring-boot-sample</module> - </modules> + </dependencies> -</project> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/components/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides b/components/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/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/a30e54e8/examples/camel-example-spring-boot-starter/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/pom.xml b/examples/camel-example-spring-boot-starter/pom.xml new file mode 100644 index 0000000..3c0b6f4 --- /dev/null +++ b/examples/camel-example-spring-boot-starter/pom.xml @@ -0,0 +1,99 @@ +<?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>examples</artifactId> + <version>2.17-SNAPSHOT</version> + </parent> + + <artifactId>camel-example-spring-boot-starter</artifactId> + <name>Camel :: Example :: Spring Boot Starter</name> + <description>An example showing how to work with Camel and Spring Boot using Spring Boot Starter</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> + + <!-- spring-web --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <!-- camel --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-stream</artifactId> + </dependency> + + <!-- test --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-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/a30e54e8/examples/camel-example-spring-boot-starter/readme.adoc ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/readme.adoc b/examples/camel-example-spring-boot-starter/readme.adoc new file mode 100644 index 0000000..d5d75c4 --- /dev/null +++ b/examples/camel-example-spring-boot-starter/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/a30e54e8/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleBean.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleBean.java b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleBean.java new file mode 100644 index 0000000..ec7b3dd --- /dev/null +++ b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleBean.java @@ -0,0 +1,38 @@ +/** + * 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; + +/** + * A bean that returns a message when you call the {@link #saySomething()} method. + * <p/> + * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt> + * that we use in the Camel route to lookup this bean. + */ +@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/a30e54e8/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelApplication.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelApplication.java b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelApplication.java new file mode 100644 index 0000000..6c6c9ef --- /dev/null +++ b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelApplication.java @@ -0,0 +1,35 @@ +/** + * 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.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * A sample Spring Boot application that starts the Camel routes. + */ +@SpringBootApplication +public class SampleCamelApplication { + + /** + * A main method to start this application. + */ + public static void main(String[] args) { + SpringApplication.run(SampleCamelApplication.class, args); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelRouter.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelRouter.java b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelRouter.java new file mode 100644 index 0000000..4e0422e --- /dev/null +++ b/examples/camel-example-spring-boot-starter/src/main/java/sample/camel/SampleCamelRouter.java @@ -0,0 +1,37 @@ +/** + * 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; +import org.springframework.stereotype.Component; + +/** + * A simple Camel route that triggers from a timer and calls a bean and prints to system out. + * <p/> + * Use <tt>@Component</tt> to make Camel auto detect this route when starting. + */ +@Component +public class SampleCamelRouter extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("timer:hello?period={{timer.period}}") + .transform(method("myBean", "saySomething")) + .to("stream:out"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/examples/camel-example-spring-boot-starter/src/main/resources/application.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/src/main/resources/application.properties b/examples/camel-example-spring-boot-starter/src/main/resources/application.properties new file mode 100644 index 0000000..1d32a64 --- /dev/null +++ b/examples/camel-example-spring-boot-starter/src/main/resources/application.properties @@ -0,0 +1,28 @@ +# +# 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. +# + +# the name of Camel +camel.springboot.name = SampleCamel + +# properties used in the Camel route and beans +# -------------------------------------------- + +# what to say +greeting = Hello World + +# how often to trigger the timer +timer.period = 2000 http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/examples/camel-example-spring-boot-starter/src/test/java/sample/camel/SampleCamelApplicationTest.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-spring-boot-starter/src/test/java/sample/camel/SampleCamelApplicationTest.java b/examples/camel-example-spring-boot-starter/src/test/java/sample/camel/SampleCamelApplicationTest.java new file mode 100644 index 0000000..e5a097c --- /dev/null +++ b/examples/camel-example-spring-boot-starter/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/a30e54e8/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 16c1872..43c7017 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -77,6 +77,7 @@ <module>camel-example-spring</module> <module>camel-example-spring-boot</module> <module>camel-example-spring-boot-metrics</module> + <module>camel-example-spring-boot-starter</module> <module>camel-example-spring-javaconfig</module> <module>camel-example-spring-jms</module> <module>camel-example-spring-ws</module> http://git-wip-us.apache.org/repos/asf/camel/blob/a30e54e8/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 2ac1114..b15aeef 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1594,11 +1594,6 @@ </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>
