2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.osgi
;
19 import org
.argeo
.slc
.build
.BasicNameVersion
;
20 import org
.argeo
.slc
.build
.Distribution
;
21 import org
.argeo
.slc
.build
.NameVersion
;
22 import org
.argeo
.slc
.core
.build
.ResourceDistribution
;
23 import org
.argeo
.slc
.deploy
.DeploymentData
;
24 import org
.argeo
.slc
.deploy
.Module
;
25 import org
.argeo
.slc
.deploy
.TargetData
;
26 import org
.argeo
.slc
.process
.RealizedFlow
;
27 import org
.osgi
.framework
.Bundle
;
28 import org
.osgi
.framework
.Constants
;
30 public class OsgiBundle
extends BasicNameVersion
implements Module
{
31 private ResourceDistribution distribution
;
33 private Long internalBundleId
;
36 private String description
;
42 public OsgiBundle(String name
, String version
) {
46 public OsgiBundle(NameVersion nameVersion
) {
50 public OsgiBundle(Bundle bundle
) {
51 super(bundle
.getSymbolicName(), getVersionSafe(bundle
));
52 internalBundleId
= bundle
.getBundleId();
55 private static String
getVersionSafe(Bundle bundle
) {
56 Object versionObj
= bundle
.getHeaders().get(Constants
.BUNDLE_VERSION
);
57 if (versionObj
!= null)
58 return versionObj
.toString();
63 public OsgiBundle(RealizedFlow realizedFlow
) {
64 super(realizedFlow
.getModuleName(), realizedFlow
.getModuleVersion());
67 public String
getDeployedSystemId() {
68 return getName() + ":" + getVersion();
71 public DeploymentData
getDeploymentData() {
72 throw new UnsupportedOperationException();
75 public Distribution
getDistribution() {
79 public ResourceDistribution
getResourceDistribution() {
83 public TargetData
getTargetData() {
84 throw new UnsupportedOperationException();
87 public void setResourceDistribution(ResourceDistribution distribution
) {
88 this.distribution
= distribution
;
92 * To be used for optimization when looking in the bundle context. Can
95 public Long
getInternalBundleId() {
96 return internalBundleId
;
99 /** Only package access for the time being. e.g. from {@link BundlesManager} */
100 void setInternalBundleId(Long internalBundleId
) {
101 this.internalBundleId
= internalBundleId
;
104 public String
getLabel() {
108 public void setLabel(String label
) {
112 public String
getDescription() {
116 public void setDescription(String description
) {
117 this.description
= description
;