]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiBundle.java
resolution of Bug 242: ExecutionFlowGenerator implements Ordered instead of PriorityO...
[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.build.NameVersion;
6 import org.argeo.slc.core.build.ResourceDistribution;
7 import org.argeo.slc.deploy.DeploymentData;
8 import org.argeo.slc.deploy.Module;
9 import org.argeo.slc.deploy.TargetData;
10 import org.argeo.slc.process.RealizedFlow;
11 import org.osgi.framework.Bundle;
12 import org.osgi.framework.Constants;
13
14 public class OsgiBundle extends BasicNameVersion implements Module {
15 private ResourceDistribution distribution;
16
17 private Long internalBundleId;
18
19 private String label;
20 private String description;
21
22 public OsgiBundle() {
23
24 }
25
26 public OsgiBundle(String name, String version) {
27 super(name, version);
28 }
29
30 public OsgiBundle(NameVersion nameVersion) {
31 super(nameVersion);
32 }
33
34 public OsgiBundle(Bundle bundle) {
35 super(bundle.getSymbolicName(), getVersionSafe(bundle));
36 internalBundleId = bundle.getBundleId();
37 }
38
39 private static String getVersionSafe(Bundle bundle) {
40 Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
41 if (versionObj != null)
42 return versionObj.toString();
43 else
44 return null;
45 }
46
47 public OsgiBundle(RealizedFlow realizedFlow) {
48 super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
49 }
50
51 public String getDeployedSystemId() {
52 return getName() + ":" + getVersion();
53 }
54
55 public DeploymentData getDeploymentData() {
56 throw new UnsupportedOperationException();
57 }
58
59 public Distribution getDistribution() {
60 return distribution;
61 }
62
63 public ResourceDistribution getResourceDistribution() {
64 return distribution;
65 }
66
67 public TargetData getTargetData() {
68 throw new UnsupportedOperationException();
69 }
70
71 public void setResourceDistribution(ResourceDistribution distribution) {
72 this.distribution = distribution;
73 }
74
75 /**
76 * To be used for optimization when looking in the bundle context. Can
77 * therefore be null.
78 */
79 public Long getInternalBundleId() {
80 return internalBundleId;
81 }
82
83 /** Only package access for the time being. e.g. from {@link BundlesManager} */
84 void setInternalBundleId(Long internalBundleId) {
85 this.internalBundleId = internalBundleId;
86 }
87
88 public String getLabel() {
89 return label;
90 }
91
92 public void setLabel(String label) {
93 this.label = label;
94 }
95
96 public String getDescription() {
97 return description;
98 }
99
100 public void setDescription(String description) {
101 this.description = description;
102 }
103
104 }