tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pottlin...@apache.org
Subject incubator-tamaya-extensions git commit: TAMAYA-318: Refactor spring example
Date Mon, 04 Dec 2017 23:01:58 GMT
Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master 242174a9a -> 4367539ce


TAMAYA-318: Refactor spring example

to work without user input


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/4367539c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/4367539c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/4367539c

Branch: refs/heads/master
Commit: 4367539ce90808273a1d15d0b42bc0b3d004ee08
Parents: 242174a
Author: Phil Ottlinger <pottlinger@apache.org>
Authored: Tue Dec 5 00:01:36 2017 +0100
Committer: Phil Ottlinger <pottlinger@apache.org>
Committed: Tue Dec 5 00:01:36 2017 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/springexample/WelcomeController.java   | 8 ++++----
 .../src/main/resources/templates/welcome.ftl                 | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4367539c/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/WelcomeController.java
----------------------------------------------------------------------
diff --git a/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/WelcomeController.java
b/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/WelcomeController.java
index 172c4d5..affafef 100644
--- a/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/WelcomeController.java
+++ b/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/WelcomeController.java
@@ -29,10 +29,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
-import javax.websocket.server.PathParam;
-
 @Controller
 public class WelcomeController {
+	
+	private static final String FOREGROUND_DEFAULT = "#DDDDDD"; 
 
 	@Value("${application.message:Hello World}")
 	private String message = "Hello World";
@@ -40,7 +40,7 @@ public class WelcomeController {
 	@Config(value = "background.color", required = false)
 	private String backgroundColor = "#BBBBBB";
 
-	@Config(value = "foreground.color", required = false, defaultValue = "#DDDDDD")
+	@Config(value = "foreground.color", required = false, defaultValue = FOREGROUND_DEFAULT)
 	private DynamicValue<String> foregroundColor;
 
 	@Config(value = "background.color", required = false)
@@ -59,7 +59,7 @@ public class WelcomeController {
 	@GetMapping("/update")
 	public String update(@RequestParam("foreground") String newForeground, Map<String, Object>
model) {
 		foregroundColor.setUpdatePolicy(UpdatePolicy.IMMEDIATE);
-		if(newForeground!=null){
+		if(newForeground!=null && !newForeground.isEmpty()){
 			System.out.println("Setting new foreground: " + newForeground+"...");
 			System.setProperty("foreground.color", newForeground);
 		}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4367539c/examples/05-spring-example/src/main/resources/templates/welcome.ftl
----------------------------------------------------------------------
diff --git a/examples/05-spring-example/src/main/resources/templates/welcome.ftl b/examples/05-spring-example/src/main/resources/templates/welcome.ftl
index da57937..08738da 100644
--- a/examples/05-spring-example/src/main/resources/templates/welcome.ftl
+++ b/examples/05-spring-example/src/main/resources/templates/welcome.ftl
@@ -21,7 +21,7 @@
 
 <body>
     <h1>Tamaya - Spring Boot Example</h1>
-    This example show how Tamaya Configuration can be used with Spring Boot to enable Spring
with Tamaya
+    This example shows how Tamaya Configuration can be used with Spring Boot to enable Spring
with Tamaya
     dynamic configuration features and Tamaya Configuration Injection.
     <h2>Accessing properties programmatically</h2>
     Configuration properties can be easily accessed with Tamaya's Java API:<br/>


Mime
View raw message