Package org.apache.tuscany.sca.interfacedef

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


        Class<?> cls = exceptionType.getPhysical();
        if (cls == FaultException.class) {
            return true;
        }
        DataType faultType = (DataType)exceptionType.getLogical();
        Class<?> faultBean = null;
        WebFault fault = cls.getAnnotation(WebFault.class);
        if (fault != null) {
            faultName = new QName(fault.targetNamespace(), fault.name());
            XMLType xmlType = new XMLType(faultName, null);
            faultType.setLogical(xmlType);
            if (!"".equals(fault.faultBean())) {
                try {
                    faultBean = Class.forName(fault.faultBean(), false, cls.getClassLoader());
                } catch (ClassNotFoundException e) {
                    throw new ServiceRuntimeException(e);
                }
            } else {
                Method m;
                try {
                    m = cls.getMethod("getFaultInfo", (Class[])null);
                    faultBean = m.getReturnType();
                } catch (NoSuchMethodException e) {
                    // Ignore
                }
            }
        }

        if (faultBean == null) {
            String faultBeanClassName = cls.getPackage().getName() + ".jaxws." + cls.getSimpleName() + "Bean";
            try {
                faultBean = Class.forName(faultBeanClassName, false, cls.getClassLoader());
            } catch (ClassNotFoundException e) {
                faultBean = cls;
            }
        }

        faultType.setPhysical(faultBean);
        // TODO: Use the databinding framework to introspect the fault bean class
        if (dataBindingExtensionPoint != null) {
            result =
                dataBindingExtensionPoint.introspectType(faultType, null, Throwable.class.isAssignableFrom(faultBean));
        }

        /*
         The introspection of the fault DT may not have calculated the correct element name,
         though we may have already done this in this method.  Let's look at the DataType now
         that introspection is done, and, if it has an XMLType, let's set the element to the
         'faultName' if we calculated one.
         */
        if ((faultName != null) && (faultType.getLogical() instanceof XMLType)) {
            XMLType faultTypeXML = (XMLType)faultType.getLogical();
            // The element name (if set) should match the fault name
            faultTypeXML.setElementName(faultName);
        }

        return result;
View Full Code Here


    }

    public void testJSON2OMElement() throws Exception {
        JSON2OMElement t1 = new JSON2OMElement();
        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
View Full Code Here

        }
        copy.faultTypes = clonedFaultTypes;

        List<DataType> clonedLogicalTypes = new ArrayList<DataType>();
        for (DataType t : inputType.getLogical()) {
            DataType type = (DataType) t.clone();
            clonedLogicalTypes.add(type);
        }
        DataType<List<DataType>> clonedInputType =
            new DataTypeImpl<List<DataType>>(inputType.getPhysical(), clonedLogicalTypes);
        clonedInputType.setDataBinding(inputType.getDataBinding());
View Full Code Here

     */
    public DataType<List<DataType>> getUnwrappedInputType() {
        if (unwrappedInputType == null) {
            List<DataType> childTypes = new ArrayList<DataType>();
            for (ElementInfo element : getInputChildElements()) {
                DataType type = getDataType(element);
                childTypes.add(type);
            }
            unwrappedInputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class, childTypes);
        }
        return unwrappedInputType;
View Full Code Here

        }
        return unwrappedInputType;
    }

    private DataType getDataType(ElementInfo element) {
        DataType type = null;
        if (element.isMany()) {
            DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
            type = new DataTypeImpl<DataType>("java:array", Object[].class, logical);
        } else {
            type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
        }
        return type;
View Full Code Here

                        if (d.getDataBinding() == null) {
                            d.setDataBinding(dataBinding);
                        }
                    }
                }
                DataType outputType = op.getOutputType();
                if (outputType != null && outputType.getDataBinding() == null) {
                    outputType.setDataBinding(dataBinding);
                }
                List<DataType> faultTypes = op.getFaultTypes();
                if (faultTypes != null) {
                    for (DataType d : faultTypes) {
                        if (d.getDataBinding() == null) {
                            d.setDataBinding(dataBinding);
                        }
                        DataType ft = (DataType) d.getLogical();
                        if (ft.getDataBinding() == null) {
                            ft.setDataBinding(dataBinding);
                        }

                    }
                }
                if (op.isWrapperStyle()) {
                    WrapperInfo wrapper = op.getWrapper();
                    if (wrapper != null) {
                        DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
                        if (unwrappedInputType != null) {
                            for (DataType d : unwrappedInputType.getLogical()) {
                                if (d.getDataBinding() == null) {
                                    d.setDataBinding(dataBinding);
                                }
                            }
                        }
                        DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
                        if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) {
                            unwrappedOutputType.setDataBinding(dataBinding);
                        }
                    }
                }
            }
        }
