X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.support.equinox%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2FOsgiRuntime.java;h=bd6c63034a8ca28395b4eb2d7c0ef434149d11e4;hb=c013d066971b9ac23b7b488bd1cc6193c83b6227;hp=364854605ae47181cf36fd639325bad2ab3bc439;hpb=e7ddf0b3a271a2f22108ee5b9fba69888f5c78ec;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java index 364854605..bd6c63034 100644 --- a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java +++ b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiRuntime.java @@ -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, + BundleContextAware, ResourceLoaderAware { + private String uuid = UUID.randomUUID().toString(); + private BundleContext bundleContext; + private ResourceLoader resourceLoader; - public List listModules() { - // TODO Auto-generated method stub - return null; + public List listModules() { + List modules = new ArrayList(); + 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; } }