Examples of ElementInfo


Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

                    XMLType xmlType = (XMLType)dataType.getLogical();
                    if (xmlType.getElementName() != null) {
                        element = xmlType.getElementName();
                    }
                }
                return new ElementInfo(element, new TypeInfo(ANYTYPE_QNAME, false, null));
                // throw new ServiceRuntimeException("No data binding for " + db);
            }

            helper = dataBinding.getXMLTypeHelper();
            if (helper == null) {
                // Default to JAXB
                helper = helpers.get(JAXBDataBinding.NAME);
                if (helper == null) {
                    helper = dataBindings.getDataBinding(JAXBDataBinding.NAME).getXMLTypeHelper();
                    helpers.put(JAXBDataBinding.NAME, helper);
                }
            }
            helpers.put(db, helper);
        }
        TypeInfo typeInfo = helper.getTypeInfo(javaType.isArray() ? javaType.getComponentType() : javaType,
                                               dataType.getLogical());
        ElementInfo element = new ElementInfo(name, typeInfo);
        element.setMany(byte[].class != javaType && javaType.isArray());
        element.setNillable(!javaType.isPrimitive());
        return element;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

   
    public void testCreate() {
        HelperContext context = HelperProvider.getDefaultContext();
        XSDHelper xsdHelper = context.getXSDHelper();
        xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
        ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null);
        DataObject wrapper = (DataObject) handler.create(element, null);
        assertNotNull(wrapper);
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

        targetWrapperHandler = getWrapperHandler(targetDataBinding, targetWrapped);

        if ((!sourceWrapped) && targetWrapped) {
            // Unwrapped --> Wrapped
            WrapperInfo wrapper = targetOp.getWrapper();
            ElementInfo wrapperElement = wrapper.getInputWrapperElement();

            if (source == null) {
                Object targetWrapper = targetWrapperHandler.create(wrapperElement, context);
                return new Object[] {targetWrapper};
            }

            // If the source can be wrapped, wrapped it first
            if (sourceWrapperHandler != null) {
                DataType sourceWrapperType =
                    sourceWrapperHandler.getWrapperType(wrapperElement, wrapper.getInputChildElements(), context);
                if (sourceWrapperType != null) {
                    Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context);
                    if (sourceWrapper != null) {
                        for (int i = 0; i < source.length; i++) {
                            ElementInfo argElement = wrapper.getInputChildElements().get(i);
                            sourceWrapperHandler.setChild(sourceWrapper, i, argElement, source[i]);
                        }
                        Object targetWrapper =
                            mediator.mediate(sourceWrapper, sourceWrapperType, targetType.getLogical().get(0), context
                                .getMetadata());
                        return new Object[] {targetWrapper};
                    }
                }
            }
            // Fall back to child by child transformation
            Object targetWrapper = targetWrapperHandler.create(wrapperElement, context);
            List<DataType> argTypes = wrapper.getUnwrappedInputType().getLogical();

            for (int i = 0; i < source.length; i++) {
                ElementInfo argElement = wrapper.getInputChildElements().get(i);
                DataType<XMLType> argType = argTypes.get(i);
                Object child = source[i];
                child = mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context.getMetadata());
                targetWrapperHandler.setChild(targetWrapper, i, argElement, child);
            }
            return new Object[] {targetWrapper};

        } else if (sourceWrapped && (!targetWrapped)) {
            // Wrapped to Unwrapped
            Object sourceWrapper = source[0];
            Object[] target = null;

            List<ElementInfo> childElements = sourceOp.getWrapper().getInputChildElements();
            if (targetWrapperHandler != null) {
                ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
                // 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);
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

    private static ElementInfo getElementInfo(XmlSchemaElement element) {
        if (element == null) {
            return null;
        }
        ElementInfo elementInfo = new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
        elementInfo.setMany(element.getMaxOccurs() > 1);
        elementInfo.setNillable(element.isNillable());
        return elementInfo;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

        }
        */

        public WrapperInfo getWrapperInfo() throws InvalidWSDLException {
            if (wrapperInfo == null) {
                ElementInfo in = getElementInfo(getInputWrapperElement());
                ElementInfo out = getElementInfo(getOutputWrapperElement());
                List<ElementInfo> inChildren = new ArrayList<ElementInfo>();
                if (in != null) {
                    for (XmlSchemaElement e : getInputChildElements()) {
                        inChildren.add(getElementInfo(e));
                    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

            List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
            for (int i = 0; i < method.getParameterTypes().length; i++) {
                WebParam param = getAnnotation(method, i, WebParam.class);
                assert param != null;
                inputElements.add(new ElementInfo(new QName(param.targetNamespace(), param.name()), null));
            }

            List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
            WebResult result = method.getAnnotation(WebResult.class);
            outputElements.add(new ElementInfo(new QName(result.targetNamespace(), result.name()), null));

            WrapperInfo wrapperInfo =
                new WrapperInfo(JAXB_DATABINDING, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper,
                                                                                                       null),
                                inputElements, outputElements);
            operation.setWrapper(wrapperInfo);
            // operation.setDataBinding(JAXB_DATABINDING); // could be JAXB or SDO
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

            targetWrapperHandler = getWrapperHandler(targetDataBinding, targetWrapped);

            if ((!sourceWrapped) && targetWrapped) {
                // Unwrapped --> Wrapped
                WrapperInfo wrapper = targetOp.getWrapper();
                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 =
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

    public void setUp() throws Exception {
        this.handler = new OMElementWrapperHandler();

        List<ElementInfo> elements = new ArrayList<ElementInfo>();
        for (QName inQName : new QName[] { INPUT1, INPUT2, INPUT3, INPUT4 }) {
            ElementInfo e = new ElementInfo(inQName, null);
            e.setNillable(true);
            elements.add(e);
        }
        // INPUT1,4 are like maxOccurs="unbounded"
        elements.get(0).setMany(true);
        elements.get(3).setMany(true);
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

    private static ElementInfo getElementInfo(XmlSchemaElement element) {
        if (element == null) {
            return null;
        }
        ElementInfo elementInfo = new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
        elementInfo.setMany(element.getMaxOccurs() > 1);
        elementInfo.setNillable(element.isNillable());
        elementInfo.setOmissible(element.getMinOccurs()==0);
        return elementInfo;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.util.ElementInfo

                    QName type = null;
                    if (logical instanceof XMLType) {
                        ((XMLType)logical).setElementName(element);
                        type = ((XMLType)logical).getTypeName();
                    }
                    outputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
                }
               
                List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
                for (int i = 0; i < method.getParameterTypes().length; i++) {
                    WebParam param = getAnnotation(method, i, WebParam.class);
                    ns = param != null ? param.targetNamespace() : "";
                    // Default to "" for doc-lit-wrapped && non-header
                    ns = getValue(ns, documentStyle && (param == null || !param.header()) ? "" : tns);
                    name = param != null ? param.name() : "";
                    name = getValue(name, "arg" + i);
                    element = new QName(ns, name);
                    Object logical = operation.getInputType().getLogical().get(i).getLogical();
                    QName type = null;
                    if (logical instanceof XMLType) {
                        ((XMLType)logical).setElementName(element);
                        type = ((XMLType)logical).getTypeName();
                    }
                                       
                    if (param != null) {
                        ParameterMode mode = getParameterMode(param.mode());
                        operation.getParameterModes().set(i, mode);
                    }
                    ParameterMode mode = operation.getParameterModes().get(i);

                    if (mode.equals(ParameterMode.INOUT)) {
                        inputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
                        outputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
                    } else if (mode.equals(ParameterMode.OUT)) {
                        outputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
                    } else {
                        inputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
                    }
                }                                 
                   
                String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING;
                WrapperInfo wrapperInfo =
                    new WrapperInfo(db, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper, null),
                                    inputElements, outputElements);

                wrapperInfo.setInputWrapperType(inputWrapperDT);
                wrapperInfo.setOutputWrapperType(outputWrapperDT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.