]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiBundle.java
ff90b95b78e122a99037a13a0ed589e18d097e31
[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.Distribution;
4 import org.argeo.slc.core.build.ResourceDistribution;
5 import org.argeo.slc.deploy.DeploymentData;
6 import org.argeo.slc.deploy.Module;
7 import org.argeo.slc.deploy.TargetData;
8 import org.argeo.slc.process.RealizedFlow;
9 import org.osgi.framework.Bundle;
10 import org.osgi.framework.Constants;
11
12 public class OsgiBundle implements Module<ResourceDistribution> {
13 private String name;
14 private String version;
15 private Distribution distribution;
16
17 private Long internalBundleId;
18
19 public OsgiBundle() {
20
21 }
22
23 public OsgiBundle(Bundle bundle) {
24 name = bundle.getSymbolicName();
25 version = bundle.getHeaders().get(Constants.BUNDLE_VERSION).toString();
26 internalBundleId = bundle.getBundleId();
27 }
28
29 public OsgiBundle(RealizedFlow realizedFlow) {
30 name = realizedFlow.getModuleName();
31 version = realizedFlow.getModuleVersion();
32 }
33
34 public String getDeployedSystemId() {
35 return name + ":" + version;
36 }
37
38 public DeploymentData getDeploymentData() {
39 throw new UnsupportedOperationException();
40 }
41
42 public Distribution getDistribution() {
43 return distribution;
44 }
45
46 public TargetData getTargetData() {
47 throw new UnsupportedOperationException();
48 }
49
50 public String getName() {
51 return name;
52 }
53
54 public String getVersion() {
55 return version;
56 }
57
58 public void setName(String name) {
59 this.name = name;
60 }
61
62 public void setVersion(String version) {
63 this.version = version;
64 }
65
66 public void setDistribution(Distribution 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 }