From 2462447f56660ddedff092deced1d0052765fc42 Mon Sep 17 00:00:00 2001 From: Jaroslav Pullmann Date: Tue, 29 Mar 2016 17:56:12 +0200 Subject: [PATCH 1/5] Fixed static initialisation issue in OSGi by adding SPI-related headers --- apache-jena-osgi/jena-osgi/pom.xml | 19 +++++++- .../java/org/apache/jena/osgi/Activator.java | 47 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java diff --git a/apache-jena-osgi/jena-osgi/pom.xml b/apache-jena-osgi/jena-osgi/pom.xml index f42c09eea26..aaa0fa88f16 100644 --- a/apache-jena-osgi/jena-osgi/pom.xml +++ b/apache-jena-osgi/jena-osgi/pom.xml @@ -219,6 +219,11 @@ org.apache.commons commons-lang3 + + org.osgi + org.osgi.core + 5.0.0 + @@ -233,8 +238,20 @@ org.apache.jena.*,!org.apache.jena.ext.* artifactId=jena*;inline=true,artifactId=xercesImpl;inline=true,artifactId=xml-apis;inline=true true - !sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.xml.*,!org.apache.xerces.*,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* + org.osgi.framework.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.xml.*,!org.apache.xerces.*,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* org.apache.jena.ext.* + org.apache.jena.osgi.Activator + + + osgi.extender; filter:="(|(osgi.extender=osgi.serviceloader.registrar)(osgi.extender=osgi.serviceloader.processor))", + osgi.serviceloader; filter:="(osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle)";cardinality:=multiple + + osgi.serviceloader; osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle + + diff --git a/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java new file mode 100644 index 00000000000..90f8016eb95 --- /dev/null +++ b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java @@ -0,0 +1,47 @@ +package org.apache.jena.osgi; + +import org.apache.jena.system.JenaSubsystemRegistry; +import org.apache.jena.system.JenaSubsystemRegistryBasic; +import org.apache.jena.system.JenaSystem; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + /* + * Based on http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java + * the Activator#start() waits for bundle extension by Aries SPI Fly, configures JenaSystem logging and requests for initialization. + */ + public void start(BundleContext context) throws Exception { + + Thread t = new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + } + setUpJena(); + } + }); + t.start(); + } + + private void setUpJena() { + JenaSubsystemRegistry r = new JenaSubsystemRegistryBasic() { + @Override + public void load() { + super.load(); + } + }; + JenaSystem.setSubsystemRegistry(r); + JenaSystem.DEBUG_INIT = true; + JenaSystem.init(); + System.out.println("Jena-OSGi bundle configuration done!"); + + } + + public void stop(BundleContext context) throws Exception { + + } +} From 0ff9beb1122ffc1f2e5812972a81107f037c9e12 Mon Sep 17 00:00:00 2001 From: Jaroslav Pullmann Date: Mon, 4 Apr 2016 16:23:36 +0200 Subject: [PATCH 2/5] Jena-OSGi integration test updated, removed Xerces as embedded dependency --- apache-jena-osgi/jena-osgi-test/pom.xml | 292 ++++++------------ .../apache/jena/osgi/test/JenaOSGITest.java | 118 +++---- apache-jena-osgi/jena-osgi/pom.xml | 27 +- 3 files changed, 158 insertions(+), 279 deletions(-) diff --git a/apache-jena-osgi/jena-osgi-test/pom.xml b/apache-jena-osgi/jena-osgi-test/pom.xml index 2e63b540c11..b28d877cf5e 100644 --- a/apache-jena-osgi/jena-osgi-test/pom.xml +++ b/apache-jena-osgi/jena-osgi-test/pom.xml @@ -1,205 +1,93 @@ - - - - 4.0.0 - - org.apache.jena - jena-parent - 15-SNAPSHOT - ../../jena-parent - - - jena-osgi-test - 3.0.1-SNAPSHOT - Apache Jena - OSGi integration tests - Tests for jena-osgi as a bundle - bundle - - - 4.6.0 - 4.4.0 - 1.6.0 - 1.8.1 - - - - - apache.snapshots - Apache Snapshot Repository - http://repository.apache.org/snapshots - - false - - - - - - - org.apache.jena - jena-osgi - ${project.version} - bundle - test - - - - org.osgi - org.osgi.core - 5.0.0 - provided - - - - junit - junit - test - - - - - org.ops4j.pax.logging - pax-logging-log4j2 - ${pax.logging.version} - test - - - org.ops4j.pax.logging - pax-logging-api - ${pax.logging.version} - test - - - - org.ops4j.pax.exam - pax-exam-container-native - ${pax.exam.version} - test - - - - org.ops4j.pax.exam - pax-exam-junit4 - ${pax.exam.version} - test - - - - org.ops4j.pax.exam - pax-exam-link-mvn - ${pax.exam.version} - test - - - - org.ops4j.pax.url - pax-url-aether - ${pax.url.version} - test - - - - - org.eclipse - osgi - 3.9.1-v20140110-1610 - test - - - - org.apache.felix - org.apache.felix.framework - ${felix.version} - test - - - - - - - - org.apache.felix - maven-bundle-plugin - - true - - - - org.ops4j.pax.exam - exam-maven-plugin - ${pax.exam.version} - - - generate-link-files - - generate-link-files - - generate-test-resources - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - default-testCompile - - testCompile - - pre-integration-test - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.slf4j:slf4j-log4j12 - - - - ${project.version} - - WARN - - - - - - default-test - - test - - - integration-test - - - - - + + + + 4.0.0 + + org.apache.jena + jena-parent + 16-SNAPSHOT + + + jena-osgi-test + + 3.1.0-SNAPSHOT + Apache Jena - OSGi integration tests + Tests for jena-osgi as a bundle + bundle + + + 4.4.0 + + + + + apache.snapshots + Apache Snapshot Repository + http://repository.apache.org/snapshots + + false + + + + + + + org.apache.jena + jena-osgi + 3.1.0-SNAPSHOT + bundle + test + + + + org.ops4j.pax.exam + pax-exam-container-karaf + ${pax.exam.version} + test + + + + org.ops4j.pax.exam + pax-exam-junit4 + ${pax.exam.version} + test + + + + org.ops4j.pax.exam + pax-exam-link-mvn + ${pax.exam.version} + test + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + verify + + integration-test + verify + + + + + + diff --git a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java index ef0d85edf48..8dcb8c0bf92 100644 --- a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java +++ b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java @@ -20,10 +20,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.linkBundle; +import static org.ops4j.pax.exam.CoreOptions.maven; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; import java.io.OutputStream; import java.io.StringWriter; @@ -31,22 +31,8 @@ import java.nio.file.Files; import java.nio.file.Path; -import javax.inject.Inject; - import org.apache.jena.iri.IRI; import org.apache.jena.iri.IRIFactory; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFDataMgr; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; -import org.osgi.framework.BundleContext; - import org.apache.jena.ontology.Individual; import org.apache.jena.ontology.ObjectProperty; import org.apache.jena.ontology.OntModel; @@ -61,12 +47,19 @@ import org.apache.jena.query.ReadWrite; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; -import org.apache.jena.ontology.OntModel ; -import org.apache.jena.ontology.OntModelSpec ; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.tdb.TDBFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; /** * Brief tests of the Jena modules covered by jena-osgi @@ -76,35 +69,40 @@ @ExamReactorStrategy(PerClass.class) public class JenaOSGITest { - @Inject - private BundleContext bc; - @Configuration public Option[] config() { + return options( - // bundle with org.slf4j implementation - linkBundle("org.ops4j.pax.logging.pax-logging-log4j2"), - linkBundle("org.ops4j.pax.logging.pax-logging-api"), - - // jena-osgi - mavenBundle("org.apache.jena", "jena-osgi", - System.getProperty("jena-osgi.version", "LATEST")), - - // dependencies of jena-osgi - linkBundle("org.apache.httpcomponents.httpclient"), - linkBundle("org.apache.httpcomponents.httpcore"), - linkBundle("com.github.jsonld-java"), - linkBundle("org.apache.commons.csv"), - linkBundle("org.apache.thrift"), - linkBundle("jcl.over.slf4j"), + // OSGi container configuration + karafDistributionConfiguration().frameworkUrl( + maven().groupId("org.apache.karaf") + .artifactId("apache-karaf").type("zip") + .version("3.0.6")).useDeployFolder(false), - linkBundle("com.fasterxml.jackson.core.jackson-core"), - linkBundle("com.fasterxml.jackson.core.jackson-databind"), - linkBundle("com.fasterxml.jackson.core.jackson-annotations"), - linkBundle("org.apache.commons.lang3"), - - junitBundles() - ); + mavenBundle("org.apache.aries.spifly", + "org.apache.aries.spifly.dynamic.bundle", "1.0.8"), + + mavenBundle("org.apache.jena", "jena-osgi", "3.1.0-SNAPSHOT"), + mavenBundle("com.github.andrewoma.dexx", "collection", "0.4.0"), + mavenBundle("com.github.jsonld-java", "jsonld-java", "0.8.0"), + mavenBundle("org.apache.httpcomponents", "httpcore-osgi", + "4.4.4"), + mavenBundle("org.apache.httpcomponents", "httpclient-osgi", + "4.5.1"), + mavenBundle("commons-cli", "commons-cli", "1.3.1"), + mavenBundle("org.apache.commons", "commons-csv", "1.2"), + mavenBundle("org.apache.commons", "commons-lang3", "3.4"), + mavenBundle("org.apache.thrift", "libthrift", "0.9.3"), + + mavenBundle("com.fasterxml.jackson.core", "jackson-core", + "2.6.3"), + mavenBundle("com.fasterxml.jackson.core", "jackson-databind", + "2.6.3"), + mavenBundle("com.fasterxml.jackson.core", + "jackson-annotations", "2.6.3") + + ); + } private static final String EXAMPLE_COM_GRAPH = "http://example.com/graph"; @@ -115,19 +113,13 @@ public Option[] config() { @Test public void testJenaCore() throws Exception { Model model = makeModel(); - - // Does Model's Class.forName() still work? - model.setWriterClassName("someWriter", - "com.hp.hpl.jena.rdf.model.impl.NTripleWriter"); Writer writer = new StringWriter(); - model.write(writer, "someWriter"); - // yes, but only as long as that classname is accessible within - // jena-osgi bundle + model.write(writer, "N-Triples"); + assertEquals( " .", writer.toString().trim()); - - // Let's also test com.hp.hpl.jena.ontology + OntModel ontModel = ModelFactory .createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF); ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows @@ -142,15 +134,6 @@ public void testJenaCore() throws Exception { assertTrue(aliceIndividual.hasProperty(knowsObjProp, bobIndividiual)); } - private Model makeModel() { - Model model = ModelFactory.createDefaultModel(); - alice = model.createResource("http://example.com/alice"); - knows = model.createProperty("http://xmlns.com/foaf/0.1/knows"); - bob = model.createResource("http://example.com/bob"); - model.add(model.createStatement(alice, knows, bob)); - return model; - } - @Test public void testJenaArq() throws Exception { Dataset dataset = DatasetFactory.createMem(); @@ -209,11 +192,12 @@ public void testJenaTdb() throws Exception { dataset.end(); } - /* - @Test - public void createOntModel() - { - final OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); + private Model makeModel() { + Model model = ModelFactory.createDefaultModel(); + alice = model.createResource("http://example.com/alice"); + knows = model.createProperty("http://xmlns.com/foaf/0.1/knows"); + bob = model.createResource("http://example.com/bob"); + model.add(model.createStatement(alice, knows, bob)); + return model; } - */ } diff --git a/apache-jena-osgi/jena-osgi/pom.xml b/apache-jena-osgi/jena-osgi/pom.xml index aaa0fa88f16..6225f314c50 100644 --- a/apache-jena-osgi/jena-osgi/pom.xml +++ b/apache-jena-osgi/jena-osgi/pom.xml @@ -26,7 +26,7 @@ apache-jena-osgi 3.1.0-SNAPSHOT - jena-osgi + jena-osgi bundle Apache Jena - OSGi bundle @@ -236,22 +236,29 @@ org.apache.jena.*,!org.apache.jena.ext.* + artifactId=jena*;inline=true + true + + org.osgi.framework.*,org.apache.xml.*,org.apache.xerces.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* + org.apache.jena.ext.* org.apache.jena.osgi.Activator - - osgi.extender; filter:="(|(osgi.extender=osgi.serviceloader.registrar)(osgi.extender=osgi.serviceloader.processor))", - osgi.serviceloader; filter:="(osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle)";cardinality:=multiple - - osgi.serviceloader; osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle - + + osgi.extender; filter:="(|(osgi.extender=osgi.serviceloader.registrar)(osgi.extender=osgi.serviceloader.processor))", + osgi.serviceloader; filter:="(osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle)";cardinality:=multiple + + osgi.serviceloader; osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle + + * + * + --> From 10bcc01743f49d8c7b4e93393c1e69411aa596f1 Mon Sep 17 00:00:00 2001 From: Jaroslav Pullmann Date: Thu, 7 Apr 2016 11:54:10 +0200 Subject: [PATCH 3/5] Included new OSGified version of Dexx collection --- .../apache/jena/osgi/test/JenaOSGITest.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java index 8dcb8c0bf92..9a8f475e48c 100644 --- a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java +++ b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java @@ -83,23 +83,17 @@ public Option[] config() { "org.apache.aries.spifly.dynamic.bundle", "1.0.8"), mavenBundle("org.apache.jena", "jena-osgi", "3.1.0-SNAPSHOT"), - mavenBundle("com.github.andrewoma.dexx", "collection", "0.4.0"), + mavenBundle("com.github.andrewoma.dexx", "collection", "0.6.0-SNAPSHOT"), mavenBundle("com.github.jsonld-java", "jsonld-java", "0.8.0"), - mavenBundle("org.apache.httpcomponents", "httpcore-osgi", - "4.4.4"), - mavenBundle("org.apache.httpcomponents", "httpclient-osgi", - "4.5.1"), + mavenBundle("org.apache.httpcomponents", "httpcore-osgi","4.4.4"), + mavenBundle("org.apache.httpcomponents", "httpclient-osgi","4.5.1"), mavenBundle("commons-cli", "commons-cli", "1.3.1"), mavenBundle("org.apache.commons", "commons-csv", "1.2"), mavenBundle("org.apache.commons", "commons-lang3", "3.4"), mavenBundle("org.apache.thrift", "libthrift", "0.9.3"), - - mavenBundle("com.fasterxml.jackson.core", "jackson-core", - "2.6.3"), - mavenBundle("com.fasterxml.jackson.core", "jackson-databind", - "2.6.3"), - mavenBundle("com.fasterxml.jackson.core", - "jackson-annotations", "2.6.3") + mavenBundle("com.fasterxml.jackson.core", "jackson-core","2.6.3"), + mavenBundle("com.fasterxml.jackson.core", "jackson-databind","2.6.3"), + mavenBundle("com.fasterxml.jackson.core","jackson-annotations", "2.6.3") ); From cbf669541b97f8fbd263d11a8a9790773fa132f6 Mon Sep 17 00:00:00 2001 From: Jaroslav Pullmann Date: Thu, 7 Apr 2016 16:51:11 +0200 Subject: [PATCH 4/5] Bundle's classloader used in ServiceLoader#load --- .../org/apache/jena/osgi/test/JenaOSGITest.java | 3 +-- apache-jena-osgi/jena-osgi/pom.xml | 16 +++++++++------- .../jena/system/JenaSubsystemRegistryBasic.java | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java index 9a8f475e48c..1d468f162f3 100644 --- a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java +++ b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java @@ -79,8 +79,7 @@ public Option[] config() { .artifactId("apache-karaf").type("zip") .version("3.0.6")).useDeployFolder(false), - mavenBundle("org.apache.aries.spifly", - "org.apache.aries.spifly.dynamic.bundle", "1.0.8"), + //mavenBundle("org.apache.aries.spifly","org.apache.aries.spifly.dynamic.bundle", "1.0.8"), mavenBundle("org.apache.jena", "jena-osgi", "3.1.0-SNAPSHOT"), mavenBundle("com.github.andrewoma.dexx", "collection", "0.6.0-SNAPSHOT"), diff --git a/apache-jena-osgi/jena-osgi/pom.xml b/apache-jena-osgi/jena-osgi/pom.xml index 6225f314c50..ebf1ba45f51 100644 --- a/apache-jena-osgi/jena-osgi/pom.xml +++ b/apache-jena-osgi/jena-osgi/pom.xml @@ -233,27 +233,29 @@ maven-bundle-plugin true - + - org.apache.jena.*,!org.apache.jena.ext.* + org.apache.jena.*,!org.apache.jena.ext.* artifactId=jena*;inline=true - true - + org.osgi.framework.*,org.apache.xml.*,org.apache.xerces.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* - + --> org.apache.jena.ext.* - org.apache.jena.osgi.Activator + + + + + + 4.0.0 + + org.apache.jena + apache-jena-osgi + 3.1.0-SNAPSHOT + + jena-osgi-features + bundle + Apache Jena - OSGi Karaf features + Apache Karaf features (deplyoment configurations) for easy installation and integration testing. + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-resources-plugin + + + copy-resources + validate + + copy-resources + + + ${basedir}/target + + + src/main/resources + true + + + + + + filter + generate-resources + + resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + + attach-artifact + + + + + target/features.xml + xml + features + + + + + + + + + diff --git a/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml b/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml new file mode 100644 index 00000000000..f32bf4313b4 --- /dev/null +++ b/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml @@ -0,0 +1,46 @@ + + + + + + + mvn:org.apache.jena/jena-osgi/3.1.0-SNAPSHOT + jena_osgi_dependencies + + + + + + mvn:com.github.andrewoma.dexx/collection/0.6 + mvn:com.github.jsonld-java/jsonld-java/0.8.2 + mvn:com.fasterxml.jackson.core/jackson-core/2.7.3 + mvn:com.fasterxml.jackson.core/jackson-databind/2.7.3 + mvn:com.fasterxml.jackson.core/jackson-annotations/2.7.3 + mvn:org.apache.httpcomponents/httpcore-osgi/4.4.4 + mvn:org.apache.httpcomponents/httpclient-osgi/4.5.2 + mvn:org.apache.commons/commons-csv/1.2 + mvn:org.apache.commons/commons-lang3/3.4 + mvn:org.apache.thrift/libthrift/0.9.3 + + + + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.11.0_1 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/1.2_5 + + + diff --git a/apache-jena-osgi/jena-osgi-test/pom.xml b/apache-jena-osgi/jena-osgi-test/pom.xml index b28d877cf5e..c8e8cf200f1 100644 --- a/apache-jena-osgi/jena-osgi-test/pom.xml +++ b/apache-jena-osgi/jena-osgi-test/pom.xml @@ -1,14 +1,20 @@ - + @@ -42,6 +48,14 @@ + + org.apache.jena + jena-osgi-features + 3.1.0-SNAPSHOT + bundle + test + + org.apache.jena jena-osgi diff --git a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java index 1d468f162f3..619d1745401 100644 --- a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java +++ b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; import java.io.OutputStream; @@ -71,30 +71,24 @@ public class JenaOSGITest { @Configuration public Option[] config() { - return options( - // OSGi container configuration + // OSGi container configuration karafDistributionConfiguration().frameworkUrl( maven().groupId("org.apache.karaf") .artifactId("apache-karaf").type("zip") + /* + * Version 4.0.4 does not work at the moment: + * Error: Could not find or load main class + * org.apache.karaf.main.Main (layout of the + * archive/file naming changed). + */ .version("3.0.6")).useDeployFolder(false), - - //mavenBundle("org.apache.aries.spifly","org.apache.aries.spifly.dynamic.bundle", "1.0.8"), - - mavenBundle("org.apache.jena", "jena-osgi", "3.1.0-SNAPSHOT"), - mavenBundle("com.github.andrewoma.dexx", "collection", "0.6.0-SNAPSHOT"), - mavenBundle("com.github.jsonld-java", "jsonld-java", "0.8.0"), - mavenBundle("org.apache.httpcomponents", "httpcore-osgi","4.4.4"), - mavenBundle("org.apache.httpcomponents", "httpclient-osgi","4.5.1"), - mavenBundle("commons-cli", "commons-cli", "1.3.1"), - mavenBundle("org.apache.commons", "commons-csv", "1.2"), - mavenBundle("org.apache.commons", "commons-lang3", "3.4"), - mavenBundle("org.apache.thrift", "libthrift", "0.9.3"), - mavenBundle("com.fasterxml.jackson.core", "jackson-core","2.6.3"), - mavenBundle("com.fasterxml.jackson.core", "jackson-databind","2.6.3"), - mavenBundle("com.fasterxml.jackson.core","jackson-annotations", "2.6.3") - - ); + // Install core Jena feature + features( + maven().groupId("org.apache.jena") + .artifactId("jena-osgi-features").type("xml") + .classifier("features") + .version("3.1.0-SNAPSHOT"), "jena")); } @@ -107,12 +101,12 @@ public Option[] config() { public void testJenaCore() throws Exception { Model model = makeModel(); Writer writer = new StringWriter(); - model.write(writer, "N-Triples"); + model.write(writer, "N-Triples"); assertEquals( " .", writer.toString().trim()); - + OntModel ontModel = ModelFactory .createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF); ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows @@ -132,15 +126,13 @@ public void testJenaArq() throws Exception { Dataset dataset = DatasetFactory.createMem(); dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel()); + // We test JSON-LD as it involves multiple other bundles Path path = Files.createTempFile("example", ".jsonld"); - // System.out.println(path); path.toFile().deleteOnExit(); try (OutputStream output = Files.newOutputStream(path)) { RDFDataMgr.write(output, dataset, Lang.JSONLD); } - // We test JSON-LD as it involves multiple other bundles - Dataset dataset2 = RDFDataMgr.loadDataset(path.toUri().toString()); assertTrue(dataset2.containsNamedModel(EXAMPLE_COM_GRAPH)); diff --git a/apache-jena-osgi/jena-osgi/pom.xml b/apache-jena-osgi/jena-osgi/pom.xml index ebf1ba45f51..b4d7ebe4f89 100644 --- a/apache-jena-osgi/jena-osgi/pom.xml +++ b/apache-jena-osgi/jena-osgi/pom.xml @@ -233,34 +233,21 @@ maven-bundle-plugin true - + - org.apache.jena.*,!org.apache.jena.ext.* + org.apache.jena.*,!org.apache.jena.ext.* artifactId=jena*;inline=true true - org.osgi.framework.*,org.apache.xml.*,org.apache.xerces.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* + org.osgi.framework.*,org.apache.xml.*,org.apache.xerces.*;version="2.11.0",!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.jena.ext.*,sun.misc;resolution:=optional,* org.apache.jena.ext.* - - - - - + org.apache.jena.osgi.Activator diff --git a/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java index 90f8016eb95..e3f721b4527 100644 --- a/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java +++ b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java @@ -1,3 +1,21 @@ +/* + * 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 org.apache.jena.osgi; import org.apache.jena.system.JenaSubsystemRegistry; @@ -6,28 +24,11 @@ import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +// Sample bundle activator explicitly calling the static Jena initialization. public class Activator implements BundleActivator { - - /* - * Based on http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java - * the Activator#start() waits for bundle extension by Aries SPI Fly, configures JenaSystem logging and requests for initialization. - */ - public void start(BundleContext context) throws Exception { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - setUpJena(); - } - }); - t.start(); - } + public void start(BundleContext context) throws Exception { - private void setUpJena() { JenaSubsystemRegistry r = new JenaSubsystemRegistryBasic() { @Override public void load() { @@ -38,7 +39,6 @@ public void load() { JenaSystem.DEBUG_INIT = true; JenaSystem.init(); System.out.println("Jena-OSGi bundle configuration done!"); - } public void stop(BundleContext context) throws Exception { diff --git a/apache-jena-osgi/pom.xml b/apache-jena-osgi/pom.xml index 9fea90b0b14..c95165d1df2 100644 --- a/apache-jena-osgi/pom.xml +++ b/apache-jena-osgi/pom.xml @@ -49,6 +49,8 @@ See JENA-913 - this breaks a clean build unless "install" is used. jena-osgi-test --> + jena-osgi-features + jena-osgi-test