]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java
Reduce debug verbosity
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiRuntime.java
1 package org.argeo.slc.osgi;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.UUID;
6
7 import org.argeo.slc.UnsupportedException;
8 import org.argeo.slc.build.Distribution;
9 import org.argeo.slc.core.build.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;
19
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;
25
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));
36 }
37 }
38 return modules;
39 }
40
41 public String getDeployedSystemId() {
42 return uuid;
43 }
44
45 public DeploymentData getDeploymentData() {
46 throw new UnsupportedException();
47 }
48
49 public Distribution getDistribution() {
50 throw new UnsupportedException();
51 }
52
53 public TargetData getTargetData() {
54 throw new UnsupportedException();
55 }
56
57 public void setBundleContext(BundleContext bundleContext) {
58 this.bundleContext = bundleContext;
59 }
60
61 public void setResourceLoader(ResourceLoader resourceLoader) {
62 this.resourceLoader = resourceLoader;
63 }
64
65 }