use of org.apache.karaf.bundle.core.BundleInfo in project ddf by codice.
the class ServiceManagerImpl method isBundleReady.
private boolean isBundleReady(Bundle bundle) {
String name = bundle.getHeaders().get(Constants.BUNDLE_NAME);
BundleInfo info = bundleService.getInfo(bundle);
BundleState state = info.getState();
boolean ready;
if (info.isFragment()) {
ready = BundleState.Resolved.equals(state);
} else {
if (BundleState.Failure.equals(state)) {
printInactiveBundles();
LOGGER.error("The bundle {} failed.", name);
}
ready = BundleState.Active.equals(state);
}
if (!ready) {
LOGGER.debug("{} bundle not ready yet", name);
}
return ready;
}
use of org.apache.karaf.bundle.core.BundleInfo in project ddf by codice.
the class SynchronizedInstallerImpl method getUnavailableBundles.
@VisibleForTesting
BundleStates getUnavailableBundles(Set<String> toCheck) {
Set<Bundle> unavailableBundles = new HashSet<>();
Set<Bundle> failedBundles = new HashSet<>();
for (Bundle bundle : bundleContext.getBundles()) {
if (!toCheck.contains(bundle.getSymbolicName())) {
continue;
}
BundleInfo bundleInfo = bundleService.getInfo(bundle);
BundleState bundleState = bundleInfo.getState();
if (BundleState.Failure.equals(bundleState)) {
failedBundles.add(bundle);
continue;
}
if (bundleInfo.isFragment()) {
if (!BundleState.Resolved.equals(bundleState)) {
unavailableBundles.add(bundle);
}
} else if (!BundleState.Active.equals(bundleState)) {
unavailableBundles.add(bundle);
}
}
return new BundleStates(unavailableBundles, failedBundles);
}
use of org.apache.karaf.bundle.core.BundleInfo 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 org.apache.karaf.bundle.core.BundleInfo 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 org.apache.karaf.bundle.core.BundleInfo in project karaf by apache.
the class Diag method executeOnBundle.
@Override
protected void executeOnBundle(Bundle bundle) throws Exception {
BundleInfo info = bundleService.getInfo(bundle);
if (info.getState() == BundleState.Failure || info.getState() == BundleState.Waiting || info.getState() == BundleState.GracePeriod || info.getState() == BundleState.Installed) {
String title = ShellUtil.getBundleName(bundle);
System.out.println(title);
System.out.println(ShellUtil.getUnderlineString(title));
System.out.println("Status: " + info.getState().toString());
System.out.println(this.bundleService.getDiag(bundle));
System.out.println();
}
}
Aggregations