Github user jpullmann commented on a diff in the pull request:
https://github.com/apache/jena/pull/134#discussion_r58884548
--- Diff:
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();
+ }
+ };
--- End diff --
I did not consider changing Jena initialisation, but this exactly hits the
point. Now, with
JenaSubsystemRegistryBasic adapted:
```
@Override
public void load() {
synchronized (registryLock) {
// Find subsystems asking for initialization.
ServiceLoader<JenaSubsystemLifecycle> sl =
ServiceLoader.load(JenaSubsystemLifecycle.class,this.getClass().getClassLoader())
;
sl.forEach(this::add) ;
}
}
```
the bundle's own class loader is used for SPI resloution. Great, it works
out of the box!
I removed Aries SPI Fly dependency and headers from jena-osgi - they are
not needed any more.
The only remaining issue is embedding xerces. This is not recommended and
yields to an error in the test runtime Apache Karaf 3.0.6 (with xerces exposed
to all bundles via boot classloader):
```
org.apache.xerces.impl.dv.DVFactoryException: Schema factory class
org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl does not extend from
SchemaDVFactory.
at org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(Unknown
Source)
```
Suggestion: use "Import-Package" directive to share available
org.apache.xerces.* packages.
I updated jena-osgi/pom.xml accordingly.
The integration test is rather rough and definitely needs elaboration (will
do next week).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---