Hello,
In Karaf 4.0.4, I have my own bundles deployed using spring-dm. I would be
interested if there is a possibility to get the status of a bundle via JMX
as it is listed in karaf console.
In karaf, I get this:
karaf@root> list
285 | Active | 80 | 1.0.0.SNAPSHOT | bundle-name
>From my Java routine, I try to get the status via:
BundlesMBean mbeanProxy = JMX.newMBeanProxy(mbeanServer, bundlesObjName,
BundlesMBean.class, true);
TabularData tabularData = mbeanProxy.getBundles();
for (Object k : tabularData.keySet()) {
// key from tabularData is a java.util.List
Object[] key = ((List<?>) k).toArray();
// CompositeData is a java.util.Map that hold properties
// of a JMX entity
CompositeData bundle = tabularData.get(key);
String nameAttr = (String) bundle.get(BUNDLE_NAME_ATTR);
String versionAttr = (String) bundle.get(BUNDLE_VERSION_ATTR);
// checks if interested bundle
if ( (nameAttr != null && nameAttr.equals("bundle-name"))
&& (versionAttr != null && versionAttr.equals("1.0.0.SNAPSHOT"))
{
// return bundle status taken as it is as java.lang.String
// in karaf.
return (String) bundle.get(BUNDLE_STATE_ATTR);
}
}
The problem is that I always get null. Why this? and how can I make it so
that I get the Spring status?
Thanks,
Andrei