]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiModuleLabel.java
Remove modules manager from process builder page
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / deploy / OsgiModuleLabel.java
1 package org.argeo.slc.osgi.deploy;
2
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;
8
9 /** Logs the version of an OSGi bundle. */
10 public class OsgiModuleLabel {
11 private final static Log log = LogFactory.getLog(OsgiModuleLabel.class);
12
13 private Bundle bundle;
14
15 public OsgiModuleLabel() {
16 }
17
18 /** Sets without logging. */
19 public OsgiModuleLabel(Bundle bundle) {
20 this.bundle = bundle;
21 }
22
23 /**
24 * Retrieved bundle from a bundle context and logs it. Typically to be set
25 * as a Spring bean.
26 */
27 public void setBundleContext(BundleContext bundleContext) {
28 this.bundle = bundleContext.getBundle();
29 log.info(msg());
30 }
31
32 public String msg() {
33 String name = bundle.getHeaders().get(Constants.BUNDLE_NAME).toString();
34 String symbolicName = bundle.getSymbolicName();
35 String version = bundle.getVersion().toString();
36 return name + " v" + version + " (" + symbolicName + ")";
37 }
38 }