X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.osgi%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2Fbuild%2FOsgiRuntimeModularDistribution.java;h=cb6353c35de812b8a9a2810737c818390dcf80b5;hb=3779f02dcb5f24beee8fc08b5f5876af446dab41;hp=1c68cf5c356917a33a30109e8d6231d56f99e80f;hpb=af874b12bcb864e1ee2b48e8d6e1fea3a584c53d;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java index 1c68cf5c3..cb6353c35 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java @@ -13,6 +13,7 @@ import org.osgi.framework.Bundle; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; +import org.springframework.osgi.util.OsgiBundleUtils; public class OsgiRuntimeModularDistribution extends AbstractOsgiModularDistribution implements ResourceLoaderAware { @@ -25,17 +26,41 @@ public class OsgiRuntimeModularDistribution extends SortedMap distributions) throws Exception { - for (Bundle bundle : getBundleContext().getBundles()) { + String frameworkUrl = System.getProperty("osgi.framework"); + String frameworkBaseUrl = null; + if (frameworkUrl != null) + frameworkBaseUrl = frameworkUrl.substring(0, frameworkUrl + .lastIndexOf('/')); + bundles: for (Bundle bundle : getBundleContext().getBundles()) { OsgiBundle osgiBundle = new OsgiBundle(bundle); - String location = bundle.getLocation(); - if (location.startsWith("reference:file:")) - location = location.substring("reference:".length()); + String originalLocation = bundle.getLocation(); + + if (OsgiBundleUtils.isSystemBundle(bundle)) { + continue bundles; + } + + String location = originalLocation; + if (originalLocation.startsWith("reference:file:")) + location = originalLocation.substring("reference:".length()); + + if (frameworkBaseUrl != null + && originalLocation.startsWith("initial@reference:file:")) { + location = frameworkBaseUrl + + '/' + + originalLocation.substring("initial@reference:file:" + .length()); + } + try { URL url = new URL(location); Resource res = resourceLoader.getResource(url.toString()); distributions.put(osgiBundle, new VersionedResourceDistribution(osgiBundle, res)); + + if (log.isTraceEnabled()) + log.debug("Added url " + url + " from original location " + + originalLocation); } catch (Exception e) { log.warn("Cannot interpret location " + location + " of bundle " + bundle + ": " + e);