Examples of OutboundRouter


Examples of org.mule.api.routing.OutboundRouter

    }

    protected OutboundRouter processOutboundRouter(Class componentFactoryClass) throws MuleException
    {
        Collection routerParsers = context.getRegistry().lookupObjects(MessageProcessorAnnotationParser.class);
        OutboundRouter router = null;

        List<AnnotationMetaData> annotations = AnnotationUtils.getClassAndMethodAnnotations(componentFactoryClass);
        for (AnnotationMetaData metaData : annotations)
        {
            Router routerAnnotation = metaData.getAnnotation().annotationType().getAnnotation(Router.class);
            if (routerAnnotation != null && routerAnnotation.type() == RouterType.Outbound)
            {
                if (router != null)
                {
                    //TODO i18n
                    throw new IllegalStateException("You can only configure one outbound router on a service");
                }
                MessageProcessorAnnotationParser parser = parserFactory.getRouterParser(metaData.getAnnotation(), metaData.getClazz(), metaData.getMember());
                if (parser != null)
                {
                    router = (OutboundRouter) parser.parseMessageProcessor(metaData.getAnnotation());
                }
                else
                {
                    //TODO i18n
                    throw new IllegalStateException("Cannot find parser for router annotation: " + metaData.getAnnotation().toString());
                }
            }
        }
        if (router == null)
        {
            router = new OutboundPassThroughRouter();
        }
        //Todo, wrap lifecycle
        if (router instanceof MuleContextAware)
        {
            ((MuleContextAware) router).setMuleContext(context);
        }
        router.initialise();
        return router;
    }
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        return router;
    }

    protected void processOutbound(Class componentFactoryClass, org.mule.api.service.Service service) throws MuleException
    {
        OutboundRouter router = processOutboundRouter(componentFactoryClass);

        OutboundEndpoint outboundEndpoint;
        List<AnnotationMetaData> annotations = AnnotationUtils.getClassAndMethodAnnotations(componentFactoryClass);
        for (AnnotationMetaData annotation : annotations)
        {
            outboundEndpoint = tryOutboundEndpointAnnotation(annotation, ChannelType.Outbound);
            if (outboundEndpoint != null)
            {
                router.addRoute(outboundEndpoint);
            }
        }

        if (router instanceof MuleContextAware)
        {
            ((MuleContextAware) router).setMuleContext(context);
        }
        router.initialise();
        ((OutboundRouterCollection) service.getOutboundMessageProcessor()).addRoute(router);
    }
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(2, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router1 = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router1.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router1.getRoutes().get(0);
        assertEquals("tcp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("tcp://localhost:60201", endpoint.getEndpointURI().getAddress());
        assertTrue(endpoint instanceof OutboundEndpoint);

        // second Router
        OutboundRouter router2 = (OutboundRouter)outboundRouter.getRoutes().get(1);
        assertEquals(2, router2.getRoutes().size());
        endpoint = (ImmutableEndpoint) router2.getRoutes().get(0);
        assertEquals("udp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("udp://localhost:56731", endpoint.getEndpointURI().getAddress());
        assertTrue(endpoint instanceof OutboundEndpoint);

        endpoint = (ImmutableEndpoint) router2.getRoutes().get(1);
        assertEquals("test", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("test.queue2", endpoint.getEndpointURI().getAddress());
        assertTrue(endpoint instanceof OutboundEndpoint);

    }
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(1, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router.getRoutes().get(0);
        assertEquals("udp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("udp://localhost:56731", endpoint.getEndpointURI().getAddress());
        // cannot get this to work and get axis tests to work
        // (axis seems to use undefined transformers in some strange way)
//        assertTrue(TransformerUtils.isDefined(endpoint.getTransformers()));
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(1, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router.getRoutes().get(0);
        assertEquals(TcpConnector.TCP, endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("tcp://localhost:45431", endpoint.getEndpointURI().getAddress());
        // cannot get this to work and get axis tests to work
        // (axis seems to use undefined transformers in some strange way)
//        assertTrue(TransformerUtils.isDefined(endpoint.getTransformers()));
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

    private void updateEndpointCache(OutboundRouterCollection router)
    {
        endpointsCache.clear();
        for (Iterator iterator = router.getRoutes().iterator(); iterator.hasNext();)
        {
            OutboundRouter r = (OutboundRouter)iterator.next();
            for (MessageProcessor mp : r.getRoutes())
            {
                if (mp instanceof ImmutableEndpoint)
                {
                    ImmutableEndpoint endpoint = (ImmutableEndpoint) mp;
                    endpointsCache.put(endpoint.getEndpointURI().getAddress(), endpoint);
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        MuleEvent result;
        boolean matchfound = false;

        for (Iterator<MatchableMessageProcessor> iterator = getRoutes().iterator(); iterator.hasNext();)
        {
            OutboundRouter outboundRouter = (OutboundRouter) iterator.next();

            final MuleMessage outboundRouterMessage;
            // Create copy of message for router 1..n-1 if matchAll="true" or if
            // routers require copy because it may mutate payload before match is
            // chosen
            if (iterator.hasNext()
                && (isMatchAll() || ((outboundRouter instanceof TransformingMatchable) && ((TransformingMatchable) outboundRouter).isTransformBeforeMatch())))
            {
                if (((DefaultMuleMessage) message).isConsumable())
                {
                    throw new MessagingException(CoreMessages.cannotCopyStreamPayload(message.getPayload()
                        .getClass()
                        .getName()), event);
                }
                outboundRouterMessage = new DefaultMuleMessage(message.getPayload(), message, muleContext);
            }
            else
            {
                outboundRouterMessage = message;
            }

            try
            {
                if (outboundRouter.isMatch(outboundRouterMessage))
                {
                    matchfound = true;
                    // Manage outbound only transactions here
                    final OutboundRouter router = outboundRouter;
   
                    result = router.process(event);
   
                    if (!isMatchAll())
                    {
                        return result;
                    }
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

    public boolean hasEndpoints()
    {
        for (Iterator iterator = routers.iterator(); iterator.hasNext();)
        {
            OutboundRouter router = (OutboundRouter) iterator.next();
            if (router.getRoutes().size() > 0 || router.isDynamicRoutes())
            {
                return true;
            }
        }
        return false;
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

    public void initialise() throws InitialisationException
    {
        if (service != null)
        {
            OutboundRouter router = null;
            if (service.getOutboundMessageProcessor() instanceof OutboundRouterCollection)
            {
                router = (OutboundRouter) ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes()
                    .get(0);
            }
            else if (service.getOutboundMessageProcessor() instanceof OutboundRouter)
            {
                router = (OutboundRouter) service.getOutboundMessageProcessor();
            }
            else
            {
                throw new IllegalStateException(
                    "WSProxyService is only supported when using an OutboundRouter");
            }
            ImmutableEndpoint endpoint = (ImmutableEndpoint) router.getRoutes().get(0);
            this.urlWebservice = endpoint.getEndpointURI().getAddress();

            // remove any params from the url
            int paramIndex;
            if ((paramIndex = this.urlWebservice.indexOf("?")) != -1)
View Full Code Here

Examples of org.mule.api.routing.OutboundRouter

        assertNotNull(service.getOutboundMessageProcessor());
        OutboundRouterCollection router = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNull(router.getCatchAllStrategy());
        assertEquals(1, router.getRoutes().size());
        // check first Router
        OutboundRouter route1 = (OutboundRouter) router.getRoutes().get(0);
        assertTrue(route1 instanceof OutboundPassThroughRouter);
        assertEquals(1, route1.getRoutes().size());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.