1 package org
.argeo
.security
.core
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.osgi
.framework
.Bundle
;
6 import org
.osgi
.framework
.BundleContext
;
7 import org
.osgi
.framework
.Constants
;
10 * Logs the name and version of an OSGi bundle based on its
11 * {@link BundleContext}.
13 public class OsgiModuleLabel
{
14 private final static Log log
= LogFactory
.getLog(OsgiModuleLabel
.class);
16 private Bundle bundle
;
18 public OsgiModuleLabel() {
21 /** Sets without logging. */
22 public OsgiModuleLabel(Bundle bundle
) {
27 * Retrieved bundle from a bundle context and logs it. Typically to be set
30 public void setBundleContext(BundleContext bundleContext
) {
31 this.bundle
= bundleContext
.getBundle();
36 String name
= bundle
.getHeaders().get(Constants
.BUNDLE_NAME
).toString();
37 String symbolicName
= bundle
.getSymbolicName();
38 String version
= bundle
.getVersion().toString();
39 return name
+ " v" + version
+ " (" + symbolicName
+ ")";