Package org.mule.api.service

Examples of org.mule.api.service.Service


        return "org/mule/test/exceptions/exception-strategy-config.xml";
    }

    public void testConfig() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("testService1");
        assertNotNull(service);
        assertNotNull(service.getExceptionListener());
        assertTrue(service.getExceptionListener() instanceof DefaultMessagingExceptionStrategy);

        DefaultMessagingExceptionStrategy es = (DefaultMessagingExceptionStrategy)service.getExceptionListener();
        assertFalse(es.isEnableNotifications());
        assertNotNull(es.getCommitTxFilter());
        assertEquals("java.io.*", es.getCommitTxFilter().getPattern());

        assertNotNull(es.getRollbackTxFilter());
View Full Code Here


        return "org/mule/test/spring/global-properties-mule-2458-test.xml";
    }

    public void testProperties()
    {
        Service service = muleContext.getRegistry().lookupService("service");
        assertNotNull(service);
        ImmutableEndpoint ep = (ImmutableEndpoint) ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0);
        assertNotNull(ep);
        assertEquals("local", ep.getProperties().get("local"));
        assertEquals("global", ep.getProperties().get("global"));
        assertEquals("local", ep.getProperties().get("override-me"));
        assertEquals(3, ep.getProperties().size());
View Full Code Here

        {
            model = new SedaModel();
            model.setName(MuleProperties.OBJECT_SYSTEM_MODEL);
            muleContext.getRegistry().registerModel(model);
        }
        Service service = muleContext.getRegistry().lookupService(EVENT_MULTICASTER_DESCRIPTOR_NAME);
        if (service != null)
        {
            muleContext.getRegistry().unregisterService(service.getName());
        }
        service = new SedaService(muleContext);
        service.setName(EVENT_MULTICASTER_DESCRIPTOR_NAME);
        service.setModel(model);
        if (subscriptions == null)
        {
            logger.info("No receive endpoints have been set, using default '*'");
            ((CompositeMessageSource) service.getMessageSource()).addSource(
                muleContext.getEndpointFactory().getInboundEndpoint("vm://*"));
        }
        else
        {
            // Set multiple inbound subscriptions on the descriptor
            ServiceCompositeMessageSource messageRouter = (ServiceCompositeMessageSource) service.getMessageSource();

            for (int i = 0; i < subscriptions.length; i++)
            {
                String subscription = subscriptions[i];

                EndpointFactory endpointFactory = muleContext.getEndpointFactory();
                EndpointBuilder endpointBuilder = endpointFactory.getEndpointBuilder(subscription);
                endpointBuilder.setExchangePattern(MessageExchangePattern.fromSyncFlag(!asynchronous));
                InboundEndpoint endpoint = endpointFactory.getInboundEndpoint(endpointBuilder);

                messageRouter.addSource(endpoint);
            }
        }
        DefaultJavaComponent component = new DefaultJavaComponent(new SingletonObjectFactory(this));
        component.setMuleContext(muleContext);
        service.setComponent(component);
        return service;
    }
View Full Code Here

        return new SpringXmlConfigurationBuilder(getConfigResources());
    }

    public void testMessageInfoMappingConfig() throws Exception
    {
        Service d = muleContext.getRegistry().lookupService("msgInfoMappingTestComponent");
        assertNotNull(d);

        final MessageInfoMapping mapping = d.getMessageInfoMapping();
        assertTrue(mapping instanceof ExpressionMessageInfoMapping);

        Map props = new HashMap();
        props.put("id", "myID123");
        props.put("correlation", "myCorrelationID456");
View Full Code Here

        assertEquals("myCorrelationID456",mapping.getCorrelationId(msg));
    }

    public void testPropertyTypesConfig() throws Exception
    {
        Service c = muleContext.getRegistry().lookupService("testPropertiesComponent");
        assertNotNull(c);
        Object obj = getComponent(c);
        assertNotNull(obj);
        assertTrue(obj instanceof Apple);
        assertTrue(((Apple) obj).isBitten());
View Full Code Here

        assertTrue(((Apple) obj).isWashed());
    }

    public void testEndpointURIParamsConfig()
    {
        Service d = muleContext.getRegistry().lookupService("testPropertiesComponent");
        assertNotNull(d);
        final ServiceCompositeMessageSource router = (ServiceCompositeMessageSource) d.getMessageSource();
        assertNotNull(router);
        final List endpoints = router.getEndpoints();
        assertNotNull(endpoints);
        assertFalse(endpoints.isEmpty());
        final ImmutableEndpoint inboundEndpoint = (ImmutableEndpoint) endpoints.get(0);
View Full Code Here

            return object;
        }

        if (object instanceof Service)
        {
            Service service = (Service) object;
            //Annotations only supported on Java components
            if (service.getComponent() instanceof AbstractJavaComponent)
            {
                try
                {
                    AbstractJavaComponent component = (AbstractJavaComponent) service.getComponent();
                    if(AnnotationUtils.getMethodMetaAnnotations(component.getObjectType(), Channel.class).size()==0)
                    {
                        return object;
                    }
                   
View Full Code Here

        return "org/mule/test/integration/event-metadata-propagation-config.xml";
    }

    public void testEventMetaDataPropagation() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("component1");
        MuleSession session = new DefaultMuleSession(service, muleContext);
        MuleEvent event = new DefaultMuleEvent(new DefaultMuleMessage("Test MuleEvent", muleContext),
            ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0), session);
        service.sendEvent(event);
    }
View Full Code Here

     * @throws Exception
     */
    public void testGracefulShutdownTimeout() throws Exception
    {
        final Latch latch = new Latch();
        Service service = muleContext.getRegistry().lookupService("TestService");
        FunctionalTestComponent testComponent = (FunctionalTestComponent) getComponent(service);
        testComponent.setEventCallback(new EventCallback()
        {

            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                Thread.sleep(5500);
                latch.countDown();

            }
        });
        service.dispatchEvent(getTestEvent("test"));
        Thread.sleep(200);
        service.dispose();
        assertTrue(latch.await(1000, TimeUnit.MILLISECONDS));
    }
View Full Code Here

        return "org/mule/test/components/service-factory-functional-test.xml";
    }

    public void testGenericObjectFactory() throws Exception
    {
        Service c = muleContext.getRegistry().lookupService("orange1");
       
        Object service =  getComponent(c);
        assertTrue("Service should be an Orange", service instanceof Orange);
        // Default values
        assertEquals(new Integer(10), ((Orange) service).getSegments());
View Full Code Here

TOP

Related Classes of org.mule.api.service.Service

Copyright © 2018 www.massapicom. 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.