Package org.mule.api.transformer

Examples of org.mule.api.transformer.Transformer


    }

    @Test
    public void testParallelTransformation() throws Exception
    {
        final Transformer transformer = getTransformer();

        long startTime = System.currentTimeMillis();

        for (int i = 0; i < getParallelThreadCount(); ++i)
        {
            new Thread(new Runnable()
            {
                @Override
                public void run()
                {
                    signalStarted();
                    for (int j = 0; j < getCallsPerThread(); ++j)
                    {
                        try
                        {
                            actualResults.add(transformer.transform(srcData));
                        }
                        catch (TransformerException e)
                        {
                            actualResults.add(e);
                        }
View Full Code Here


            if (expectedType instanceof ParameterizedType)
            {
                expectedType = ((ParameterizedType) expectedType).getRawType();
            }
            DataType targetDataType = DataTypeFactory.create(((Class) expectedType));
            Transformer t = muleMessage.getMuleContext()
                .getRegistry()
                .lookupTransformer(sourceDataType, targetDataType);
            return t.transform(target);
        }
        else
        {
            return target;
        }
View Full Code Here

            }
            else
            {
                targetDataType = DataTypeFactory.create(((Class) expectedType));
            }
            Transformer t = muleContext.getRegistry().lookupTransformer(sourceDataType, targetDataType);
            if (t instanceof MessageTransformer)
            {
                return ((MessageTransformer) t).transform(source, event);
            }
            else
            {
                return t.transform(source);
            }
        }
        else
        {
            return source;
View Full Code Here

            }
            else
            {
                targetDataType = DataTypeFactory.create(((Class) expectedType));
            }
            Transformer t = muleContext.getRegistry().lookupTransformer(sourceDataType, targetDataType);
            return t.transform(source);
        }
        else
        {
            return source;
        }
View Full Code Here

            if (!getReturnClass().isInstance(result))
            {
                //If the return type does not match, lets attempt to transform it before throwing an error
                try
                {
                    Transformer t = muleContext.getRegistry().lookupTransformer(
                        DataTypeFactory.createFromObject(result), DataTypeFactory.create(getReturnClass()));
                    result = t.transform(result);
                }
                catch (TransformerException e)
                {
                    throw new ExpressionRuntimeException(CoreMessages.transformUnexpectedType(result.getClass(),
                    getReturnClass()), e);
View Full Code Here

    }

    @Test
    public void testTransformers() throws Exception
    {
        Transformer transformer = lookupTransformer("ObjectToXmpp");
        assertNotNull(transformer);
        assertEquals(ObjectToXmppPacket.class, transformer.getClass());

        transformer = lookupTransformer("XmppToObject");
        assertNotNull(transformer);
        assertEquals(XmppPacketToObject.class, transformer.getClass());
    }
View Full Code Here

        return endpointBuilder;
    }

    private Transformer lookupTransformer(String transformerName)
    {
        Transformer transformer = muleContext.getRegistry().lookupTransformer(transformerName);
        assertNotNull(transformer);
        return transformer;
    }
View Full Code Here

    }

    @Override
    public Transformer getTransformer() throws Exception
    {
        Transformer trans = createObject(DomDocumentToXml.class);
        trans.setReturnDataType(DataTypeFactory.STRING);

        EndpointBuilder builder = new EndpointURIEndpointBuilder("test://test", muleContext);
        builder.setEncoding("US-ASCII");
        ImmutableEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint(
            builder);

        trans.setEndpoint(endpoint);
        return trans;
    }
View Full Code Here

    }

    @Override
    public Transformer getTransformer() throws Exception
    {
        Transformer trans = createObject(XmlToOutputHandler.class);
        trans.setReturnDataType(DataTypeFactory.create(OutputHandler.class));

        EndpointBuilder builder = new EndpointURIEndpointBuilder("test://test", muleContext);
        builder.setEncoding("UTF-8");
        ImmutableEndpoint endpoint =
            muleContext.getEndpointFactory().getInboundEndpoint(builder);

        trans.setEndpoint(endpoint);
        return trans;
    }
View Full Code Here

    }

    @Test
    public void testRegisterTransformersAsNamedObjects() throws Exception
    {
        Transformer transformer1 = muleRegistryHelper.lookupTransformer(DataTypeFactory.STRING, APPLE_DATA_TYPE);
        Transformer transformer2 = muleRegistryHelper.lookupTransformer(APPLE_DATA_TYPE, DataTypeFactory.STRING);

        assertEquals(stringToApple, transformer1);
        assertEquals(appleToString, transformer2);
    }
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.