Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide all-in-one OSGi bundle for API and Core #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions johnzon-bundle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- 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. -->
<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">

<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>johnzon</artifactId>
<groupId>org.apache.johnzon</groupId>
<version>2.0.1-SNAPSHOT</version>
</parent>

<artifactId>johnzon-bundle</artifactId>
<name>Johnzon :: OSGi Bundle containing API and Implementation</name>
<packaging>bundle</packaging>

<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>jakarta.json.*;-split-package:=first,org.apache.johnzon.core.*</Export-Package>
<Import-Package></Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
182 changes: 182 additions & 0 deletions johnzon-bundle/src/main/java/jakarta/json/spi/JsonProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* 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 jakarta.json.spi;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Map;

import jakarta.json.JsonArray;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonMergePatch;
import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonPatch;
import jakarta.json.JsonPatchBuilder;
import jakarta.json.JsonPointer;
import jakarta.json.JsonReader;
import jakarta.json.JsonReaderFactory;
import jakarta.json.JsonString;
import jakarta.json.JsonStructure;
import jakarta.json.JsonValue;
import jakarta.json.JsonWriter;
import jakarta.json.JsonWriterFactory;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonGeneratorFactory;
import jakarta.json.stream.JsonParser;
import jakarta.json.stream.JsonParserFactory;

import org.osgi.annotation.versioning.ProviderType;

@ProviderType
public abstract class JsonProvider {
private static final class Holder {
private static final JsonProvider DEFAULT = new org.apache.johnzon.core.JsonProviderImpl();
}

protected JsonProvider() {
// no-op
}

public static JsonProvider provider() {
return Holder.DEFAULT;
}

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);

public abstract JsonObjectBuilder createObjectBuilder();

public JsonObjectBuilder createObjectBuilder(JsonObject object) {
throw new UnsupportedOperationException();
}

public JsonObjectBuilder createObjectBuilder(Map<String, ?> map) {
throw new UnsupportedOperationException();
}

public abstract JsonArrayBuilder createArrayBuilder();

public JsonArrayBuilder createArrayBuilder(JsonArray array) {
throw new UnsupportedOperationException();
}

public JsonPointer createPointer(String jsonPointer) {
throw new UnsupportedOperationException();
}

public JsonPatchBuilder createPatchBuilder() {
throw new UnsupportedOperationException();
}

public JsonPatchBuilder createPatchBuilder(JsonArray array) {
throw new UnsupportedOperationException();
}

public JsonPatch createPatch(JsonArray array) {
throw new UnsupportedOperationException();
}

public JsonPatch createDiff(JsonStructure source, JsonStructure target) {
throw new UnsupportedOperationException();
}

public JsonMergePatch createMergePatch(JsonValue patch) {
throw new UnsupportedOperationException();
}

public JsonMergePatch createMergeDiff(JsonValue source, JsonValue target) {
throw new UnsupportedOperationException();
}

public JsonArrayBuilder createArrayBuilder(Collection<?> collection) {
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();
}

public JsonNumber createValue(Number number) {
if (number instanceof Integer) {
return createValue(number.intValue());
} else if (number instanceof Long) {
return createValue(number.longValue());
} else if (number instanceof Double) {
return createValue(number.doubleValue());
} else if (number instanceof BigInteger) {
return createValue((BigInteger) number);
} else if (number instanceof BigDecimal) {
return createValue((BigDecimal) number);
} else {
throw new UnsupportedOperationException(number + " type is not known");
}
}
}

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<module>johnzon-jsonschema</module>
<module>johnzon-osgi</module>
<module>johnzon-jsonlogic</module>
<module>johnzon-bundle</module>
</modules>

<dependencyManagement>
Expand Down