예제 #1
0
  protected void setSubscriptionsOnDescriptor(MuleDescriptor descriptor) throws UMOException {
    List endpoints = new ArrayList();
    for (Iterator iterator = listeners.iterator(); iterator.hasNext(); ) {
      ApplicationListener listener = (ApplicationListener) iterator.next();
      if (listener instanceof AsynchronousEventListener) {
        listener = ((AsynchronousEventListener) listener).getListener();
      }
      if (listener instanceof MuleSubscriptionEventListener) {
        String[] subscriptions = ((MuleSubscriptionEventListener) listener).getSubscriptions();
        for (int i = 0; i < subscriptions.length; i++) {
          if (subscriptions[i].indexOf("*") == -1 && MuleEndpointURI.isMuleUri(subscriptions[i])) {
            boolean isSoap = registerAsSoap(subscriptions[i], listener);

            if (!isSoap) {
              endpoints.add(subscriptions[i]);
            }
          }
        }
      }
    }
    if (endpoints.size() > 0) {
      for (Iterator iterator = endpoints.iterator(); iterator.hasNext(); ) {
        String endpoint = (String) iterator.next();
        MuleEndpoint ep = new MuleEndpoint(endpoint, true);

        // check whether the endpoint has already been set on the MuleEventMulticastor
        if (descriptor.getInboundRouter().getEndpoint(ep.getName()) == null) {
          descriptor.getInboundRouter().addEndpoint(ep);
        }
      }
    }
  }
예제 #2
0
  /**
   * Registers a java object as a Umo pcomponent that listens for and sends events on the given
   * urls. By default the ThreadingProfile for the components will be set so that there will only be
   * one thread of execution.
   *
   * @param component any java object, Mule will it's endpointUri discovery to determine which event
   *     to invoke based on the evnet payload type
   * @param name The identifying name of the components. This can be used to later unregister it
   * @param listenerEndpointUri The url endpointUri to listen to
   * @param sendEndpointUri The url endpointUri to dispatch to
   * @throws UMOException
   */
  public UMODescriptor registerComponentInstance(
      Object component,
      String name,
      UMOEndpointURI listenerEndpointUri,
      UMOEndpointURI sendEndpointUri)
      throws UMOException {
    MuleDescriptor descriptor = new MuleDescriptor();
    descriptor.setName(name);
    descriptor.setImplementationInstance(component);

    // Create the endpoints
    UMOEndpoint inboundProvider = null;
    UMOEndpoint outboundProvider = null;
    if (listenerEndpointUri != null) {
      inboundProvider =
          TransportFactory.createEndpoint(listenerEndpointUri, UMOEndpoint.ENDPOINT_TYPE_RECEIVER);
    }
    if (sendEndpointUri != null) {
      outboundProvider =
          TransportFactory.createEndpoint(sendEndpointUri, UMOEndpoint.ENDPOINT_TYPE_SENDER);
    }
    descriptor.setInboundEndpoint(inboundProvider);
    descriptor.setOutboundEndpoint(outboundProvider);

    // register the components descriptor
    getModel().registerComponent(descriptor);
    return descriptor;
  }
예제 #3
0
 private MuleDescriptor createInDescriptor(String name, String implementation)
     throws UMOException {
   MuleDescriptor descriptor = new MuleDescriptor();
   descriptor.setExceptionListener(new DefaultExceptionStrategy());
   descriptor.setName(name);
   descriptor.setImplementation(implementation);
   descriptor.setInboundEndpoint(buildEndpoint(HTTP_LOCALHOST_60198));
   return descriptor;
 }
예제 #4
0
  /**
   * Creates a component based on its descriptor.
   *
   * @param descriptor the descriptor to create the component from
   * @return The newly created component
   * @throws UMOException
   */
  public static Object createService(UMODescriptor descriptor) throws UMOException {
    Object component;
    try {
      component = descriptor.getServiceFactory().create();

      // TODO MULE-1933 Would be nice to remove this eventually.
      BeanUtils.populate(component, descriptor.getProperties());
    } catch (Exception e) {
      throw new LifecycleException(
          MessageFactory.createStaticMessage("Unable to create component"), e, descriptor);
    }

    // Call any custom initialisers
    if (descriptor instanceof MuleDescriptor) {
      ((MuleDescriptor) descriptor).fireInitialisationCallbacks(component);
    }

    return component;
  }
예제 #5
0
  /**
   * Creates a Mule Descriptor that can be further maniputalted by the calling class before
   * registering it with the UMOModel
   *
   * @param implementation either a container refernece to an object or a fully qualified class name
   *     to use as the component implementation which event to invoke based on the evnet payload
   *     type
   * @param name The identifying name of the component. This can be used to later unregister it
   * @param inboundEndpoint The endpoint to listen to. Can be null
   * @param outboundEndpoint The endpoint to dispatch to. Can be null
   * @param properties properties to set on the component. Can be null
   * @throws UMOException
   */
  public UMODescriptor createDescriptor(
      String implementation,
      String name,
      UMOEndpoint inboundEndpoint,
      UMOEndpoint outboundEndpoint,
      Map properties)
      throws UMOException {
    MuleDescriptor descriptor = new MuleDescriptor();
    descriptor.setImplementation(implementation);
    descriptor.setName(name);
    if (properties != null) {
      descriptor.getProperties().putAll(properties);
    }

    descriptor.setInboundEndpoint(inboundEndpoint);
    descriptor.setOutboundEndpoint(outboundEndpoint);

    return descriptor;
  }
예제 #6
0
  public static final UMODescriptor getDescriptor(
      UMOConnector connector, UMOEndpointURI endpointUri, WireFormat wireFormat)
      throws UMOException {
    UMOEndpoint endpoint = new MuleEndpoint();
    endpoint.setConnector(connector);
    endpoint.setEndpointURI(endpointUri);
    endpoint.setName(MANAGER_ENDPOINT_NAME);
    endpoint.setType(UMOEndpoint.ENDPOINT_TYPE_RECEIVER);

    MuleDescriptor descriptor = new MuleDescriptor();
    descriptor.setName(MANAGER_COMPONENT_NAME);
    descriptor.setInboundEndpoint(endpoint);
    descriptor.setImplementation(MuleManagerComponent.class.getName());
    descriptor.setContainerManaged(false);
    Map props = new HashMap();
    props.put("wireFormat", wireFormat);
    descriptor.setProperties(props);
    return descriptor;
  }