use of org.apache.karaf.bundle.core.BundleState in project karaf by apache.
the class SpringStateService method getState.
public BundleState getState(Bundle bundle) {
OsgiBundleApplicationContextEvent event = states.get(bundle.getBundleId());
BundleState state = mapEventToState(event);
return (bundle.getState() != Bundle.ACTIVE) ? BundleState.Unknown : state;
}
use of org.apache.karaf.bundle.core.BundleState in project karaf by apache.
the class SpringStateService method onOsgiApplicationEvent.
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
if (LOG.isDebugEnabled()) {
BundleState state = mapEventToState(event);
LOG.debug("Spring app state changed to " + state + " for bundle " + event.getBundle().getBundleId());
}
states.put(event.getBundle().getBundleId(), event);
}
use of org.apache.karaf.bundle.core.BundleState in project karaf by apache.
the class BlueprintStateService method blueprintEvent.
@Override
public void blueprintEvent(BlueprintEvent blueprintEvent) {
if (LOG.isDebugEnabled()) {
BundleState state = getState(blueprintEvent);
LOG.debug("Blueprint app state changed to " + state + " for bundle " + blueprintEvent.getBundle().getBundleId());
}
states.put(blueprintEvent.getBundle().getBundleId(), blueprintEvent);
}
use of org.apache.karaf.bundle.core.BundleState in project karaf by apache.
the class BlueprintStateService method getState.
@Override
public BundleState getState(Bundle bundle) {
BlueprintEvent event = states.get(bundle.getBundleId());
BundleState state = getState(event);
return (bundle.getState() != Bundle.ACTIVE) ? BundleState.Unknown : state;
}
use of org.apache.karaf.bundle.core.BundleState in project karaf by apache.
the class JavaSecurityTest method testJavaSecurity.
@Test
public void testJavaSecurity() throws Exception {
assertNotNull("Karaf should run under a security manager", System.getSecurityManager());
BundleService service = getOsgiService(BundleService.class);
long tried = 0;
while (true) {
Map<Bundle, BundleState> incorrect = new HashMap<>();
for (Bundle bundle : bundleContext.getBundles()) {
BundleInfo info = service.getInfo(bundle);
BundleState state = info.getState();
if (state != BundleState.Active && state != BundleState.Resolved) {
incorrect.put(bundle, state);
}
}
if (incorrect.isEmpty()) {
break;
} else {
if (++tried >= 10) {
fail("Unable to start bundles correctly: " + incorrect);
}
Thread.sleep(100);
}
}
}
Aggregations