Package org.apache.tuscany.spi.databinding

Examples of org.apache.tuscany.spi.databinding.TransformationContext


        List<Transformer> path =
            registry.getTransformerChain(XmlObject.class.getName(), DataObject.class.getName());
        System.out.println("Path: " + path);

        TransformationContext tContext = createTransformationContext();
        tContext.getMetadata().put(SDOType.class, new SDOType(typeHelper));

        Object result = object;
        for (Transformer transformer : path) {
            result = ((PullTransformer)transformer).transform(result, tContext);
        }
View Full Code Here


        List<Transformer> path =
            registry.getTransformerChain(XMLDocument.class.getName(), Node.class.getName());
        System.out.println("Path: " + path);

        TransformationContext tContext = createTransformationContext();

        Object result = object;
        for (Transformer transformer : path) {
            result = ((PullTransformer)transformer).transform(result, tContext);
        }
View Full Code Here

        List<Transformer> path =
            registry.getTransformerChain(XMLDocument.class.getName(), JAXBElement.class.getName());
        System.out.println("Path: " + path);

        TransformationContext tContext = createTransformationContext();

        Object result = object;
        for (Transformer transformer : path) {
            result = ((PullTransformer)transformer).transform(result, tContext);
        }
View Full Code Here

    private TransformationContext createTransformationContext() {
        DataType dataType = new DataType<Class>(Object.class, null);
        dataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(dataType).anyTimes();

        expect(tContext.getSourceDataType()).andReturn(dataType).anyTimes();
        Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
        expect(tContext.getMetadata()).andReturn(metadata).anyTimes();
        replay(tContext);
        return tContext;
    }
View Full Code Here

        XMLStreamReader reader = t1.transform(object, null);

        DataType targetDataType = new DataType<Class>(Object.class, null);
        targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        // XMLStreamReader to JAXB
        XMLStreamReader2JAXB t2 = new XMLStreamReader2JAXB();
        Object object2 = t2.transform(reader, tContext);

        DataType sourceDataType = new DataType<Class>(Object.class, null);
        sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        replay(tContext1);

        JAXB2Node t3 = new JAXB2Node();
        Node node = t3.transform(object2, tContext1);
View Full Code Here

    @SuppressWarnings("unchecked")
    public void testDataBindingBootstrap() throws Exception {
        DataType targetDataType = new DataType<Class>(Object.class, null);
        targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        String2DataObject t1 = new String2DataObject();
        DataObject po1 = t1.transform(IPO_XML, null);
        client.call(po1);
View Full Code Here

        Reader2JAXB t0 = new Reader2JAXB();

        DataType targetDataType = new DataType<Class>(Object.class, null);
        targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataType<Class>(Object.class, null);
        sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

        Object result = source;
        int size = path.size();
        int i = 0;
        while (i < size) {
            Transformer transformer = path.get(i);
            TransformationContext context =
                createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
            // the source and target type
            if (transformer instanceof PullTransformer) {
                // For intermediate node, set data type to null
                result = ((PullTransformer)transformer).transform(result, context);
View Full Code Here

                                                                 Object.class, null);
        DataType targetType =
            (index == size - 1) ? targetDataType : new DataType<Object>(transformer.getTargetDataBinding(),
                                                                        Object.class, null);
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        TransformationContext context =
            new TransformationContextImpl(sourceType, targetType, classLoader, metadata);
        return context;
    }
View Full Code Here

        List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
        Object result = source;
        int size = path.size();
        for (int i = 0; i < size; i++) {
            Transformer transformer = path.get(i);
            TransformationContext context =
                createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);

            if (transformer instanceof PullTransformer) {
                result = ((PullTransformer)transformer).transform(result, context);
            } else if (transformer instanceof PushTransformer) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.databinding.TransformationContext

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.