Repository: camel
Updated Branches:
  refs/heads/master d2000f861 -> 7d6e1307a


CAMEL-10358: Adding an example about how to use LiveReload with Camel and 
Spring-Boot


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7d6e1307
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7d6e1307
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7d6e1307

Branch: refs/heads/master
Commit: 7d6e1307a2cb4358f1a2c65cf440db3dca6eed3a
Parents: d2000f8
Author: Nicola Ferraro <ni.ferr...@gmail.com>
Authored: Wed Oct 26 11:14:20 2016 +0200
Committer: Nicola Ferraro <ni.ferr...@gmail.com>
Committed: Wed Oct 26 11:14:20 2016 +0200

----------------------------------------------------------------------
 .../pom.xml                                     | 106 +++++++++++++++++++
 .../readme.adoc                                 |  23 ++++
 .../livereload/LiveReloadApplication.java       |  37 +++++++
 .../springboot/livereload/LiveReloadRouter.java |  46 ++++++++
 .../src/main/resources/application.properties   |  25 +++++
 examples/pom.xml                                |   1 +
 6 files changed, 238 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/camel-example-spring-boot-live-reload/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-live-reload/pom.xml 
b/examples/camel-example-spring-boot-live-reload/pom.xml
new file mode 100644
index 0000000..03e1886
--- /dev/null
+++ b/examples/camel-example-spring-boot-live-reload/pom.xml
@@ -0,0 +1,106 @@
+<?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.19.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-spring-boot-live-reload</artifactId>
+    <name>Camel :: Example :: Spring Boot Live Reload</name>
+    <description>An example showing how to use the live reload feature of 
Spring Boot with Camel</description>
+
+    <properties>
+        <spring.boot-version>${spring-boot-version}</spring.boot-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-spring-boot-dependencies</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <!-- Spring-Boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- Camel -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-jetty-starter</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>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/camel-example-spring-boot-live-reload/readme.adoc
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-live-reload/readme.adoc 
b/examples/camel-example-spring-boot-live-reload/readme.adoc
new file mode 100644
index 0000000..e051c37
--- /dev/null
+++ b/examples/camel-example-spring-boot-live-reload/readme.adoc
@@ -0,0 +1,23 @@
+= Spring Boot Camel LiveReload Sample
+
+This example shows how to use the live reload feature of Spring Boot with 
Apache Camel.
+
+The example exposes a rest endpoint on http://localhost:8080/.
+The route can be tested with a browser having the LiveReload extension 
installed.
+LiveReload browser extensions are freely available for the most popular 
browsers from http://livereload.com[livereload.com].
+
+The example should be launched with the following maven command:
+
+ mvn clean install spring-boot:run
+
+Once the application is started, you can visit http://localhost:8080/ with a 
browser and activate the LiveReload feature
+(usually, by clicking on the extension's icon).
+
+Changing the source code (eg. changing the default message returned by the 
route) will produce a refresh in the browser.
+When using IntelliJ Idea, after doing the changes, you should compile the 
project (eg. by clicking on the _"Make Project"_ button)
+in order to see the changes in the browser.
+
+== More information
+
+You can find more information about Apache Camel at the website: 
http://camel.apache.org/.
+You can find more information about the LiveReload feature in the 
http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html[dev
 tools documentation].

http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadApplication.java
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadApplication.java
 
b/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadApplication.java
new file mode 100644
index 0000000..20547c7
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadApplication.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 org.apache.camel.example.springboot.livereload;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ */
+@SpringBootApplication
+public class LiveReloadApplication {
+
+    /**
+     * A main method to start this application.
+     */
+    public static void main(String[] args) {
+        SpringApplication.run(LiveReloadApplication.class, args);
+    }
+
+}
+//CHECKSTYLE:ON

http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadRouter.java
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadRouter.java
 
b/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadRouter.java
new file mode 100644
index 0000000..3c77e02
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-live-reload/src/main/java/org/apache/camel/example/springboot/livereload/LiveReloadRouter.java
@@ -0,0 +1,46 @@
+/**
+ * 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.example.springboot.livereload;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * A simple Camel route that exposes a text/plain REST endpoint returning a 
simple message.
+ * <p/>
+ * Use <tt>@Component</tt> to make Camel auto detect this route when starting.
+ */
+@Component
+public class LiveReloadRouter extends RouteBuilder {
+
+    @Value("${port}")
+    private Integer port;
+
+    @Override
+    public void configure() throws Exception {
+
+        restConfiguration().port(port);
+
+        rest().get("/")
+                .produces("text/plain")
+                .route()
+                .transform().constant("Change me");
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/camel-example-spring-boot-live-reload/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-spring-boot-live-reload/src/main/resources/application.properties
 
b/examples/camel-example-spring-boot-live-reload/src/main/resources/application.properties
new file mode 100644
index 0000000..718de5c
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-live-reload/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+# Name of the Camel app
+camel.springboot.name = SampleCamelLiveReload
+
+# The server port
+port=8080
+
+# Enable live reload
+spring.devtools.livereload.enabled=true

http://git-wip-us.apache.org/repos/asf/camel/blob/7d6e1307/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index be4a662..481f6a5 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -81,6 +81,7 @@
     <module>camel-example-splunk</module>
     <module>camel-example-spring</module>
     <module>camel-example-spring-boot</module>
+    <module>camel-example-spring-boot-live-reload</module>
     <module>camel-example-spring-boot-metrics</module>
     <module>camel-example-spring-boot-rest-jpa</module>
     <module>camel-example-spring-boot-starter</module>

Reply via email to