1 package org
.argeo
.slc
.osgi
;
3 import java
.util
.ArrayList
;
7 import org
.argeo
.slc
.UnsupportedException
;
8 import org
.argeo
.slc
.build
.Distribution
;
9 import org
.argeo
.slc
.core
.deploy
.ResourceDistribution
;
10 import org
.argeo
.slc
.deploy
.DeploymentData
;
11 import org
.argeo
.slc
.deploy
.ModularDeployedSystem
;
12 import org
.argeo
.slc
.deploy
.TargetData
;
13 import org
.osgi
.framework
.Bundle
;
14 import org
.osgi
.framework
.BundleContext
;
15 import org
.springframework
.context
.ResourceLoaderAware
;
16 import org
.springframework
.core
.io
.Resource
;
17 import org
.springframework
.core
.io
.ResourceLoader
;
18 import org
.springframework
.osgi
.context
.BundleContextAware
;
20 public class OsgiRuntime
implements ModularDeployedSystem
<OsgiBundle
>,
21 BundleContextAware
, ResourceLoaderAware
{
22 private String uuid
= UUID
.randomUUID().toString();
23 private BundleContext bundleContext
;
24 private ResourceLoader resourceLoader
;
26 public List
<OsgiBundle
> listModules() {
27 List
<OsgiBundle
> modules
= new ArrayList
<OsgiBundle
>();
28 Bundle
[] bundles
= bundleContext
.getBundles();
29 for (Bundle bundle
: bundles
) {
30 OsgiBundle osgiBundle
= new OsgiBundle(bundle
);
31 modules
.add(osgiBundle
);
32 String location
= bundle
.getLocation();
33 if (location
!= null) {
34 Resource resource
= resourceLoader
.getResource(location
);
35 osgiBundle
.setDistribution(new ResourceDistribution(resource
));
41 public String
getDeployedSystemId() {
45 public DeploymentData
getDeploymentData() {
46 throw new UnsupportedException();
49 public Distribution
getDistribution() {
50 throw new UnsupportedException();
53 public TargetData
getTargetData() {
54 throw new UnsupportedException();
57 public void setBundleContext(BundleContext bundleContext
) {
58 this.bundleContext
= bundleContext
;
61 public void setResourceLoader(ResourceLoader resourceLoader
) {
62 this.resourceLoader
= resourceLoader
;