Example #1
0
  public synchronized void start() throws MuleException {
    lifecycleManager.checkPhase(Startable.PHASE_NAME);
    if (!isStarted()) {
      if (getSecurityManager() == null) {
        throw new MuleRuntimeException(CoreMessages.objectIsNull("securityManager"));
      }
      if (getQueueManager() == null) {
        throw new MuleRuntimeException(CoreMessages.objectIsNull("queueManager"));
      }

      startDate = System.currentTimeMillis();

      fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STARTING));

      lifecycleManager.firePhase(this, Startable.PHASE_NAME);

      fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STARTED));

      if (logger.isInfoEnabled()) {
        SplashScreen splashScreen = SplashScreen.getInstance(ServerStartupSplashScreen.class);
        splashScreen.setHeader(this);
        splashScreen.setFooter(this);
        logger.info(splashScreen.toString());
      }
    }
  }
Example #2
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();
  }