]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java
MOve project to PDE
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / build / OsgiRuntimeModularDistribution.java
index 7f3b49a381867914c9b35b0f2b3bbab2b789d7a4..cb6353c35de812b8a9a2810737c818390dcf80b5 100644 (file)
@@ -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,14 +26,32 @@ public class OsgiRuntimeModularDistribution extends
                        SortedMap<NameVersion, Distribution> 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 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());