tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya git commit: Replaced the name 'area' with 'section'. Implemented management JMX extension for Tamaya incl a minimal test bed. Added documentation/doc updates.
Date Mon, 24 Aug 2015 16:24:46 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master b6521ede9 -> f41ea3ca1


Replaced the name 'area' with 'section'.
Implemented management JMX extension for Tamaya incl a minimal test bed.
Added documentation/doc updates.


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

Branch: refs/heads/master
Commit: f41ea3ca155df12e678f69f1429280c978d1174f
Parents: b6521ed
Author: anatole <anatole@apache.org>
Authored: Mon Aug 24 18:24:32 2015 +0200
Committer: anatole <anatole@apache.org>
Committed: Mon Aug 24 18:24:32 2015 +0200

----------------------------------------------------------------------
 examples/pom.xml                                |  2 +-
 .../tamaya/events/FrozenConfiguration.java      |  2 +-
 .../tamaya/events/FrozenPropertySource.java     |  2 +-
 .../tamaya/format/ConfigurationFormat.java      |  4 +-
 .../functions/ConfigurationFunctions.java       | 49 ++++++++++++++------
 5 files changed, 40 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f41ea3ca/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index a720cf8..acc4347 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -40,7 +40,7 @@ under the License.
         <module>6-fileobserver-example</module>
         <module>5-injection-example</module>
         <module>7-builder-example</module>
-        <!-- module>remote-example</module -->
+        <!-- module>server-example</module -->
     </modules>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f41ea3ca/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
