예제 #1
0
  protected void initMule() {
    try {
      // endpointsCache.clear();
      // See if there has been a discriptor explicitly configured
      if (applicationContext.containsBean(EVENT_MULTICASTER_DESCRIPTOR_NAME)) {
        descriptor = (UMODescriptor) applicationContext.getBean(EVENT_MULTICASTER_DESCRIPTOR_NAME);
      }
      // If the mule manager has been initialised in the contain
      // there is not need to do anything here
      if (applicationContext.containsBean("muleManager")) {
        // Register the multicaster descriptor
        registerMulticasterDescriptor();
        return;
      }
      UMOManager manager = MuleManager.getInstance();
      Map map = applicationContext.getBeansOfType(MuleConfiguration.class);
      if (map != null && map.size() > 0) {
        MuleManager.setConfiguration((MuleConfiguration) map.values().iterator().next());
      }
      if (!manager.isStarted()) {
        MuleManager.getConfiguration().setSynchronous(!asynchronous);
        // register any endpointUri mappings
        registerEndpointMappings();
      }
      // tell mule to load component definitions from spring
      SpringContainerContext containerContext = new SpringContainerContext();
      containerContext.setBeanFactory(applicationContext);
      manager.setContainerContext(null);
      manager.setContainerContext(containerContext);

      // see if there are any UMOConnectors to register
      registerConnectors();

      // Next see if there are any UMOTransformers to register
      registerTransformers();

      registerGlobalEndpoints();

      // Register the multicaster descriptor
      registerMulticasterDescriptor();

      if (!manager.isStarted()) {
        manager.start();
      }
    } catch (UMOException e) {
      throw new MuleRuntimeException(SpringMessages.failedToReinitMule(), e);
    }
  }
예제 #2
0
  /**
   * Configures a started manager. This method will throw InitialisationException if the current
   * manager is already started
   *
   * @param synchronous whether to start the manager in synchronous mode
   * @param serverUrl the url used to receive client requests, or null if the server listening
   *     components should not be set up
   * @return the configured manager
   * @throws UMOException if the manager is already started or it fails to start
   */
  public UMOManager createStartedManager(boolean synchronous, String serverUrl, String modeltype)
      throws UMOException {
    if (manager.isStarted()) {
      throw new InitialisationException(new Message(Messages.MANAGER_ALREADY_STARTED), this);
    }
    if (serverUrl == null) {
      serverUrl = "";
    }
    MuleManager.getConfiguration().setServerUrl(serverUrl);
    MuleManager.getConfiguration().setSynchronous(synchronous);
    if (!MODEL_NOT_SET.equals(modeltype)) {
      model = ModelFactory.createModel(modeltype);
    } else {
      model = ModelFactory.createModel("seda");
    }
    manager.registerModel(model);

    manager.start();
    return manager;
  }