/** * 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; }
public void testCreate() throws Exception { MuleEndpointURI url = new MuleEndpointURI("tcp://7877"); UMOEndpoint endpoint = TransportFactory.createEndpoint(url, UMOEndpoint.ENDPOINT_TYPE_RECEIVER); assertNotNull(endpoint); assertNotNull(endpoint.getConnector()); assertEquals("tcp://localhost:7877", endpoint.getEndpointURI().getAddress()); }
/** * 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 inboundEndpointUri The url endpointUri to listen to. Can be null * @param outboundEndpointUri The url endpointUri 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, UMOEndpointURI inboundEndpointUri, UMOEndpointURI outboundEndpointUri, Map properties) throws UMOException { // Create the endpoints UMOEndpoint inboundEndpoint = null; UMOEndpoint outboundEndpoint = null; if (inboundEndpointUri != null) { inboundEndpoint = TransportFactory.createEndpoint(inboundEndpointUri, UMOEndpoint.ENDPOINT_TYPE_RECEIVER); } if (outboundEndpointUri != null) { outboundEndpoint = TransportFactory.createEndpoint(outboundEndpointUri, UMOEndpoint.ENDPOINT_TYPE_SENDER); } return createDescriptor(implementation, name, inboundEndpoint, outboundEndpoint, properties); }
public UMOEndpoint createEndpointFromUri(UMOEndpointURI uri, String type) throws UMOException { uri.initialise(); UMOEndpoint endpoint = TransportFactory.createEndpoint(uri, type); registerEndpoint(endpoint); return endpoint; }