use of javax.management.MBeanException in project karaf by apache.
the class BundlesMBeanImpl method getDiag.
@Override
public TabularData getDiag() throws MBeanException {
try {
CompositeType diagType = new CompositeType("Diag", "OSGi Bundle Diag", new String[] { "Name", "Status", "Diag" }, new String[] { "Bundle Name", "Current Status", "Diagnostic" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("Diagnostics", "Tables of all bundles diagnostic", diagType, new String[] { "Name" });
TabularData table = new TabularDataSupport(tableType);
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
BundleInfo bundleInfo = bundleService.getInfo(bundle);
String name = ShellUtil.getBundleName(bundle);
String status = bundleInfo.getState().toString();
String diag = bundleService.getDiag(bundle);
CompositeData data = new CompositeDataSupport(diagType, new String[] { "Name", "Status", "Diag" }, new Object[] { name, status, diag });
table.put(data);
}
return table;
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of javax.management.MBeanException in project karaf by apache.
the class BundlesMBeanImpl method getBundles.
public TabularData getBundles() throws MBeanException {
try {
CompositeType bundleType = new CompositeType("Bundle", "OSGi Bundle", new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new String[] { "ID of the Bundle", "Name of the Bundle", "Symbolic Name of the Bundle", "Version of the Bundle", "Start Level of the Bundle", "Current State of the Bundle", "Update location of the Bundle" }, new OpenType[] { SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("Bundles", "Tables of all bundles", bundleType, new String[] { "ID" });
TabularData table = new TabularDataSupport(tableType);
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
try {
BundleInfo info = bundleService.getInfo(bundle);
String bundleStateString = info.getState().toString();
CompositeData data = new CompositeDataSupport(bundleType, new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new Object[] { info.getBundleId(), info.getName(), info.getSymbolicName(), info.getVersion(), info.getStartLevel(), bundleStateString, info.getUpdateLocation() });
table.put(data);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
return table;
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of javax.management.MBeanException in project karaf by apache.
the class ObrMBeanImpl method getBundles.
public TabularData getBundles() throws MBeanException {
try {
CompositeType bundleType = new CompositeType("OBR Resource", "Bundle available in the OBR", new String[] { "presentationname", "symbolicname", "version" }, new String[] { "Presentation Name", "Symbolic Name", "Version" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("OBR Resources", "Table of all resources/bundles available in the OBR", bundleType, new String[] { "symbolicname", "version" });
TabularData table = new TabularDataSupport(tableType);
Resource[] resources = repositoryAdmin.discoverResources("(|(presentationname=*)(symbolicname=*))");
for (Resource resource : resources) {
try {
CompositeData data = new CompositeDataSupport(bundleType, new String[] { "presentationname", "symbolicname", "version" }, new Object[] { resource.getPresentationName(), resource.getSymbolicName(), resource.getVersion().toString() });
table.put(data);
} catch (Exception e) {
e.printStackTrace();
}
}
return table;
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of javax.management.MBeanException in project karaf by apache.
the class InstancesMBeanImpl method startInstance.
public void startInstance(String name, String opts, boolean wait, boolean debug) throws MBeanException {
try {
Instance child = getExistingInstance(name);
String options = opts;
if (options == null) {
options = child.getJavaOpts();
}
if (options == null) {
options = DEFAULT_OPTS;
}
if (debug) {
options += DEBUG_OPTS;
}
if (wait) {
String state = child.getState();
if (Instance.STOPPED.equals(state)) {
child.start(opts);
}
if (!Instance.STARTED.equals(state)) {
do {
Thread.sleep(500);
state = child.getState();
} while (Instance.STARTING.equals(state));
}
} else {
child.start(opts);
}
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of javax.management.MBeanException in project karaf by apache.
the class JdbcMBeanImpl method getDatasources.
@Override
public TabularData getDatasources() throws MBeanException {
try {
CompositeType type = new CompositeType("DataSource", "JDBC DataSource", new String[] { "name", "product", "version", "url", "status" }, new String[] { "Name", "Database product", "Database version", "JDBC URL", "Status" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("JDBC DataSources", "Table of the JDBC DataSources", type, new String[] { "name" });
TabularData table = new TabularDataSupport(tableType);
for (String datasource : jdbcService.datasources()) {
try {
Map<String, String> info = jdbcService.info(datasource);
CompositeData data = new CompositeDataSupport(type, new String[] { "name", "product", "version", "url", "status" }, new Object[] { datasource, info.get("db.product"), info.get("db.version"), info.get("url"), "OK" });
table.put(data);
} catch (Exception e) {
CompositeData data = new CompositeDataSupport(type, new String[] { "name", "product", "version", "url", "status" }, new Object[] { datasource, "", "", "", "ERROR" });
table.put(data);
}
}
return table;
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
Aggregations