]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java
Remote shutdown
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.equinox / src / main / java / org / argeo / slc / osgi / OsgiRuntime.java
index 364854605ae47181cf36fd639325bad2ab3bc439..bd6c63034a8ca28395b4eb2d7c0ef434149d11e4 100644 (file)
@@ -1,38 +1,65 @@
 package org.argeo.slc.osgi;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
+import org.argeo.slc.UnsupportedException;
 import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.core.deploy.ResourceDistribution;
 import org.argeo.slc.deploy.DeploymentData;
 import org.argeo.slc.deploy.ModularDeployedSystem;
 import org.argeo.slc.deploy.TargetData;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.osgi.context.BundleContextAware;
 
-public class OsgiRuntime implements ModularDeployedSystem {
+public class OsgiRuntime implements ModularDeployedSystem<OsgiBundle>,
+               BundleContextAware, ResourceLoaderAware {
+       private String uuid = UUID.randomUUID().toString();
+       private BundleContext bundleContext;
+       private ResourceLoader resourceLoader;
 
-       public List<DeployedSystem> listModules() {
-               // TODO Auto-generated method stub
-               return null;
+       public List<OsgiBundle> listModules() {
+               List<OsgiBundle> modules = new ArrayList<OsgiBundle>();
+               Bundle[] bundles = bundleContext.getBundles();
+               for (Bundle bundle : bundles) {
+                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
+                       modules.add(osgiBundle);
+                       String location = bundle.getLocation();
+                       if (location != null) {
+                               Resource resource = resourceLoader.getResource(location);
+                               osgiBundle.setDistribution(new ResourceDistribution(resource));
+                       }
+               }
+               return modules;
        }
 
        public String getDeployedSystemId() {
-               // TODO Auto-generated method stub
-               return null;
+               return uuid;
        }
 
        public DeploymentData getDeploymentData() {
-               // TODO Auto-generated method stub
-               return null;
+               throw new UnsupportedException();
        }
 
        public Distribution getDistribution() {
-               // TODO Auto-generated method stub
-               return null;
+               throw new UnsupportedException();
        }
 
        public TargetData getTargetData() {
-               // TODO Auto-generated method stub
-               return null;
+               throw new UnsupportedException();
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       public void setResourceLoader(ResourceLoader resourceLoader) {
+               this.resourceLoader = resourceLoader;
        }
 
 }