Package org.apache.tuscany.sca.interfacedef.util

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


                elements.add(getElementInfo(logical.getPhysical(), logical, null, helpers));
             } else {
                // convert synthesized fault bean to a wrapper type
                elements = new ArrayList<ElementInfo>();
                for (DataType<XMLType> propDT: op.getFaultBeans().get(faultName)) {
                    XMLType logical = propDT.getLogical();
                    elements.add(getElementInfo(propDT.getPhysical(), propDT, logical.getElementName(), helpers));
                }
            }
            wrappers.put(faultName, elements);
        }
View Full Code Here


    public Part generatePart(Definition definition, DataType arg, String partName) {
        Part part = definition.createPart();
        part.setName(partName);
        if (arg != null && arg.getLogical() instanceof XMLType) {
            XMLType xmlType = (XMLType)arg.getLogical();
            QName elementName = xmlType.getElementName();
            part.setElementName(elementName);
            addNamespace(definition, elementName);
            if (xmlType.getElementName() == null) {
                QName typeName = xmlType.getTypeName();
                part.setTypeName(typeName);
                addNamespace(definition, typeName);
            }
        }
        return part;
View Full Code Here

        if (helper == null) {
            DataBinding dataBinding = dataBindings.getDataBinding(db);
            if (dataBinding == null) {
                QName element = name;
                if (element == null || dataType.getLogical() instanceof XMLType) {
                    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);
            }
View Full Code Here

        } else {
            // For remote interfaces where the target is represented with WSDL
            // the source will have been converted to WSDL so we rely on JAXB mappings
            // being the same in both cases and just compare the type names directly.
            // TODO - is this right?
            XMLType sourceLogicalType = null;

            // There is some nesting of data types (when GeneratedDataTypes or arrays are used) so
            // dig a bit deeper to find the real data type. Use a loop since for a multidimensional
            // array, we might need to go more than one level deep.
            while (source.getLogical() instanceof DataType<?>) {
                source = (DataType<?>)source.getLogical();
            }           
            sourceLogicalType = (XMLType)source.getLogical();

            XMLType targetLogicalType = null;
            while (target.getLogical() instanceof DataType<?>) {
                target = (DataType<?>)target.getLogical();
            }           
            targetLogicalType = (XMLType)target.getLogical();

            // The logical type seems to be null in some cases, e.g. when the
            // argument or return type is something like a Map.
            // TODO - check when some type give rise to a null logical type
            if (sourceLogicalType.getTypeName() == null ||
                targetLogicalType.getTypeName() == null) {
                return true;
            }

            boolean match = sourceLogicalType.getTypeName().equals(targetLogicalType.getTypeName());

            if (!match){

                QName anyType = new QName("http://www.w3.org/2001/XMLSchema", "anyType");
                if (sourceLogicalType.getTypeName().equals(anyType) ||
                    targetLogicalType.getTypeName().equals(anyType)){
                    // special case where a Java interface uses a generic type, e.g.
                    // public OMElement getGreetings(OMElement om)
                    // while the provided WSDL uses a specific type. So we assume
                    // that xsd:anyType matched anything
                    match = true;
                } else {
                    if (audit != null){
                        audit.append("Operation argument types source = " +
                                     sourceLogicalType.getTypeName() +
                                     " target = " +
                                     targetLogicalType.getTypeName() +
                        " don't match for");
                    }
                }
            }
View Full Code Here

            Object logical = type.getLogical();
            if (logical instanceof XMLType) {
                elementName = ((XMLType)logical).getElementName();
            }
            TypeInfo typeInfo = SimpleTypeMapperImpl.getXMLType(cls);
            type.setLogical(new XMLType(elementName, typeInfo == null ? null : typeInfo.getQName()));
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

    @Override
    public boolean introspect(DataType type, Annotation[] annotations) {
        if (Node.class.isAssignableFrom(type.getPhysical())) {
            if (type.getLogical() == null) {
                type.setLogical(new XMLType(ROOT_ELEMENT, null));
            }
            type.setDataBinding(NAME);
            return true;
        }
        return false;
View Full Code Here

            DataType dataType = context.getTargetDataType();
            Object logical = dataType == null ? null : dataType.getLogical();
            if (!(logical instanceof XMLType)) {
                return element;
            }
            XMLType xmlType = (XMLType)logical;
            QName name = new QName(element.getNamespaceURI(), element.getLocalName());
            if (xmlType.isElement() && !xmlType.getElementName().equals(name)) {
                QName newName = xmlType.getElementName();
                String prefix = element.getPrefix();
                String qname = newName.getLocalPart();
                if (prefix != null && !prefix.equals("")) {
                    qname = prefix + ":" + qname;
                }
View Full Code Here

        QName elementName = null;
        Object logical = dataType.getLogical();
        if (logical instanceof XMLType) {
            elementName = ((XMLType)logical).getElementName();
        }
        dataType.setLogical(new XMLType(elementName, xmlType));
        return true;
    }
View Full Code Here

        }
        DataType<?> dataType = context.getTargetDataType();
        Object logical = dataType.getLogical();
        QName elementName = null;
        if (logical instanceof XMLType) {
            XMLType xmlType = (XMLType)logical;
            QName element = xmlType.getElementName();
            if (element != null) {
                elementName = element;
            }
        }
        if (elementName == null) {
            // Try source type
            dataType = context.getSourceDataType();
            logical = dataType.getLogical();
            if (logical instanceof XMLType) {
                XMLType xmlType = (XMLType)logical;
                QName element = xmlType.getElementName();
                if (element != null) {
                    elementName = element;
                }
            }
        }
View Full Code Here

    }
   
    public Object transform(T source, TransformationContext context) {
        //FIXME why is the logical type sometimes a Class instead of an XMLType?
        if (context.getSourceDataType().getLogical() instanceof XMLType) {
            XMLType xmlType = (XMLType) context.getSourceDataType().getLogical();
            return toJavaObject(xmlType.getTypeName(), getRootElement(source), context);
        } else {
            return toJavaObject(null, getRootElement(source), context);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.interfacedef.util.XMLType

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.