1 package org
.argeo
.slc
.osgi
.build
;
4 import java
.util
.SortedMap
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.argeo
.slc
.build
.Distribution
;
9 import org
.argeo
.slc
.build
.NameVersion
;
10 import org
.argeo
.slc
.core
.build
.VersionedResourceDistribution
;
11 import org
.argeo
.slc
.osgi
.OsgiBundle
;
12 import org
.osgi
.framework
.Bundle
;
13 import org
.springframework
.context
.ResourceLoaderAware
;
14 import org
.springframework
.core
.io
.Resource
;
15 import org
.springframework
.core
.io
.ResourceLoader
;
17 public class OsgiRuntimeModularDistribution
extends
18 AbstractOsgiModularDistribution
implements ResourceLoaderAware
{
19 private final static Log log
= LogFactory
20 .getLog(OsgiRuntimeModularDistribution
.class);
22 private ResourceLoader resourceLoader
;
24 protected void fillDistributions(
25 SortedMap
<NameVersion
, Distribution
> distributions
)
28 for (Bundle bundle
: getBundleContext().getBundles()) {
29 OsgiBundle osgiBundle
= new OsgiBundle(bundle
);
31 String location
= bundle
.getLocation();
32 if (location
.startsWith("reference:file:"))
33 location
= location
.substring("reference:".length());
35 URL url
= new URL(location
);
36 Resource res
= resourceLoader
.getResource(url
.toString());
37 distributions
.put(osgiBundle
,
38 new VersionedResourceDistribution(osgiBundle
, res
));
39 } catch (Exception e
) {
40 log
.warn("Cannot interpret location " + location
41 + " of bundle " + bundle
+ ": " + e
);
46 public void setResourceLoader(ResourceLoader resourceLoader
) {
47 this.resourceLoader
= resourceLoader
;