Package org.mule.api.transformer

Examples of org.mule.api.transformer.Transformer


        final String mimeType = "text/plain";
        final boolean disableTransportTransformer = true;

        // Creates a mock Transformer that will check that the endpoint is completely
        // configured when setEndpoint method is called.
        Transformer mockTransformer = mock(Transformer.class);
        doAnswer(new Answer<Object>()
        {
            public Object answer(InvocationOnMock invocation) throws Throwable
            {
                AbstractEndpoint endpoint = (AbstractEndpoint) invocation.getArguments()[0];
View Full Code Here


                    else
                    {
                        returnClass = ClassUtils.loadClass(returnClassString, getClass());
                    }
                }
                Transformer trans = (Transformer) ClassUtils.instanciateClass(transClass);
                if (!(trans instanceof DiscoverableTransformer))
                {
                    throw new RegistrationException(CoreMessages.transformerNotImplementDiscoverable(trans));
                }
                if (returnClass != null)
                {
                    trans.setReturnDataType(DataTypeFactory.create(returnClass, mime));
                }
                if (name != null)
                {
                    trans.setName(name);
                }
                else
                {
                    //This will generate a default name for the transformer
                    name = trans.getName();
                    //We then prefix the name to ensure there is less chance of conflict if the user registers
                    // the transformer with the same name
                    trans.setName("_" + name);
                }
                registry.registerTransformer(trans);
            }
            catch (InvocationTargetException itex)
            {
View Full Code Here

            // Next see if there are any Connectors to register
            Map transformers = applicationContext.getBeansOfType(Transformer.class, true, true);
            if (transformers.size() > 0)
            {
                Map.Entry entry;
                Transformer t;
                for (Iterator iterator = transformers.entrySet().iterator(); iterator.hasNext();)
                {
                    entry = (Map.Entry) iterator.next();
                    t = (Transformer) entry.getValue();
                    if (t.getName() == null)
                    {
                        t.setName(entry.getKey().toString());
                    }
                    muleContext.getRegistry().registerTransformer(t);
                }
            }
        }
View Full Code Here

    public void testTransformerConfig()
    {
        // first of all test generic transformer configuration
        super.testTransformerConfig();

        Transformer t = muleContext.getRegistry().lookupTransformer("TestCompressionTransformer");
        assertNotNull(t);
        assertTrue(t instanceof TestCompressionTransformer);

        // This will only work with the MuleXml Builder other implementations
        // will have to set this proerty manually or mimic Mules behaviour
        assertEquals("this was set from the manager properties!",
            ((TestCompressionTransformer)t).getBeanProperty1());
        assertEquals(12, ((TestCompressionTransformer)t).getBeanProperty2());

        assertEquals(t.getReturnClass(), java.lang.String.class);

        t = muleContext.getRegistry().lookupTransformer("TestTransformer");
        assertNotNull(t);
        assertEquals(t.getReturnClass(), byte[].class);
    }
View Full Code Here

    }

    public void testFilterOnGlobalEndpoint()
    {
        Flow flow1 = muleContext.getRegistry().lookupObject("flow1");
        Transformer flow1Transoformer = (Transformer) flow1.getMessageProcessors().get(1);
        Flow flow2 = muleContext.getRegistry().lookupObject("flow2");
        Transformer flow2Transoformer = (Transformer) flow2.getMessageProcessors().get(1);

        assertNotSame(flow1Transoformer, flow2Transoformer);
    }
View Full Code Here

            List<Transformer> transformers = new LinkedList<Transformer>();
            StringTokenizer st = new StringTokenizer(property, DELIM);
            while (st.hasMoreTokens())
            {
                String key = st.nextToken().trim();
                Transformer transformer = context.getRegistry().lookupTransformer(key);

                if (transformer == null)
                {
                    throw new IllegalArgumentException(key);
                }
View Full Code Here

        assertEquals("bar", ((TestExceptionStrategy) es).getTestProperty());
    }

    public void testCustomTransformerConfig() throws Exception
    {
        Transformer trans = muleContext.getRegistry().lookupTransformer("testTransformer");
        assertNotNull("testTransformer should not be null", trans);
        assertTrue("Transformer should be an instance of TestCompressionTransformer", trans instanceof TestCompressionTransformer);
        assertEquals(((TestCompressionTransformer)trans).getBeanProperty1(), "soo");
        assertEquals(((TestCompressionTransformer)trans).getBeanProperty2(), 12345);
    }
View Full Code Here

    protected void checkNames(String prefix, List transformers)
    {
        Iterator iterator = transformers.iterator();
        for (int count = 1; iterator.hasNext(); count++)
        {
            Transformer transformer = (Transformer) iterator.next();
            logger.debug(transformer);
            assertEquals(prefix + count, transformer.getName());
        }
    }
View Full Code Here

        muleContext = context;
    }

    public Transformer resolve(DataType source, DataType result) throws ResolverException
    {
        Transformer t = transformerCache.get(source.toString() + result.toString());
        if (t != null)
        {
            return t;
        }
View Full Code Here

    }

    @Override
    public Transformer getRoundTripTransformer() throws Exception
    {
        Transformer trans = super.getRoundTripTransformer();
        EndpointBuilder builder = new EndpointURIEndpointBuilder("test://test", muleContext);
        builder.setEncoding(ENCODING);
        ImmutableEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint(
            builder);
        trans.setEndpoint(endpoint);
        return trans;
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transformer.Transformer

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.