polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [1/3] polygene-java git commit: javax.json serialization allows to set provider properties at assembly
Date Mon, 03 Apr 2017 09:22:49 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 5296c3551 -> 30acba2eb


javax.json serialization allows to set provider properties at assembly

Default is to ignore comments when using Johnzon

POLYGENE-238


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/40ae69a5
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/40ae69a5
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/40ae69a5

Branch: refs/heads/develop
Commit: 40ae69a596d4fdc4c138d3a452f73ebb77f78a9e
Parents: 5296c35
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Apr 3 10:18:08 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon Apr 3 10:18:08 2017 +0200

----------------------------------------------------------------------
 .../javaxjson/JavaxJsonFactories.java           | 15 ++++-------
 .../javaxjson/JavaxJsonSettings.java            | 28 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/40ae69a5/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonFactories.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonFactories.java
b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonFactories.java
index 99893bd..de5c79b 100644
--- a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonFactories.java
+++ b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonFactories.java
@@ -17,14 +17,11 @@
  */
 package org.apache.polygene.serialization.javaxjson;
 
-import java.util.Collections;
-import java.util.Map;
 import javax.json.JsonBuilderFactory;
 import javax.json.JsonException;
 import javax.json.JsonReaderFactory;
 import javax.json.JsonWriterFactory;
 import javax.json.spi.JsonProvider;
-import javax.json.stream.JsonGenerator;
 import javax.json.stream.JsonGeneratorFactory;
 import javax.json.stream.JsonParserFactory;
 import org.apache.polygene.api.injection.scope.Uses;
@@ -84,14 +81,12 @@ public interface JavaxJsonFactories
                 }
             }
 
-            Map<String, ?> parserProperties = Collections.singletonMap( "org.apache.johnzon.supports-comments",
true );
-            parserFactory = jsonProvider.createParserFactory( parserProperties );
-            readerFactory = jsonProvider.createReaderFactory( parserProperties );
+            parserFactory = jsonProvider.createParserFactory( settings.getJsonParserProperties()
);
+            readerFactory = jsonProvider.createReaderFactory( settings.getJsonParserProperties()
);
 
-            Map<String, ?> generatorProperties = Collections.emptyMap();
-            generatorFactory = jsonProvider.createGeneratorFactory( generatorProperties );
-            builderFactory = jsonProvider.createBuilderFactory( generatorProperties );
-            writerFactory = jsonProvider.createWriterFactory( generatorProperties );
+            generatorFactory = jsonProvider.createGeneratorFactory( settings.getJsonGeneratorProperties()
);
+            builderFactory = jsonProvider.createBuilderFactory( settings.getJsonGeneratorProperties()
);
+            writerFactory = jsonProvider.createWriterFactory( settings.getJsonGeneratorProperties()
);
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/40ae69a5/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSettings.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSettings.java
b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSettings.java
index de5c27f..e19392e 100644
--- a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSettings.java
+++ b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSettings.java
@@ -17,6 +17,7 @@
  */
 package org.apache.polygene.serialization.javaxjson;
 
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import org.apache.polygene.api.type.ValueType;
@@ -32,11 +33,18 @@ public class JavaxJsonSettings extends SerializationSettings<JavaxJsonSettings>
     }
 
     private String jsonProviderClassName;
+    private Map<String, Object> jsonParserProperties;
+    private Map<String, Object> jsonGeneratorProperties;
     private String typeInfoPropertyName;
     private Map<ValueType, JavaxJsonAdapter<?>> adapters;
 
     public JavaxJsonSettings()
     {
+        jsonParserProperties = new HashMap<String, Object>()
+        {{
+            put( "org.apache.johnzon.supports-comments", true );
+        }};
+        jsonGeneratorProperties = new HashMap<>();
         typeInfoPropertyName = "_type";
         adapters = new LinkedHashMap<>();
     }
@@ -51,6 +59,26 @@ public class JavaxJsonSettings extends SerializationSettings<JavaxJsonSettings>
         this.jsonProviderClassName = jsonProviderClassName;
     }
 
+    public Map<String, Object> getJsonParserProperties()
+    {
+        return jsonParserProperties;
+    }
+
+    public void setJsonParserProperties( Map<String, Object> jsonParserProperties )
+    {
+        this.jsonParserProperties = jsonParserProperties;
+    }
+
+    public Map<String, Object> getJsonGeneratorProperties()
+    {
+        return jsonGeneratorProperties;
+    }
+
+    public void setJsonGeneratorProperties( Map<String, Object> jsonGeneratorProperties
)
+    {
+        this.jsonGeneratorProperties = jsonGeneratorProperties;
+    }
+
     public String getTypeInfoPropertyName()
     {
         return typeInfoPropertyName;


Mime
View raw message