/** * 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()); }
public void initialise() throws InitialisationException { if (wireFormat == null) { wireFormat = new SerializationWireFormat(); } try { if (StringUtils.isEmpty(serverUri)) { // no serverUrl specified, warn a user logger.warn( "No serverUriUrl specified, MuleAdminAgent will not start. E.g. use " + "<mule:admin-agent serverUri=\"tcp://example.com:60504\"/> "); // abort the agent registration process managementContext.getRegistry().unregisterAgent(this.getName()); return; } // Check for override if (ModelHelper.isComponentRegistered(MuleManagerComponent.MANAGER_COMPONENT_NAME)) { logger.info("Mule manager component has already been initialised, ignoring server url"); } else { if (managementContext.getRegistry().lookupConnector(DEFAULT_MANAGER_ENDPOINT) != null) { throw new AlreadyInitialisedException("Server Components", this); } MuleEndpoint writableEndpoint; // Check to see if we have an endpoint identifier UMOImmutableEndpoint endpoint = managementContext.getRegistry().lookupEndpoint(serverUri); if (endpoint == null) { UMOEndpointURI endpointUri = new MuleEndpointURI(serverUri); UMOConnector connector = TransportFactory.getOrCreateConnectorByProtocol(endpointUri); // If this connector has already been initialised i.e. it's a // pre-existing connector don't reinit if (managementContext.getRegistry().lookupConnector(connector.getName()) == null) { connector.setName(DEFAULT_MANAGER_ENDPOINT); connector.initialise(); managementContext.getRegistry().registerConnector(connector); } writableEndpoint = new MuleEndpoint(); writableEndpoint.setConnector(connector); writableEndpoint.setEndpointURI(endpointUri); } else { writableEndpoint = new MuleEndpoint(endpoint); } logger.info("Registering Admin listener on: " + serverUri); UMODescriptor descriptor = MuleManagerComponent.getDescriptor( writableEndpoint, wireFormat, RegistryContext.getConfiguration().getDefaultEncoding(), RegistryContext.getConfiguration().getDefaultSynchronousEventTimeout()); ModelHelper.registerSystemComponent(descriptor); } } catch (UMOException e) { throw new InitialisationException(e, this); } }
/** * 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; }