use of org.mule.runtime.core.api.context.notification.MuleContextNotification in project mule by mulesoft.
the class DefaultMuleApplication method setMuleContext.
private void setMuleContext(final MuleContext muleContext, Registry registry) {
statusListener = new MuleContextNotificationListener<MuleContextNotification>() {
@Override
public boolean isBlocking() {
return false;
}
@Override
public void onNotification(MuleContextNotification notification) {
Action action = notification.getAction();
if (new IntegerAction(CONTEXT_INITIALISED).equals(action) || new IntegerAction(CONTEXT_STARTED).equals(action) || new IntegerAction(CONTEXT_STOPPED).equals(action) || new IntegerAction(CONTEXT_DISPOSED).equals(action)) {
updateStatusFor(muleContext.getLifecycleManager().getCurrentPhase());
}
}
};
notificationRegistrer = registry.lookupByType(NotificationListenerRegistry.class).get();
notificationRegistrer.registerListener(statusListener);
}
use of org.mule.runtime.core.api.context.notification.MuleContextNotification in project mule by mulesoft.
the class DefaultMuleApplicationStatusTestCase method initialised.
@Test
public void initialised() {
// the context was initialised before we gave it to the application, so we need
// to fire the notification again since the listener wasn't there
notificationDispatcher.dispatch(new MuleContextNotification(muleContext, CONTEXT_INITIALISED));
assertStatus(ApplicationStatus.INITIALISED);
}
use of org.mule.runtime.core.api.context.notification.MuleContextNotification in project mule by mulesoft.
the class MuleContextLifecycleTestCase method notificationHasMuleContextRef.
@Test
public void notificationHasMuleContextRef() throws Exception {
ctx.initialise();
new DefaultsConfigurationBuilder().configure(ctx);
final AtomicReference<MuleContext> contextFromNotification = new AtomicReference<>();
final AtomicReference<String> resourceId = new AtomicReference<>();
MuleContextNotificationListener<MuleContextNotification> listener = notification -> {
contextFromNotification.set(notification.getMuleContext());
resourceId.set(notification.getResourceIdentifier());
};
notificationListenerRegistry.registerListener(listener);
ctx.start();
assertNotNull(contextFromNotification.get());
assertSame(ctx, contextFromNotification.get());
assertEquals(ctx.getConfiguration().getId(), resourceId.get());
}
Aggregations