Example #1
0
  /**
   * Initialise the service. The service will first create a Mule UMO from the UMODescriptor and
   * then initialise a pool based on the attributes in the UMODescriptor.
   *
   * @throws org.mule.api.lifecycle.InitialisationException if the service fails to initialise
   */
  public final synchronized void initialise() throws InitialisationException {
    if (initialised.get()) {
      throw new InitialisationException(
          CoreMessages.objectAlreadyInitialised("Service '" + name + "'"), this);
    }
    // Ensure Component has service instance and is initialised. If the 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.setService(this);
    component.initialise();

    if (inboundRouter == null) {
      // Create Default routes that route to the default inbound and
      // outbound endpoints
      inboundRouter = new DefaultInboundRouterCollection();
      // TODO MULE-2102 This should be configured in the default template.
      inboundRouter.addRouter(new InboundPassThroughRouter());
    }
    if (outboundRouter == null) {
      outboundRouter = new DefaultOutboundRouterCollection();
      // TODO MULE-2102 This should be configured in the default template.
      outboundRouter.addRouter(new OutboundPassThroughRouter());
    }
    if (responseRouter == null) {
      responseRouter = new DefaultResponseRouterCollection();
    }

    if (exceptionListener == null) {
      // By default us the model Exception Listener
      exceptionListener = getModel().getExceptionListener();
      //            // TODO MULE-2102 This should be configured in the default template.
      //            exceptionListener = new DefaultServiceExceptionStrategy(this);
      //            ((MuleContextAware) exceptionListener).setMuleContext(muleContext);
      //            ((Initialisable) exceptionListener).initialise();
    }

    doInitialise();

    // initialise statistics
    stats = createStatistics();

    stats.setEnabled(muleContext.getStatistics().isEnabled());
    muleContext.getStatistics().add(stats);
    stats.setOutboundRouterStat(outboundRouter.getStatistics());
    stats.setInboundRouterStat(inboundRouter.getStatistics());
    stats.setComponentStat(component.getStatistics());

    initialised.set(true);
    fireServiceNotification(ServiceNotification.SERVICE_INITIALISED);
  }
Example #2
0
  /**
   * Initialise the service. The service will first create a component from the ServiceDescriptor
   * and then initialise a pool based on the attributes in the ServiceDescriptor .
   *
   * @see org.mule.api.registry.ServiceDescriptor
   * @throws org.mule.api.lifecycle.InitialisationException if the service fails to initialise
   */
  public final synchronized void initialise() throws InitialisationException {
    if (inboundRouter == null) {
      // Create Default routes that route to the default inbound and
      // outbound endpoints
      inboundRouter = new DefaultInboundRouterCollection();
      // TODO MULE-2102 This should be configured in the default template.
      inboundRouter.addRouter(new InboundPassThroughRouter());
    }
    if (outboundRouter == null) {
      outboundRouter = new DefaultOutboundRouterCollection();
      // TODO MULE-2102 This should be configured in the default template.
      outboundRouter.addRouter(new OutboundPassThroughRouter());
    }
    if (responseRouter == null) {
      responseRouter = new DefaultResponseRouterCollection();
    }

    if (exceptionListener == null) {
      // By default us the model Exception Listener
      exceptionListener = getModel().getExceptionListener();
      //            // TODO MULE-2102 This should be configured in the default template.
      //            exceptionListener = new DefaultServiceExceptionStrategy(this);
      //            ((MuleContextAware) exceptionListener).setMuleContext(muleContext);
      //            ((Initialisable) exceptionListener).initialise();
    }

    try {
      lifecycleManager.fireLifecycle(Initialisable.PHASE_NAME);
    } catch (LifecycleException e) {
      throw new InitialisationException(e, this);
    }
    // Ensure Component has service instance and is initialised. If the 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.setService(this);
    component.initialise();

    // initialise statistics
    stats = createStatistics();

    stats.setEnabled(muleContext.getStatistics().isEnabled());
    muleContext.getStatistics().add(stats);
    stats.setOutboundRouterStat(outboundRouter.getStatistics());
    stats.setInboundRouterStat(inboundRouter.getStatistics());
    stats.setComponentStat(component.getStatistics());
  }
Example #3
0
 public void testEndpointURIParamsConfig() {
   Service d = muleContext.getRegistry().lookupService("testPropertiesComponent");
   assertNotNull(d);
   final InboundRouterCollection router = d.getInboundRouter();
   assertNotNull(router);
   final List endpoints = router.getEndpoints();
   assertNotNull(endpoints);
   assertFalse(endpoints.isEmpty());
   final ImmutableEndpoint inboundEndpoint = (ImmutableEndpoint) endpoints.get(0);
   assertNotNull(inboundEndpoint);
   final List transformers = inboundEndpoint.getTransformers();
   assertFalse(transformers.isEmpty());
   assertNotNull(transformers.get(0));
   final List responseTransformers = inboundEndpoint.getResponseTransformers();
   assertFalse(responseTransformers.isEmpty());
   assertNotNull(responseTransformers.get(0));
 }
Example #4
0
  /** Returns a list of all incoming endpoints on a service. */
  protected List getIncomingEndpoints() {
    List endpoints = new ArrayList();

    // Add inbound endpoints
    endpoints.addAll(inboundRouter.getEndpoints());

    // Add response endpoints
    if (responseRouter != null && responseRouter.getEndpoints() != null) {
      endpoints.addAll(responseRouter.getEndpoints());
    }
    return endpoints;
  }