1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.osgi;
17
18 import org.argeo.slc.DefaultNameVersion;
19 import org.argeo.slc.NameVersion;
20 import org.argeo.slc.build.Distribution;
21 import org.argeo.slc.core.build.ResourceDistribution;
22 import org.argeo.slc.deploy.DeploymentData;
23 import org.argeo.slc.deploy.Module;
24 import org.argeo.slc.deploy.ModuleDescriptor;
25 import org.argeo.slc.deploy.TargetData;
26 import org.argeo.slc.execution.RealizedFlow;
27 import org.osgi.framework.Bundle;
28 import org.osgi.framework.Constants;
29 import org.springframework.core.io.Resource;
30
31
32 public class OsgiBundle extends DefaultNameVersion implements Module {
33 private ResourceDistribution distribution;
34
35 private Long internalBundleId;
36
37 private String title;
38 private String description;
39
40 public OsgiBundle() {
41
42 }
43
44 public OsgiBundle(String name, String version) {
45 super(name, version);
46 }
47
48 public OsgiBundle(NameVersion nameVersion) {
49 super(nameVersion);
50 }
51
52 public OsgiBundle(Bundle bundle) {
53 super(bundle.getSymbolicName(), getVersionSafe(bundle));
54 internalBundleId = bundle.getBundleId();
55 }
56
57
58
59
60
61
62
63 public OsgiBundle(RealizedFlow realizedFlow) {
64 super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
65 }
66
67
68 private static String getVersionSafe(Bundle bundle) {
69 Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
70 if (versionObj != null)
71 return versionObj.toString();
72 else
73 return null;
74 }
75
76
77 public String getDeployedSystemId() {
78 return getName() + ":" + getVersion();
79 }
80
81
82
83
84
85
86
87 public DeploymentData getDeploymentData() {
88 return null;
89 }
90
91
92 public Distribution getDistribution() {
93 return distribution;
94 }
95
96
97
98
99
100 public ResourceDistribution getResourceDistribution() {
101 return distribution;
102 }
103
104
105 public TargetData getTargetData() {
106 throw new UnsupportedOperationException();
107 }
108
109 public void setResourceDistribution(ResourceDistribution distribution) {
110 this.distribution = distribution;
111 }
112
113
114
115
116
117 public Long getInternalBundleId() {
118 return internalBundleId;
119 }
120
121
122 void setInternalBundleId(Long internalBundleId) {
123 this.internalBundleId = internalBundleId;
124 }
125
126
127 public String getTitle() {
128 return title;
129 }
130
131 public void setTitle(String label) {
132 this.title = label;
133 }
134
135
136 public String getDescription() {
137 return description;
138 }
139
140 public void setDescription(String description) {
141 this.description = description;
142 }
143
144 public ModuleDescriptor getModuleDescriptor() {
145 ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
146 moduleDescriptor.setName(getName());
147 moduleDescriptor.setVersion(getVersion());
148 moduleDescriptor.setDescription(description);
149 moduleDescriptor.setTitle(title);
150 return moduleDescriptor;
151 }
152 }