Package org.apache.tuscany.sca.interfacedef

Examples of org.apache.tuscany.sca.interfacedef.DataType


                // If the result is from an InvocationTargetException look at
                // the actual cause.
                if (result instanceof InvocationTargetException) {
                    result = ((InvocationTargetException)result).getCause();
                }
                DataType targetDataType = null;
                for (DataType exType : targetOperation.getFaultTypes()) {
                    if (((Class)exType.getPhysical()).isInstance(result)) {
                        if (result instanceof FaultException) {
                            DataType faultType = (DataType)exType.getLogical();
                            if (((FaultException)result).isMatchingType(faultType.getLogical())) {
                                targetDataType = exType;
                                break;
                            }
                        } else {
                            targetDataType = exType;
                            break;
                        }
                    }
                }

                /*
                if (targetDataType == null) {
                    // Not a business exception
                    return resultMsg;
                }
                */

                DataType targetFaultType = getFaultType(targetDataType);
                if (targetFaultType == null) {
                    throw new ServiceRuntimeException("Target fault type cannot be resolved: " + targetDataType,
                                                      (Throwable)result);
                    // throw new TransformationException("Target fault type cannot be resolved: " + targetDataType);
                }

                // FIXME: How to match a source fault type to a target fault
                // type?
                DataType sourceDataType = null;
                DataType sourceFaultType = null;
                for (DataType exType : sourceOperation.getFaultTypes()) {
                    DataType faultType = getFaultType(exType);
                    // Match by the QName (XSD element) of the fault type
                    if (faultType != null && typesMatch(targetFaultType.getLogical(), faultType.getLogical())) {
                        sourceDataType = exType;
                        sourceFaultType = faultType;
                        break;
                    }
                }
View Full Code Here


     * @param context
     * @param element
     */
    public static void adjustElementName(TransformationContext context, OMElement element) {
        if (context != null) {
            DataType dataType = context.getTargetDataType();
            Object logical = dataType == null ? null : dataType.getLogical();
            if (!(logical instanceof XMLType)) {
                return;
            }
            XMLType xmlType = (XMLType)logical;
            if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) {
View Full Code Here

        HelperContext helperContext = SDOContextHelper.getHelperContext(context);
        OMFactory factory = OMAbstractFactory.getOMFactory();

        QName name  = ROOT_ELEMENT;
        if (context != null) {
            DataType dataType = context.getTargetDataType();
            Object logical = dataType == null ? null : dataType.getLogical();
            if (logical instanceof XMLType) {
                XMLType xmlType = (XMLType)logical;
                if (xmlType.isElement()) {
                    name = xmlType.getElementName();
                }
View Full Code Here

                    if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) {
                        inArg.setDataBinding(JSONDataBinding.NAME);
                    }
                }
            }
            DataType outputType = operation.getOutputType();
            if (outputType != null) {
                if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) {
                    outputType.setDataBinding(JSONDataBinding.NAME);
                }
            }
        }
    }
View Full Code Here

        for (Operation op : iface.getOperations()) {
            DataType<List<DataType>> inputType = op.getInputType();
            for (DataType t : inputType.getLogical()) {
                register(pkg2nsMap, t);
            }
            DataType outputType = op.getOutputType();
            register(pkg2nsMap, outputType);
        }

        Definition def = createDefinition(pkg2nsMap, iface.getJavaClass(), requiresSOAP12);
View Full Code Here

        operations = new ArrayList<Operation>();
        operations.add(operation);

        types = new ArrayList<DataType>();
        inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
        DataType type = new DataTypeImpl<Class>(String.class, Object.class);
        types.add(type);
        operation = newOperation("foo");
        operation.setInputType(inputType);
        operations.add(operation);

        types = new ArrayList<DataType>();
        type = new DataTypeImpl<Class>(String.class, Object.class);
        DataType type2 = new DataTypeImpl<Class>(String.class, Object.class);
        types.add(type);
        types.add(type2);
        inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
        operation = newOperation("foo");
        operation.setInputType(inputType);
View Full Code Here

     * @param context
     * @param element
     */
    public static void adjustElementName(TransformationContext context, OMElement element) {
        if (context != null) {
            DataType dataType = context.getTargetDataType();
            Object logical = dataType == null ? null : dataType.getLogical();
            if (!(logical instanceof XMLType)) {
                return;
            }
            XMLType xmlType = (XMLType)logical;
            if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) {
View Full Code Here

    }

    public void testTransform() throws Exception {
        Reader2JAXB t0 = new Reader2JAXB();

        DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        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 DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        replay(tContext1);
View Full Code Here

    public void testTransform2() throws Exception {
        Reader2JAXB t0 = new Reader2JAXB();

        QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
        DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, 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 DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
View Full Code Here

    }   

    public void testTransform3() throws Exception {

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        replay(tContext1);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.interfacedef.DataType

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.