You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/04/22 10:33:51 UTC

[sling-org-apache-sling-feature] branch master updated: SLING-9362 : Use Apache Felix cm.json for JSON handling

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature.git


The following commit(s) were added to refs/heads/master by this push:
     new 4085cd9  SLING-9362 : Use Apache Felix cm.json for JSON handling
4085cd9 is described below

commit 4085cd9e1325b038ee6e6fc0aa7182d5954b2a0d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 22 12:33:36 2020 +0200

    SLING-9362 : Use Apache Felix cm.json for JSON handling
---
 pom.xml                                            |  14 +-
 .../org/apache/sling/feature/Configuration.java    | 149 +--------------------
 2 files changed, 14 insertions(+), 149 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8ecd781..35fa33d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,13 +91,19 @@
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-json_1.1_spec</artifactId>
-            <version>1.0</version>
+            <version>1.2</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.utils</artifactId>
-            <version>1.11.2</version>
+            <version>1.11.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.cm.json</artifactId>
+            <version>1.0.3-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 
@@ -111,13 +117,13 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>2.23.0</version>
+            <version>3.3.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.johnzon</groupId>
             <artifactId>johnzon-core</artifactId>
-            <version>1.0.0</version>
+            <version>1.2.3</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/src/main/java/org/apache/sling/feature/Configuration.java b/src/main/java/org/apache/sling/feature/Configuration.java
index 386b702..b44e9a6 100644
--- a/src/main/java/org/apache/sling/feature/Configuration.java
+++ b/src/main/java/org/apache/sling/feature/Configuration.java
@@ -16,14 +16,11 @@
  */
 package org.apache.sling.feature;
 
-import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
+
+import org.apache.felix.cm.json.Configurations;
 
 
 /**
@@ -58,8 +55,8 @@ public class Configuration
     /** The pid or name for factory pids. */
     private final String pid;
 
-    /** The properties. */
-    private final Dictionary<String, Object> properties = new OrderedDictionary();
+    /** The ordered properties. */
+    private final Dictionary<String, Object> properties = Configurations.newConfiguration();
 
     /**
      * Create a new configuration
@@ -213,142 +210,4 @@ public class Configuration
                 + ", properties=" + properties
                 + "]";
     }
-
-    static class OrderedDictionary extends Dictionary<String, Object> implements Map<String, Object> {
-
-        private static class EnumarationImpl<E> implements Enumeration<E> {
-            private final Iterator<E> iterator;
-
-            public EnumarationImpl(Iterator<E> iterator) {
-                this.iterator = iterator;
-            }
-
-            @Override
-            public boolean hasMoreElements() {
-                return iterator.hasNext();
-            }
-
-            @Override
-            public E nextElement() {
-                return iterator.next();
-            }
-        }
-
-        private final Map<String, Object> map = new LinkedHashMap<String, Object>();
-
-        @Override
-        public int size() {
-            return map.size();
-        }
-
-        @Override
-        public boolean isEmpty() {
-            return map.isEmpty();
-        }
-
-        @Override
-        public Enumeration<String> keys() {
-            return new EnumarationImpl<>(map.keySet().iterator());
-        }
-
-        @Override
-        public Enumeration<Object> elements() {
-            return new EnumarationImpl<>(map.values().iterator());
-        }
-
-        @Override
-        public Object get(Object key) {
-            return map.get(key);
-        }
-
-        @Override
-        public Object put(String key, Object value) {
-            // Make sure the value is not null
-            if (value == null) {
-                throw new NullPointerException();
-            }
-
-            return map.put(key, value);
-        }
-
-        @Override
-        public Object remove(Object key) {
-            return map.remove(key);
-        }
-
-        @Override
-		public boolean containsKey(Object key) {
-			return this.map.containsKey(key);
-		}
-
-		@Override
-		public boolean containsValue(Object value) {
-			return this.map.containsValue(value);
-		}
-
-		@Override
-		public void putAll(Map<? extends String, ? extends Object> m) {
-			this.map.putAll(m);
-		}
-
-		@Override
-		public void clear() {
-			this.map.clear();
-		}
-
-		@Override
-		public Set<String> keySet() {
-			return this.map.keySet();
-		}
-
-		@Override
-		public Collection<Object> values() {
-			return this.map.values();
-		}
-
-		@Override
-		public Set<Entry<String, Object>> entrySet() {
-			return this.map.entrySet();
-		}
-
-		@Override
-        public boolean equals(Object o) {
-        	if ( !(o instanceof OrderedDictionary) ) {
-        		if ( o instanceof Dictionary ) {
-        			@SuppressWarnings("rawtypes")
-					final Dictionary other = (Dictionary)o;
-        			if (other.size() == this.size() ) {
-        				final Enumeration<String> iter = this.keys();
-        				while ( iter.hasMoreElements() ) {
-        					final String key = iter.nextElement();
-        					final Object ov = other.get(key);
-        					if ( ov == null ) {
-        						return false;
-        					}
-        					final Object tv = this.get(key);
-        					if ( !tv.equals(ov) ) {
-        						return false;
-        					}
-        				}
-        				return true;
-        			}
-        		}
-        		if ( o instanceof Map ) {
-        			return map.equals(o);
-        		}
-        		return false;
-        	}
-            return map.equals(((OrderedDictionary)o).map);
-        }
-
-        @Override
-        public int hashCode() {
-            return map.hashCode();
-        }
-
-		@Override
-		public String toString() {
-			return map.toString();
-		}
-    }
 }