View Full Code Here

            if (inputType != null) {
                for (DataType d : inputType.getLogical()) {
                    setDataBinding(d, dataBinding);
                }
            }
            DataType outputType = op.getOutputType();
            if (outputType != null) {
                setDataBinding(outputType, dataBinding);
            }
            List<DataType> faultTypes = op.getFaultTypes();
            if (faultTypes != null) {
                for (DataType d : faultTypes) {
                    setDataBinding(d, dataBinding);
                    setDataBinding((DataType) d.getLogical(), dataBinding);
                }
            }
            if (op.isWrapperStyle()) {
                WrapperInfo wrapper = op.getWrapper();
                if (wrapper != null) {
                    DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
                    if (unwrappedInputType != null) {
                        for (DataType d : unwrappedInputType.getLogical()) {
                            setDataBinding(d, dataBinding);
                        }
                    }
                    DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
                    if (unwrappedOutputType != null) {
                        setDataBinding(unwrappedOutputType, dataBinding);
                    }
                }
            }
View Full Code Here

                ElementInfo wrapperElement = wrapper.getOutputWrapperElement();
                List<ElementInfo> childElements = wrapper.getOutputChildElements();

                // If the source can be wrapped, wrapped it first
                if (sourceWrapperHandler != null) {
                    DataType sourceWrapperType =
                        sourceWrapperHandler.getWrapperType(wrapperElement, childElements, context);
                    if (sourceWrapperType != null) {
                        Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context);
                        if (sourceWrapper != null) {
                            if (!childElements.isEmpty()) {
                                // Set the return value
                                ElementInfo returnElement = wrapper.getOutputChildElements().get(0);
                                sourceWrapperHandler.setChild(sourceWrapper, 0, returnElement, response);
                            }
                            Object targetWrapper =
                                mediator.mediate(sourceWrapper, sourceWrapperType, targetType.getLogical(), context
                                    .getMetadata());
                            return targetWrapper;
                        }
                    }
                }
                Object targetWrapper = targetWrapperHandler.create(wrapper.getOutputWrapperElement(), context);

                if (childElements.isEmpty()) {
                    // void output
                    return targetWrapper;
                }
                ElementInfo argElement = childElements.get(0);
                DataType<XMLType> argType = wrapper.getUnwrappedOutputType();
                Object child = response;
                child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
                targetWrapperHandler.setChild(targetWrapper, 0, argElement, child);
                return targetWrapper;
            } else if (sourceWrapped && (!targetWrapped)) {
                // Wrapped to Unwrapped
                Object sourceWrapper = response;
                List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
                if (childElements.isEmpty()) {
                    // The void output
                    return null;
                }
                if (targetWrapperHandler != null) {
                    ElementInfo wrapperElement = sourceOp.getWrapper().getOutputWrapperElement();

                    // FIXME: This is a workaround for the wsdless support as it passes in child elements
                    // under the wrapper that only matches by position
                    if (sourceWrapperHandler.isInstance(sourceWrapper, wrapperElement, childElements, context)) {
                        DataType targetWrapperType =
                            targetWrapperHandler.getWrapperType(wrapperElement, childElements, context);
                        if (targetWrapperType != null) {
                            Object targetWrapper =
                                mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context
                                    .getMetadata());
View Full Code Here

        //        }

        // FIXME: We need to deal with wrapped<-->unwrapped conversion

        // Check output type
        DataType sourceOutputType = source.getOutputType();
        DataType targetOutputType = target.getOutputType();

        // Note the target output type is now the source for checking
        // compatibility
        if (!isCompatible(targetOutputType, sourceOutputType, remotable)) {
            return false;
View Full Code Here

        // wireService.checkCompatibility(source, target, false);
    }

    public void testOutputTypes() throws Exception {
        InterfaceContract source = new MockContract("FooContract");
        DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
        Operation opSource1 = newOperation("op1");
        opSource1.setOutputType(sourceOutputType);
        Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
        sourceOperations.put("op1", opSource1);
        source.getInterface().getOperations().addAll(sourceOperations.values());

        InterfaceContract target = new MockContract("FooContract");
        DataType targetOutputType = new DataTypeImpl<Type>(String.class, String.class);
        Operation opTarget = newOperation("op1");
        opTarget.setOutputType(targetOutputType);
        Map<String, Operation> targetOperations = new HashMap<String, Operation>();
        targetOperations.put("op1", opTarget);
        target.getInterface().getOperations().addAll(targetOperations.values());
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.