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