-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add a demo with Jsonp that can be ran inside an OSGI container #291
Open
aserkes
wants to merge
3
commits into
jakartaee:master
Choose a base branch
from
aserkes:osgi-demos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,6 +341,8 @@ | |
<Bundle-Description>Jakarta JSON Processing API ${spec.version}</Bundle-Description> | ||
<Specification-Vendor>${vendor.name}</Specification-Vendor> | ||
<Implementation-Build-Id>${buildNumber}</Implementation-Build-Id> | ||
<Import-Package></Import-Package> | ||
<Require-Capability>osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)", osgi.serviceloader; filter:="(osgi.serviceloader=jakarta.json.spi.JsonProvider)"; cardinality:=multiple</Require-Capability> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that osgi extender required? can we avoid using it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean follow https://docs.osgi.org/reference/portable-java-contracts.html somehow |
||
</instructions> | ||
</configuration> | ||
<executions> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. | ||
|
||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Distribution License v. 1.0, which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
|
||
SPDX-License-Identifier: BSD-3-Clause | ||
|
||
--> | ||
|
||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.jsonp</groupId> | ||
<artifactId>demos</artifactId> | ||
<version>2.0.2-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>jsondemos-jsonpointer-osgi</artifactId> | ||
<packaging>bundle</packaging> | ||
|
||
<properties> | ||
<main.class>JsonpointerOsgiDemo</main.class> | ||
<modules.directory>${project.build.directory}/modules</modules.directory> | ||
<spec.version>2.0</spec.version> | ||
<json.api.version>2.0.1-SNAPSHOT</json.api.version> | ||
<jsonp.impl.version>${project.version}</jsonp.impl.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.json</groupId> | ||
<artifactId>jakarta.json-api</artifactId> | ||
<version>${json.api.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jsonp</groupId> | ||
<artifactId>jsonp</artifactId> | ||
<version>${jsonp.impl.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>osgi.core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>org.apache.felix.framework</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>org.apache.felix.eventadmin</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-junit4</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-container-forked</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-link-mvn</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ops4j.pax.url</groupId> | ||
<artifactId>pax-url-aether</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Used in feature.xml and in tests--> | ||
<dependency> | ||
<groupId>org.apache.aries.spifly</groupId> | ||
<artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ow2.asm</groupId> | ||
<artifactId>asm-all</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.aries</groupId> | ||
<artifactId>org.apache.aries.util</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>maven-paxexam-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>generate-config</id> | ||
<goals> | ||
<goal>generate-depends-file</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>integration-tests</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<includes> | ||
<include>**/*IT.java</include> | ||
</includes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.glassfish.build</groupId> | ||
<artifactId>spec-version-maven-plugin</artifactId> | ||
<configuration> | ||
<spec> | ||
<nonFinal>${non.final}</nonFinal> | ||
<jarType>api</jarType> | ||
<specVersion>${spec.version}</specVersion> | ||
<specImplVersion>${project.version}</specImplVersion> | ||
<apiPackage>${project.artifactId}</apiPackage> | ||
</spec> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>set-spec-properties</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<id>main-artifact-module</id> | ||
<goals> | ||
<goal>bundle</goal> | ||
</goals> | ||
<configuration> | ||
<instructions> | ||
<Bundle-Activator>org.eclipse.jsondemos.osgi.jsonpointer.JsonpointerOsgiDemo | ||
</Bundle-Activator> | ||
<Bundle-Version>${spec.bundle.version}</Bundle-Version> | ||
<Bundle-SymbolicName>${spec.bundle.symbolic-name}</Bundle-SymbolicName> | ||
<Include-Resource>{maven-resources},target/classes/module-info.class</Include-Resource> | ||
</instructions> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.karaf.tooling</groupId> | ||
<artifactId>karaf-maven-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<startLevel>80</startLevel> | ||
<aggregateFeatures>false</aggregateFeatures> | ||
<includeProjectArtifact>true</includeProjectArtifact> | ||
<primaryFeatureName>${karaf.feature.name}</primaryFeatureName> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>generate-features-file</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>features-generate-descriptor</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<!-- | ||
|
||
Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
|
||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Distribution License v. 1.0, which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
|
||
SPDX-License-Identifier: BSD-3-Clause | ||
|
||
--> | ||
|
||
<!--Use for Karaf--> | ||
<features> | ||
<feature name="jsondemos-jsonpointer-osgi"> | ||
<bundle start-level="51">mvn:jakarta.json/jakarta.json-api/${project.version}</bundle> | ||
<bundle start-level="51">mvn:org.eclipse.jsonp/jsonp/${project.version}</bundle> | ||
<!-- Next 3 bundles are necessary for discovering and loading implementations matching a given interface (Java SPI), that used by jakarta.json-api--> | ||
<bundle start-level="50">mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/${spifly.version} | ||
</bundle> | ||
<bundle start-level="50">mvn:org.ow2.asm/asm-all/${asm.all.version}</bundle> | ||
<bundle start-level="50">mvn:org.apache.aries/org.apache.aries.util/${aries.util.version}</bundle> | ||
</feature> | ||
</features> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
module org.eclipse.jsondemos.osgi.jsonpointer { | ||
requires jakarta.json; | ||
requires osgi.core; | ||
} |
21 changes: 21 additions & 0 deletions
21
...pointer-osgi/src/main/java/org/eclipse/jsondemos/osgi/jsonpointer/JsonPointerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.jsondemos.osgi.jsonpointer; | ||
|
||
import jakarta.json.JsonObject; | ||
|
||
/** | ||
* Implementation of this interface will be registered in OSGI container as a service. | ||
*/ | ||
public interface JsonPointerService { | ||
|
||
JsonObject read(String pathToResource); | ||
} |
35 changes: 35 additions & 0 deletions
35
...ter-osgi/src/main/java/org/eclipse/jsondemos/osgi/jsonpointer/JsonPointerServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.jsondemos.osgi.jsonpointer; | ||
|
||
import jakarta.json.Json; | ||
import jakarta.json.JsonObject; | ||
import jakarta.json.JsonReader; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* This class will be registered as a service inside an OSGI container and will be available for other bundles. | ||
*/ | ||
public class JsonPointerServiceImpl implements JsonPointerService { | ||
@Override | ||
public JsonObject read(String pathToResource) { | ||
try ( | ||
InputStream is = JsonpointerOsgiDemo.class.getResourceAsStream("/wiki.json"); | ||
JsonReader rdr = Json.createReader(is) | ||
) { | ||
return rdr.readObject(); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be empty, nothing (or default
*
) is usually the best