]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiBundle.java
Improve log
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiBundle.java
1 package org.argeo.slc.osgi;
2
3 import org.argeo.slc.build.BasicNameVersion;
4 import org.argeo.slc.build.Distribution;
5 import org.argeo.slc.core.build.ResourceDistribution;
6 import org.argeo.slc.deploy.DeploymentData;
7 import org.argeo.slc.deploy.Module;
8 import org.argeo.slc.deploy.TargetData;
9 import org.argeo.slc.process.RealizedFlow;
10 import org.osgi.framework.Bundle;
11 import org.osgi.framework.Constants;
12
13 public class OsgiBundle extends BasicNameVersion implements Module {
14 private ResourceDistribution distribution;
15
16 private Long internalBundleId;
17
18 public OsgiBundle() {
19
20 }
21
22 public OsgiBundle(String name, String version) {
23 super(name, version);
24 }
25
26 public OsgiBundle(Bundle bundle) {
27 super(bundle.getSymbolicName(), getVersionSafe(bundle));
28 internalBundleId = bundle.getBundleId();
29 }
30
31 private static String getVersionSafe(Bundle bundle) {
32 Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
33 if (versionObj != null)
34 return versionObj.toString();
35 else
36 return null;
37 }
38
39 public OsgiBundle(RealizedFlow realizedFlow) {
40 super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
41 }
42
43 public String getDeployedSystemId() {
44 return getName() + ":" + getVersion();
45 }
46
47 public DeploymentData getDeploymentData() {
48 throw new UnsupportedOperationException();
49 }
50
51 public Distribution getDistribution() {
52 return distribution;
53 }
54
55 public ResourceDistribution getResourceDistribution() {
56 return distribution;
57 }
58
59 public TargetData getTargetData() {
60 throw new UnsupportedOperationException();
61 }
62
63 public void setResourceDistribution(ResourceDistribution distribution) {
64 this.distribution = distribution;
65 }
66
67 /**
68 * To be used for optimization when looking in the bundle context. Can
69 * therefore be null.
70 */
71 public Long getInternalBundleId() {
72 return internalBundleId;
73 }
74
75 /** Only package access for the time being. e.g. from {@link BundlesManager} */
76 void setInternalBundleId(Long internalBundleId) {
77 this.internalBundleId = internalBundleId;
78 }
79
80 }