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

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


                    }
                    element.setSchemaType(type);
                    element.setSchemaTypeName(type.getQName());
                }
            }
            XMLType xmlType = new XMLType(getElementInfo(element));
            xmlType.setNillable(element.isNillable());
            xmlType.setMany(element.getMaxOccurs() > 1);
            dataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
        }
View Full Code Here


            itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
            Class<?> itemClass = operation.getOutputType().getPhysical();
            DataType<XMLType> outputType = operation.getOutputType();
            QName qname = outputType.getLogical().getElementName();
            qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName());
            itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null));
            if (itemClassType.getPhysical() == org.apache.abdera.model.Entry.class) {
                supportsFeedEntries = true;
            }
           
            return new AtomBindingInvoker.GetInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
View Full Code Here

            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())) {
                // FIXME:: Throw expection or switch to the new Element?
                OMFactory factory = OMAbstractFactory.getOMFactory();
                QName name = xmlType.getElementName();
                OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
                element.setNamespace(namespace);
                element.setLocalName(name.getLocalPart());
            }
        }
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

            // of FaultException
            //
            if ((exc instanceof FaultException) && (faultBeanType.getLogical() instanceof XMLType)) {
                FaultException faultExc = (FaultException)exc;
                DataType<XMLType> faultBeanXMLType = (DataType<XMLType>)faultBeanType;
                XMLType faultLogical = faultBeanXMLType.getLogical();
                faultExc.setFaultName(faultLogical.getElementName());
            }
            return exc;
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
View Full Code Here

        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

                ParameterizedType parameterizedType = ((ParameterizedType)type);
                Type rawType = parameterizedType.getRawType();
                if (rawType == JAXBElement.class) {
                    Type actualType = parameterizedType.getActualTypeArguments()[0];
                    if (actualType instanceof Class) {
                        XMLType xmlType = JAXBContextHelper.getXmlTypeName((Class)actualType);
                        dataType.setLogical(xmlType);
                        dataType.setDataBinding(NAME);
                        return true;
                    }
                }
            }
            if (dataType.getLogical() == null) {
                dataType.setLogical(XMLType.UNKNOWN);
            }
            dataType.setDataBinding(NAME);
            return true;
        }

        XMLType xmlType = JAXBContextHelper.getXmlTypeName(javaType);
        if (xmlType == null) {
            return false;
        }
        dataType.setLogical(xmlType);
        dataType.setDataBinding(NAME);
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

        } else {
            Class type = dataType.getPhysical();
            Object logical = dataType.getLogical();
            QName elementName = JAXBDataBinding.ROOT_ELEMENT;
            if (logical instanceof XMLType) {
                XMLType xmlType = (XMLType)logical;
                QName element = xmlType.getElementName();
                if (element != null) {
                    elementName = element;
                } else {
                    /**
                     * Set the declared type to Object.class so that xsi:type
View Full Code Here

        Class type = dataType.getPhysical();
        if (JAXBElement.class.isAssignableFrom(type)) {
            type = Object.class;
        }
        if (type == Object.class && dataType.getLogical() instanceof XMLType) {
            XMLType xType = (XMLType)dataType.getLogical();
            Class javaType = SimpleTypeMapperImpl.getJavaType(xType.getTypeName());
            if (javaType != null) {
                type = javaType;
            }
        }
        return type;
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.