You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2017/05/29 09:58:52 UTC
servicemix-specs git commit: Add json-api 1.1
Repository: servicemix-specs
Updated Branches:
refs/heads/master b0fbce1f5 -> 9265f7233
Add json-api 1.1
Project: http://git-wip-us.apache.org/repos/asf/servicemix-specs/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix-specs/commit/9265f723
Tree: http://git-wip-us.apache.org/repos/asf/servicemix-specs/tree/9265f723
Diff: http://git-wip-us.apache.org/repos/asf/servicemix-specs/diff/9265f723
Branch: refs/heads/master
Commit: 9265f72331f26f8374765d4530522d238edeecf2
Parents: b0fbce1
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu May 18 13:55:46 2017 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Mon May 29 11:54:10 2017 +0200
----------------------------------------------------------------------
json-api-1.1/pom.xml | 168 ++++++++
.../main/java/javax/json/spi/JsonProvider.java | 388 +++++++++++++++++++
pom.xml | 1 +
3 files changed, 557 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/servicemix-specs/blob/9265f723/json-api-1.1/pom.xml
----------------------------------------------------------------------
diff --git a/json-api-1.1/pom.xml b/json-api-1.1/pom.xml
new file mode 100644
index 0000000..8e84c4b
--- /dev/null
+++ b/json-api-1.1/pom.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>specs</artifactId>
+ <version>2.8-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.json-api-1.1</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.8-SNAPSHOT</version>
+ <name>Apache ServiceMix :: Specs :: JSon API 1.1</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.1_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.locator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Description>${project.description}</Bundle-Description>
+ <Export-Package>javax.json*;version=1.1;-split-package:=merge-first;-noimport:=true</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Private-Package>org.apache.servicemix.specs.locator;-split-package:=merge-first</Private-Package>
+ <Bundle-Activator>org.apache.servicemix.specs.locator.Activator</Bundle-Activator>
+ <Implementation-Title>Apache ServiceMix</Implementation-Title>
+ <Implementation-Version>${project.version}</Implementation-Version>
+ </instructions>
+ <unpackBundle>true</unpackBundle>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <artifactSet>
+ <includes>
+ <include>org.apache.geronimo.specs:geronimo-json_1.1_spec</include>
+ <include>org.apache.servicemix.specs:org.apache.servicemix.specs.locator</include>
+ </includes>
+ </artifactSet>
+ <filters>
+ <filter>
+ <artifact>org.apache.geronimo.specs:geronimo-json_1.1_spec</artifact>
+ <excludes>
+ <exclude>javax/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>org.apache.servicemix.specs:org.apache.servicemix.specs.locator</artifact>
+ <excludes>
+ <exclude>org/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>deploy</id>
+ <properties>
+ <createSourcesJar>true</createSourcesJar>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.1_spec</artifactId>
+ <classifier>sources</classifier>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.locator</artifactId>
+ <classifier>sources</classifier>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/sources</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <minmemory>128m</minmemory>
+ <maxmemory>512m</maxmemory>
+ <sourcepath>${project.build.directory}/sources</sourcepath>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/servicemix-specs/blob/9265f723/json-api-1.1/src/main/java/javax/json/spi/JsonProvider.java
----------------------------------------------------------------------
diff --git a/json-api-1.1/src/main/java/javax/json/spi/JsonProvider.java b/json-api-1.1/src/main/java/javax/json/spi/JsonProvider.java
new file mode 100644
index 0000000..ec4e340
--- /dev/null
+++ b/json-api-1.1/src/main/java/javax/json/spi/JsonProvider.java
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.json.spi;
+
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonBuilderFactory;
+import javax.json.JsonException;
+import javax.json.JsonMergePatch;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonPatch;
+import javax.json.JsonPatchBuilder;
+import javax.json.JsonPointer;
+import javax.json.JsonReader;
+import javax.json.JsonReaderFactory;
+import javax.json.JsonString;
+import javax.json.JsonStructure;
+import javax.json.JsonValue;
+import javax.json.JsonWriter;
+import javax.json.JsonWriterFactory;
+import javax.json.stream.JsonGenerator;
+import javax.json.stream.JsonGeneratorFactory;
+import javax.json.stream.JsonParser;
+import javax.json.stream.JsonParserFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JsonProvider is the actual implementation of all the Json logic.
+ * A JsonProvider instance can be used concurrently.
+ *
+ * It can be accessed via
+ * <pre>
+ * <code>
+ * JsonProvider provider = JsonProvider.provider();
+ * </code>
+ * </pre>
+ */
+public abstract class JsonProvider {
+ private static final String DEFAULT_PROVIDER = "org.apache.johnzon.core.JsonProviderImpl";
+
+ protected JsonProvider() {
+ // no-op
+ }
+
+ public static JsonProvider provider() {
+ if (System.getSecurityManager() != null) {
+ return AccessController.doPrivileged(new PrivilegedAction<JsonProvider>() {
+ public JsonProvider run() {
+ return doLoadProvider();
+ }
+ });
+ }
+ return doLoadProvider();
+ }
+
+ private static JsonProvider doLoadProvider() throws JsonException {
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Class<? extends JsonProvider> spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(
+ JsonProvider.class, JsonProvider.class.getName());
+ if (spiClass != null) {
+ return spiClass.newInstance();
+ }
+ } catch (final Throwable e) {
+ // locator not available, try normal mode
+ }
+
+ // don't use Class.forName() to avoid to bind class to tccl if thats a classloader facade
+ // so implementing a simple SPI when ProviderLocator is not here
+ final String name = "META-INF/services/" + JsonProvider.class.getName();
+ try {
+ Enumeration<URL> configs;
+ if (tccl == null) {
+ configs = ClassLoader.getSystemResources(name);
+ } else {
+ configs = tccl.getResources(name);
+ }
+
+ if (configs.hasMoreElements()) {
+ InputStream in = null;
+ BufferedReader r = null;
+ final List<String> names = new ArrayList<String>();
+ try {
+ in = configs.nextElement().openStream();
+ r = new BufferedReader(new InputStreamReader(in, "utf-8"));
+ String l;
+ while ((l = r.readLine()) != null) {
+ if (l.startsWith("#")) {
+ continue;
+ }
+ return JsonProvider.class.cast(tccl.loadClass(l).newInstance());
+ }
+ } catch (final IOException x) {
+ // no-op
+ } finally {
+ try {
+ if (r != null) {
+ r.close();
+ }
+ } catch (final IOException y) {
+ // no-op
+ }
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (final IOException y) {
+ // no-op
+ }
+ }
+ }
+ } catch (final Exception ex) {
+ // no-op
+ }
+
+ try {
+ final Class<?> clazz = tccl.loadClass(DEFAULT_PROVIDER);
+ return JsonProvider.class.cast(clazz.newInstance());
+ } catch (final Throwable cnfe) {
+ throw new JsonException(DEFAULT_PROVIDER + " not found", cnfe);
+ }
+ }
+
+ public abstract JsonParser createParser(Reader reader);
+
+ public abstract JsonParser createParser(InputStream in);
+
+ public abstract JsonParserFactory createParserFactory(Map<String, ?> config);
+
+ public abstract JsonGenerator createGenerator(Writer writer);
+
+ public abstract JsonGenerator createGenerator(OutputStream out);
+
+ public abstract JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config);
+
+ public abstract JsonReader createReader(Reader reader);
+
+ public abstract JsonReader createReader(InputStream in);
+
+ public abstract JsonWriter createWriter(Writer writer);
+
+ public abstract JsonWriter createWriter(OutputStream out);
+
+ public abstract JsonWriterFactory createWriterFactory(Map<String, ?> config);
+
+ public abstract JsonReaderFactory createReaderFactory(Map<String, ?> config);
+
+ /**
+ * Create an empty JsonObjectBuilder
+ * @since 1.0
+ */
+ public abstract JsonObjectBuilder createObjectBuilder();
+
+ /**
+ * Creates a JSON object builder, initialized with the specified JsonObject.
+ * @since 1.1
+ */
+ public JsonObjectBuilder createObjectBuilder(JsonObject jsonObject) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Creates a JSON object builder, initialized with the specified Map.
+ * @since 1.1
+ */
+ public JsonObjectBuilder createObjectBuilder(Map<String, Object> map) {
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract JsonArrayBuilder createArrayBuilder();
+
+ public JsonArrayBuilder createArrayBuilder(JsonArray initialData) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonArrayBuilder createArrayBuilder(Collection<?> initialData) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a {@link JsonPointer} based on the given path string
+ *
+ * @since 1.1
+ */
+ public JsonPointer createPointer(String path) {
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract JsonBuilderFactory createBuilderFactory(Map<String, ?> config);
+
+
+ public JsonString createValue(String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonNumber createValue(int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonNumber createValue(long value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonNumber createValue(double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonNumber createValue(BigDecimal value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public JsonNumber createValue(BigInteger value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a {@link JsonPatch} as defined in
+ * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
+ *
+ * @param array with the patch operations
+ * @return the JsonPatch based on the given operations
+ *
+ * @see #createDiff(JsonStructure, JsonStructure)
+ *
+ * @since 1.1
+ */
+ public JsonPatch createPatch(JsonArray array) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a {@link JsonPatch} by comparing the source to the target as defined in
+ * <a href="https://tools.ietf.org/html/rfc6902">RFC-6902</a>.
+ *
+ * Applying this {@link JsonPatch} to the source you will give you the target.
+ *
+ * @see #createPatch(JsonArray)
+ *
+ * @since 1.1
+ */
+ public JsonPatch createDiff(JsonStructure source, JsonStructure target) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a new JsonPatchBuilder
+ * @since 1.1
+ */
+ public JsonPatchBuilder createPatchBuilder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a new JsonPatchBuilder from initial data.
+ * @param initialData the initial patch operations
+ * @since 1.1
+ */
+ public JsonPatchBuilder createPatchBuilder(JsonArray initialData) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Create a merge patch based on the given JsonValue.
+ *
+ * If you have the following JsonMergePatch:
+ *
+ * <pre>
+ * {
+ * "a":"z",
+ * "c": {
+ * "f": null
+ * }
+ * }
+ * </pre>
+ *
+ * and apply it to the following JSON
+ *
+ * <pre>
+ * {
+ * "a": "b",
+ * "c": {
+ * "d": "e",
+ * "f": "g"
+ * }
+ * }
+ * </pre>
+ *
+ * you will get the following result:
+ *
+ * <pre>
+ * {
+ * "a": "z",
+ * "c": {
+ * "d": "e",
+ * }
+ * }
+ * </pre>
+ *
+ * @see #createMergeDiff(JsonValue, JsonValue)
+ *
+ * @since 1.1
+ */
+ public JsonMergePatch createMergePatch(JsonValue patch) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ /**
+ * Create a merge patch by comparing the source to the target.
+ * Applying this JsonMergePatch to the source will give you the target.
+ * A MergePatch is a JsonValue as defined in http://tools.ietf.org/html/rfc7396
+ *
+ * If you have a JSON like
+ * <pre>
+ * {
+ * "a": "b",
+ * "c": {
+ * "d": "e",
+ * "f": "g"
+ * }
+ * }
+ * </pre>
+ *
+ * and comparing it with
+ *
+ * <pre>
+ * {
+ * "a": "z",
+ * "c": {
+ * "d": "e",
+ * }
+ * }
+ * </pre>
+ *
+ * you will get the following JsonMergePatch:
+ *
+ * <pre>
+ * {
+ * "a":"z",
+ * "c": {
+ * "f": null
+ * }
+ * }
+ * </pre>
+ *
+ * @see #createMergePatch(JsonValue)
+ *
+ * @since 1.1
+ */
+ public JsonMergePatch createMergeDiff(JsonValue source, JsonValue target) {
+ throw new UnsupportedOperationException();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/servicemix-specs/blob/9265f723/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f9adaab..a955fea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,6 +74,7 @@
<module>jsr370-api-m1</module>
<module>jsr370-api-m4</module>
<module>jsr370-api-m5</module>
+ <module>json-api-1.1</module>
<module>assembly</module>
</modules>