rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r1171064 - /incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java
Date Thu, 15 Sep 2011 11:51:56 GMT
Author: jasha
Date: Thu Sep 15 11:51:56 2011
New Revision: 1171064

URL: http://svn.apache.org/viewvc?rev=1171064&view=rev
Log:
RAVE-253 Use same binding method as in Shindig's PropertiesModule for host, port & contextroot
(as constant)

Modified:
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java

Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java?rev=1171064&r1=1171063&r2=1171064&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java
(original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/commoncontainer/ConfigurablePropertiesModule.java
Thu Sep 15 11:51:56 2011
@@ -62,7 +62,23 @@ public class ConfigurablePropertiesModul
      */
     @Override
     protected void configure() {
-        Names.bindProperties(this.binder(), getProperties());
+        bindPropertiesAsConstants();
+        bindNonConstantProperties();
+    }
+
+    private void bindPropertiesAsConstants() {
+        for(String propertyName: constantGuiceProperties()) {
+            this.binder().bindConstant().annotatedWith(Names.named(propertyName))
+                    .to(getProperties().getProperty(propertyName));
+        }
+    }
+
+    private void bindNonConstantProperties() {
+        Properties p = getProperties();
+        for (String overridableProperty : constantGuiceProperties()) {
+            p.remove(overridableProperty);
+        }
+        Names.bindProperties(this.binder(), p);
     }
 
     /**
@@ -197,4 +213,17 @@ public class ConfigurablePropertiesModul
         propertyNames.add("shindig.contextroot");
         return propertyNames;
     }
+
+    /**
+     *
+     * @return List of property keys that should be bound as constants in Guice
+     */
+    private static List<String> constantGuiceProperties() {
+        List<String> propertyNames = new ArrayList<String>();
+        propertyNames.add("shindig.host");
+        propertyNames.add("shindig.port");
+        propertyNames.add("shindig.contextroot");
+        return propertyNames;
+    }
+
 }



Mime
View raw message