b/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
index 290e1a9..7afac7a 100644
--- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ b/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
@@ -36,7 +36,7 @@ import java.util.logging.Logger;
 
 /**
  * /**
- * Configuration implementation that stores all current values of a given (possibly dynamic,
contextual and non remote
+ * Configuration implementation that stores all current values of a given (possibly dynamic,
contextual and non server
  * capable instance) and is fully serializable. Note that hereby only the scannable key/value
pairs are considered.
  */
 public final class FrozenConfiguration implements Configuration, Serializable {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f41ea3ca/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
b/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
index 71f5294..12778be 100644
--- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ b/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
@@ -26,7 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * PropertySource implementation that stores all current values of a given (possibly dynamic,
contextual and non remote
+ * PropertySource implementation that stores all current values of a given (possibly dynamic,
contextual and non server
  * capable instance) and is fully serializable. Note that hereby only the scannable key/value
pairs are considered.
  */
 public final class FrozenPropertySource implements PropertySource, Serializable {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f41ea3ca/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
index ab06da1..37ff92e 100644
--- a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
+++ b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
@@ -46,7 +46,7 @@ public interface ConfigurationFormat {
     /**
      * Allows the format to examine the given resource, e.g. for a matching file ending.
Only, if a format accepts an
      * URL, it will be tried for reading the configuration.
-     * @param url the url to read the configuration data from (could be a file, a remote
location, a classpath
+     * @param url the url to read the configuration data from (could be a file, a server
location, a classpath
      *            resource or something else, not null.
      * @return true, if this format accepts the given URL for reading.
      */
@@ -89,7 +89,7 @@ public interface ConfigurationFormat {
      * entries.
      * @see org.apache.tamaya.spi.PropertySource
      * @param resource a descriptive name for the resource, since an InputStream does not
have any)
-     * @param inputStream the inputStream to read the configuration data from (could be a
file, a remote location, a classpath
+     * @param inputStream the inputStream to read the configuration data from (could be a
file, a server location, a classpath
      *            resource or something else.
      * @return the corresponding {@link ConfigurationData} containing sections/properties
read, never {@code null}.
      * @throws org.apache.tamaya.ConfigException if parsing of the input fails.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/f41ea3ca/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
index d01409b..0f9da3b 100644
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
+++ b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
@@ -23,7 +23,6 @@ import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
@@ -34,14 +33,15 @@ import java.util.TreeSet;
  */
 public final class ConfigurationFunctions {
 
-    private static final ConfigQuery<String> INFO_QUERY = new ConfigQuery<String>(){
+    private static final ConfigQuery<String> INFO_JSON_QUERY = new ConfigQuery<String>(){
         @Override
         public String query(Configuration config) {
             StringBuilder builder = new StringBuilder();
             Map<String,String> props = new TreeMap<>(config.getProperties());
-            builder.append("Configuration: {\n")
-                    .append("  \"class\": \n"+ config.getClass().getName() + ",\n")
-                    .append("  \"properties\": {\n");
+            builder.append("\"configuration\": {\n")
+                    .append("  \"class\": \""+ config.getClass().getName() + "\",\n")
+                    .append("  \"timestamp\": " + System.currentTimeMillis() + ",\n")
+                    .append("  \"data\": {\n");
             for(Map.Entry<String,String> en: props.entrySet()){
                 builder.append("     \"" + escape(en.getKey()) +"\": \""+escape(en.getValue())+"\",\n");
             }
@@ -49,6 +49,22 @@ public final class ConfigurationFunctions {
             return builder.toString();
         }
     };
+    private static final ConfigQuery<String> INFO_XML_QUERY = new ConfigQuery<String>(){
+        @Override
+        public String query(Configuration config) {
+            StringBuilder builder = new StringBuilder();
+            Map<String,String> props = new TreeMap<>(config.getProperties());
+            builder.append("<configuration>\n")
+                    .append("  <class>"+ config.getClass().getName() + "</class>\n")
+                    .append("  <timestamp>" + System.currentTimeMillis() + "</timestamp>\n")
+                    .append("  <data>\n");
+            for(Map.Entry<String,String> en: props.entrySet()){
+                builder.append("     <entry key=\"" + escape(en.getKey()) +"\">"+escape(en.getValue())+"</entry>\n");
+            }
+            builder.append("   </data>\n</configuration>\n");
+            return builder.toString();
+        }
+    };
 
 
     /**
@@ -183,13 +199,11 @@ public final class ConfigurationFunctions {
         return new ConfigQuery<Set<String>>() {
             @Override
             public Set<String> query(Configuration config) {
-                final Set<String> areas = new HashSet<>();
+                final Set<String> areas = new TreeSet<>();
                 for(String s: config.getProperties().keySet()) {
                     int index = s.lastIndexOf('.');
                     if (index > 0) {
                         areas.add(s.substring(0, index));
-                    } else {
-                        areas.add("<root>");
                     }
                 }
                 return areas;
@@ -209,12 +223,11 @@ public final class ConfigurationFunctions {
         return new ConfigQuery<Set<String>>() {
             @Override
             public Set<String> query(Configuration config) {
-                final Set<String> transitiveAreas = new HashSet<>();
+                final Set<String> transitiveAreas = new TreeSet<>();
                 for (String s : config.query(sections())) {
+                    transitiveAreas.add(s);
                     int index = s.lastIndexOf('.');
-                    if (index < 0) {
-                        transitiveAreas.add("<root>");
-                    } else {
+                    if (index > 0) {
                         while (index > 0) {
                             s = s.substring(0, index);
                             transitiveAreas.add(s);
@@ -241,7 +254,7 @@ public final class ConfigurationFunctions {
             @Override
             public Set<String> query(Configuration config) {
                 Set<String> result = new TreeSet<>();
-                for(String s: sections().query(config)){
+                for(String s : sections().query(config)){
                     if(predicate.test(s)){
                         result.add(s);
                     }
@@ -324,7 +337,15 @@ public final class ConfigurationFunctions {
      * @return the given query.
      */
     public static ConfigQuery<String> jsonInfo() {
-        return INFO_QUERY;
+        return INFO_JSON_QUERY;
+    }
+
+    /**
+     * Creates a ConfigQuery that creates a XML formatted ouitput of all properties in the
given configuration.
+     * @return the given query.
+     */
+    public static ConfigQuery<String> xmlInfo() {
+        return INFO_XML_QUERY;
     }
 
 }


Mime
View raw message