]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiBundle.java
Upload of distributions
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiBundle.java
index 45cee40e2e98eab4f996c6c6a0dda1638e930ae2..9fb09bebf588ea6fe071ac31d71b41760b87f4c6 100644 (file)
@@ -1,7 +1,8 @@
 package org.argeo.slc.osgi;
 
+import org.argeo.slc.build.BasicNameVersion;
 import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.deploy.ResourceDistribution;
+import org.argeo.slc.core.build.ResourceDistribution;
 import org.argeo.slc.deploy.DeploymentData;
 import org.argeo.slc.deploy.Module;
 import org.argeo.slc.deploy.TargetData;
@@ -9,10 +10,8 @@ import org.argeo.slc.process.RealizedFlow;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 
-public class OsgiBundle implements Module<ResourceDistribution> {
-       private String name;
-       private String version;
-       private Distribution distribution;
+public class OsgiBundle extends BasicNameVersion implements Module {
+       private ResourceDistribution distribution;
 
        private Long internalBundleId;
 
@@ -20,19 +19,29 @@ public class OsgiBundle implements Module<ResourceDistribution> {
 
        }
 
+       public OsgiBundle(String name, String version) {
+               super(name, version);
+       }
+
        public OsgiBundle(Bundle bundle) {
-               name = bundle.getSymbolicName();
-               version = bundle.getHeaders().get(Constants.BUNDLE_VERSION).toString();
+               super(bundle.getSymbolicName(), getVersionSafe(bundle));
                internalBundleId = bundle.getBundleId();
        }
 
+       private static String getVersionSafe(Bundle bundle) {
+               Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+               if (versionObj != null)
+                       return versionObj.toString();
+               else
+                       return null;
+       }
+
        public OsgiBundle(RealizedFlow realizedFlow) {
-               name = realizedFlow.getModuleName();
-               version = realizedFlow.getModuleVersion();
+               super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
        }
 
        public String getDeployedSystemId() {
-               return name + ":" + version;
+               return getName() + ":" + getVersion();
        }
 
        public DeploymentData getDeploymentData() {
@@ -43,27 +52,15 @@ public class OsgiBundle implements Module<ResourceDistribution> {
                return distribution;
        }
 
-       public TargetData getTargetData() {
-               throw new UnsupportedOperationException();
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public void setName(String name) {
-               this.name = name;
+       public ResourceDistribution getResourceDistribution() {
+               return distribution;
        }
 
-       public void setVersion(String version) {
-               this.version = version;
+       public TargetData getTargetData() {
+               throw new UnsupportedOperationException();
        }
 
-       public void setDistribution(Distribution distribution) {
+       public void setResourceDistribution(ResourceDistribution distribution) {
                this.distribution = distribution;
        }