Beispiel #1
0
  public void start() throws MuleException {
    lifecycleManager.checkPhase(Startable.PHASE_NAME);

    if (!beyondInitialState.get() && initialState.equals(AbstractService.INITIAL_STATE_STOPPED)) {
      logger.info("Service " + name + " has not been started (initial state = 'stopped')");
      beyondInitialState.set(true);
      return;
    }

    // Ensure Component is started. If component was configured with spring and
    // is therefore in the registry it will get started automatically, if it was
    // set on the service directly then it won't be started automatically. So to
    // be sure we start it here.
    component.start();

    // Create the receivers for the service but do not start them yet.
    registerListeners();

    // We connect the receivers _before_ starting the service because there may
    // be
    // some initialization required for the service which needs to have them
    // connected.
    // For example, the org.mule.transport.soap.glue.GlueMessageReceiver adds
    // InitialisationCallbacks within its doConnect() method (see MULE-804).
    connectListeners();

    if (!beyondInitialState.get() && initialState.equals(AbstractService.INITIAL_STATE_PAUSED)) {
      lifecycleManager.fireLifecycle(Startable.PHASE_NAME);
      lifecycleManager.fireLifecycle(Pausable.PHASE_NAME);
      logger.info("Service " + name + " has been started and paused (initial state = 'paused')");
    } else {
      lifecycleManager.fireLifecycle(Startable.PHASE_NAME);
      logger.info("Service " + name + " has been started successfully");
    }
    beyondInitialState.set(true);

    // We start the receivers _after_ starting the service because if a message
    // gets routed to the service before it is started,
    // org.mule.model.AbstractComponent.dispatchEvent() will throw a
    // ServiceException with message COMPONENT_X_IS_STOPPED (see MULE-526).
    startListeners();
  }
Beispiel #2
0
  /**
   * Starts a Mule Service.
   *
   * @param startPaused - Start service in a "paused" state (messages are received but not
   *     processed).
   */
  protected void start(boolean startPaused) throws MuleException {

    // Ensure Component is started. If component was configured with spring and
    // is therefore in the registry it will get started automatically, if it was
    // set on the service directly then it won't be started automatically. So to
    // be sure we start it here.
    component.start();

    // Create the receivers for the service but do not start them yet.
    registerListeners();

    // We connect the receivers _before_ starting the service because there may
    // be
    // some initialization required for the service which needs to have them
    // connected.
    // For example, the org.mule.transport.soap.glue.GlueMessageReceiver adds
    // InitialisationCallbacks within its doConnect() method (see MULE-804).
    connectListeners();

    // Start (and pause) the service.
    if (stopped.get()) {
      stopped.set(false);
      paused.set(false);
      doStart();
    }
    fireServiceNotification(ServiceNotification.SERVICE_STARTED);
    if (startPaused) {
      pause();
    }

    // We start the receivers _after_ starting the service because if a message
    // gets routed to the service before it is started,
    // org.mule.model.AbstractComponent.dispatchEvent() will throw a
    // ServiceException with message COMPONENT_X_IS_STOPPED (see MULE-526).
    startListeners();
  }