Beispiel #1
0
 /**
  * Fires a server notification to all registered {@link
  * org.mule.api.context.notification.listener.CustomNotificationListener} notificationManager.
  *
  * @param notification the notification to fire. This must be of type {@link
  *     org.mule.context.notification.CustomNotification} otherwise an exception will be thrown.
  * @throws UnsupportedOperationException if the notification fired is not a {@link
  *     org.mule.context.notification.CustomNotification}
  */
 public void fireNotification(ServerNotification notification) {
   ServerNotificationManager notificationManager = getNotificationManager();
   if (notificationManager != null) {
     notificationManager.fireNotification(notification);
   } else if (logger.isDebugEnabled()) {
     logger.debug("MuleEvent Manager is not enabled, ignoring notification: " + notification);
   }
 }
Beispiel #2
0
 public void registerListener(ServerNotificationListener l, String resourceIdentifier)
     throws NotificationException {
   ServerNotificationManager notificationManager = getNotificationManager();
   if (notificationManager == null) {
     throw new MuleRuntimeException(CoreMessages.serverNotificationManagerNotEnabled());
   }
   notificationManager.addListenerSubscription(l, resourceIdentifier);
 }
 protected final void registerNotificationType(
     final ServerNotificationManager notificationManager,
     @SuppressWarnings("rawtypes") final Class<? extends ServerNotificationListener> listenerType,
     final Class<? extends ServerNotification> notificationType) {
   @SuppressWarnings("rawtypes")
   final Map<Class<? extends ServerNotificationListener>, Set<Class<? extends ServerNotification>>>
       mapping = notificationManager.getInterfaceToTypes();
   if (!mapping.containsKey(listenerType)) {
     notificationManager.addInterfaceToType(listenerType, notificationType);
   }
 }
  @Override
  protected void configureMuleContext(MuleContextBuilder builder) {
    super.configureMuleContext(builder);

    // Configure EndpointMessageNotificationListener for notifications test
    ServerNotificationManager notificationManager = new ServerNotificationManager();
    notificationManager.addInterfaceToType(
        EndpointMessageNotificationListener.class, EndpointMessageNotification.class);
    notificationManager.addInterfaceToType(
        SecurityNotificationListener.class, SecurityNotification.class);

    builder.setNotificationManager(notificationManager);
  }
  public MessageProcessorNotificationListener<MessageProcessorNotification>
      registerForApplicationNotifications(MuleContext context) {
    try {
      final ServerNotificationManager notificationManager = context.getNotificationManager();
      if (!notificationManager.isNotificationDynamic()) {
        notificationManager.setNotificationDynamic(true);
      }
      registerNotificationType(
          notificationManager,
          MuleMessageDebuggerListener.class,
          MessageProcessorNotification.class);

      final MuleMessageDebuggerListener muleMessageDebuggerListener =
          new MuleMessageDebuggerListener(context);
      context.registerListener(muleMessageDebuggerListener);
      return muleMessageDebuggerListener;
    } catch (NotificationException e) {
      e.printStackTrace();
    }
    return null;
  }
Beispiel #6
0
  public synchronized void dispose() {
    if (isDisposed()) {
      return;
    }

    ServerNotificationManager notificationManager = getNotificationManager();
    lifecycleManager.checkPhase(Disposable.PHASE_NAME);
    fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_DISPOSING));

    try {
      if (isStarted()) {
        stop();
      }
    } catch (MuleException e) {
      logger.error("Failed to stop manager: " + e.getMessage(), e);
    }

    try {
      lifecycleManager.firePhase(this, Disposable.PHASE_NAME);
      // Dispose internal registries
      registryBroker.dispose();
    } catch (Exception e) {
      logger.debug("Failed to cleanly dispose Mule: " + e.getMessage(), e);
    }

    notificationManager.fireNotification(
        new MuleContextNotification(this, MuleContextNotification.CONTEXT_DISPOSED));

    notificationManager.dispose();
    workManager.dispose();

    if ((getStartDate() > 0) && logger.isInfoEnabled()) {
      SplashScreen splashScreen = SplashScreen.getInstance(ServerShutdownSplashScreen.class);
      splashScreen.setHeader(this);
      logger.info(splashScreen.toString());
    }

    // SplashScreen holds static variables which need to be cleared in case we restart the server.
    SplashScreen.dispose();
  }
Beispiel #7
0
 public void unregisterListener(ServerNotificationListener l) {
   ServerNotificationManager notificationManager = getNotificationManager();
   if (notificationManager != null) {
     notificationManager.removeListener(l);
   }
 }