Author: [email protected]
Date: Wed Jan 25 13:59:31 2012
New Revision: 1999

Log:
AMDATU-527 Configurable member should be volatile and reset to default when 
configuration is removed

Modified:
   
trunk/amdatu-kitchensink/demo-tenant-global/src/main/java/org/amdatu/kitchensink/demo/tenant/global/impl/GlobalApplicationImpl.java
   
trunk/amdatu-kitchensink/demo-tenant-local/src/main/java/org/amdatu/kitchensink/demo/tenant/local/impl/LocalApplicationImpl.java

Modified: 
trunk/amdatu-kitchensink/demo-tenant-global/src/main/java/org/amdatu/kitchensink/demo/tenant/global/impl/GlobalApplicationImpl.java
==============================================================================
--- 
trunk/amdatu-kitchensink/demo-tenant-global/src/main/java/org/amdatu/kitchensink/demo/tenant/global/impl/GlobalApplicationImpl.java
 (original)
+++ 
trunk/amdatu-kitchensink/demo-tenant-global/src/main/java/org/amdatu/kitchensink/demo/tenant/global/impl/GlobalApplicationImpl.java
 Wed Jan 25 13:59:31 2012
@@ -29,11 +29,11 @@
 
     public final static String CONFIG_PID = 
"org.amdatu.kitchensink.demo.tenant.global";
     public final static String CONFIG_MSG_KEY = "demo.tenant.msg";
+    public final static String MSG_DEFAULT = "Default message";
 
+    private volatile String m_helloWorldMessage = MSG_DEFAULT;
     private volatile Component m_component;
 
-    private String m_helloWorldMessage = "Default message";
-
     public void init() {
         setMessageProperty(m_helloWorldMessage);
     }
@@ -43,15 +43,19 @@
     }
 
     public void updated(Dictionary properties) throws ConfigurationException {
-        if (properties == null)
-            return;
-        Object msg = properties.get(CONFIG_MSG_KEY);
-        if (msg == null)
-            throw new ConfigurationException(CONFIG_MSG_KEY,
-                "Configuration value is missing");
-        if (!(msg instanceof String))
-            throw new ConfigurationException(CONFIG_MSG_KEY,
-                "Confgiration Value must be String");
+        String msg = MSG_DEFAULT;
+        if (properties != null) {
+            Object value = properties.get(CONFIG_MSG_KEY);
+            if (value == null) {
+                throw new ConfigurationException(CONFIG_MSG_KEY,
+                    "Configuration value is missing");
+            }
+            if (!(value instanceof String)) {
+                throw new ConfigurationException(CONFIG_MSG_KEY,
+                    "Configuration value must be String");
+            }
+            msg = (String) value;
+        }
         m_helloWorldMessage = (String) msg;
         setMessageProperty(m_helloWorldMessage);
     }

Modified: 
trunk/amdatu-kitchensink/demo-tenant-local/src/main/java/org/amdatu/kitchensink/demo/tenant/local/impl/LocalApplicationImpl.java
==============================================================================
--- 
trunk/amdatu-kitchensink/demo-tenant-local/src/main/java/org/amdatu/kitchensink/demo/tenant/local/impl/LocalApplicationImpl.java
    (original)
+++ 
trunk/amdatu-kitchensink/demo-tenant-local/src/main/java/org/amdatu/kitchensink/demo/tenant/local/impl/LocalApplicationImpl.java
    Wed Jan 25 13:59:31 2012
@@ -29,11 +29,11 @@
 
     public final static String CONFIG_PID = 
"org.amdatu.kitchensink.demo.tenant.local";
     public final static String CONFIG_MSG_KEY = "demo.tenant.msg";
+    public final static String MSG_DEFAULT = "Default message";
 
+    private volatile String m_helloWorldMessage = MSG_DEFAULT;
     private volatile Component m_component;
 
-    private String m_helloWorldMessage = "Default message";
-
     public void init() {
         setMessageProperty(m_helloWorldMessage);
     }
@@ -43,15 +43,19 @@
     }
 
     public void updated(Dictionary properties) throws ConfigurationException {
-        if (properties == null)
-            return;
-        Object msg = properties.get(CONFIG_MSG_KEY);
-        if (msg == null)
-            throw new ConfigurationException(CONFIG_MSG_KEY,
-                "Configuration value is missing");
-        if (!(msg instanceof String))
-            throw new ConfigurationException(CONFIG_MSG_KEY,
-                "Confgiration Value must be String");
+        String msg = MSG_DEFAULT;
+        if (properties != null) {
+            Object value = properties.get(CONFIG_MSG_KEY);
+            if (value == null) {
+                throw new ConfigurationException(CONFIG_MSG_KEY,
+                    "Configuration value is missing");
+            }
+            if (!(value instanceof String)) {
+                throw new ConfigurationException(CONFIG_MSG_KEY,
+                    "Configuration value must be String");
+            }
+            msg = (String) value;
+        }
         m_helloWorldMessage = (String) msg;
         setMessageProperty(m_helloWorldMessage);
     }
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to