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

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


                inputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                    public DataType<XMLType> run() {
                        try {
                            Class<?> wrapperClass = Class.forName(inputWrapperClassName, false, clazz.getClassLoader());
                            QName qname = new QName(inputNS, inputName);
                            DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
                            dataBindingExtensionPoint.introspectType(dt, operation);
                            // TUSCANY-2505
                            if (dt.getLogical() instanceof XMLType) {
                                XMLType xmlType = (XMLType)dt.getLogical();
                                xmlType.setElementName(qname);
                            }
                            return dt;
                        } catch (ClassNotFoundException e) {
                            GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
                            return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, inputWrapperClassName, inputNS, inputName, true,
                                                             cl);
                        }
                    }
                });

                QName inputWrapper = inputWrapperDT.getLogical().getElementName();

                ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
                ns = responseWrapper == null ? tns : getValue(responseWrapper.targetNamespace(), tns);
                name =
                    responseWrapper == null ? operationName + "Response" : getValue(responseWrapper.localName(),
                                                                                    operationName + "Response");
                wrapperBeanName = responseWrapper == null ? "" : responseWrapper.className();
                if ("".equals(wrapperBeanName)) {
                    wrapperBeanName =
                        CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName()) + "Response";
                }

                DataType<XMLType> outputWrapperDT = null;
                final String outputWrapperClassName = wrapperBeanName;
                final String outputNS = ns;
                final String outputName = name;

                outputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                    public DataType<XMLType> run() {
                        try {
                            Class<?> wrapperClass =
                                Class.forName(outputWrapperClassName, false, clazz.getClassLoader());
                            QName qname = new QName(outputNS, outputName);
                            DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
                            dataBindingExtensionPoint.introspectType(dt, operation);
                            // TUSCANY-2505
                            if (dt.getLogical() instanceof XMLType) {
                                XMLType xmlType = (XMLType)dt.getLogical();
                                xmlType.setElementName(qname);
                            }
                            return dt;
                        } catch (ClassNotFoundException e) {
                            GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
                            return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, outputWrapperClassName, outputNS, outputName,
View Full Code Here


                && aMethod.getParameterTypes().length == 0
                && JAXWSFaultExceptionMapper.isMappedGetter(aMethod.getName())) {
                String propName = resolvePropertyFromMethod(aMethod.getName());
                QName propQName = new QName(faultBeanName.getNamespaceURI(), propName);
                Class<?> propType = aMethod.getReturnType();
                XMLType xmlPropType = new XMLType(propQName, null);
                DataType<XMLType> propDT = new DataTypeImpl<XMLType>(propType, xmlPropType);
                org.apache.tuscany.sca.databinding.annotation.DataType dt =
                    aMethod.getAnnotation(org.apache.tuscany.sca.databinding.annotation.DataType.class);
                if (dt != null) {
                    propDT.setDataBinding(dt.value());
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

                QName faultQName = ((XMLType)faultType.getLogical()).getElementName();
                String faultNS =
                    "".equals(fault.targetNamespace()) ? faultQName.getNamespaceURI() : fault.targetNamespace();
                String faultLocal = "".equals(fault.name()) ? faultQName.getLocalPart() : fault.name();
                faultName = new QName(faultNS, faultLocal);
                XMLType xmlType = new XMLType(faultName, null);
                faultType.setLogical(xmlType);
            }
            if (!"".equals(fault.faultBean())) {
                faultBean = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
                    public Class<?> run() {
                        try {
                            return 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) {
            final String faultBeanClassName = CodeGenerationHelper.getPackagePrefix(cls) + cls.getSimpleName() + "Bean";
            final QName qname = faultName;
            faultType = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                public DataType<XMLType> run() {
                    try {
                        Class<?> faultBean = Class.forName(faultBeanClassName, false, cls.getClassLoader());
                        return new DataTypeImpl<XMLType>(faultBean, new XMLType(qname, qname));
                    } catch (ClassNotFoundException e) {
                        if (generatingFaultBean) {
                            Class<? extends Throwable> t = (Class<? extends Throwable>)cls;
                            ClassLoader parent =
                                operation == null ? t.getClassLoader() : ((JavaInterface)operation.getInterface())
                                    .getJavaClass().getClassLoader();
                            GeneratedClassLoader cl = new GeneratedClassLoader(parent);
                            GeneratedDataTypeImpl dt = new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, t, cl);
                            return dt;
                        } else {
                            return new DataTypeImpl<XMLType>(cls, new XMLType(qname, qname));
                        }
                    }
                }
            });
        } else {
            faultType.setDataBinding(null);
            faultType.setGenericType(faultBean);
            faultType.setPhysical(faultBean);
        }

        // TODO: Use the databinding framework to introspect the fault bean class
        if (faultType.getDataBinding() == null && dataBindingExtensionPoint != null) {
            faultBean = faultType.getPhysical();
            result =
                dataBindingExtensionPoint.introspectType(faultType, operation);
        }
        ((DataType) exceptionType).setLogical(faultType);

        /*
         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

    private boolean typesMatch(Object first, Object second) {
        if (first.equals(second)) {
            return true;
        }
        if (first instanceof XMLType && second instanceof XMLType) {
            XMLType t1 = (XMLType)first;
            XMLType t2 = (XMLType)second;
            // TUSCANY-2113, we should compare element names only
            return matches(t1.getElementName(), t2.getElementName());
        }
        return false;
    }
View Full Code Here

                    }
                    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

            } else if (conversational) {
                conversationSequence = ConversationSequence.CONVERSATION_CONTINUE;
            }

            // Set outputType to null for void
            XMLType xmlReturnType = new XMLType(new QName(ns, "return"), null);
            DataType<XMLType> returnDataType =
                returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method
                    .getGenericReturnType(), xmlReturnType);
            List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length);
            Type[] genericParamTypes = method.getGenericParameterTypes();
            for (int i = 0; i < parameterTypes.length; i++) {
                Class<?> paramType = parameterTypes[i];
                XMLType xmlParamType = new XMLType(new QName(ns, "arg" + i), null);
                paramDataTypes.add(new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, paramType, genericParamTypes[i],
                                                             xmlParamType));
            }
            List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length);
            Type[] genericFaultTypes = method.getGenericExceptionTypes();
            for (int i = 0; i < faultTypes.length; i++) {
                Class<?> faultType = faultTypes[i];
                // Only add checked exceptions
                // JAXWS Specification v2.1 section 3.7 says RemoteException should not be mapped
                if (Exception.class.isAssignableFrom(faultType) && (!RuntimeException.class.isAssignableFrom(faultType))
                    && (!RemoteException.class.isAssignableFrom(faultType))) {
                    XMLType xmlFaultType = new XMLType(new QName(ns, faultType.getSimpleName()), null);
                    DataType<XMLType> faultDataType =
                        new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i], xmlFaultType);
                    faultDataTypes.add(new DataTypeImpl<DataType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i],
                                                                  faultDataType));
                }
View Full Code Here

        public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) {
            this.isSimpleType = isSimpleType;
            this.property = property;
            this.propertyValue = propertyValue;
            this.javaType = javaType;
            sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property
                .getXSDType()));
            TypeInfo typeInfo = null;
            if (this.property.getXSDType() != null) {
                if (SimpleTypeMapperImpl.isSimpleXSDType(this.property.getXSDType())) {
                    typeInfo = new TypeInfo(property.getXSDType(), true, null);
                } else {
                    typeInfo = new TypeInfo(property.getXSDType(), false, null);
                }
            } else {
                typeInfo = new TypeInfo(property.getXSDType(), false, null);
            }

            XMLType xmlType = new XMLType(typeInfo);
            String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName());
            if (dataBinding != null) {
                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
            } else {
                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
View Full Code Here

    private boolean typesMatch(Object first, Object second) {
        if (first.equals(second)) {
            return true;
        }
        if (first instanceof XMLType && second instanceof XMLType) {
            XMLType t1 = (XMLType)first;
            XMLType t2 = (XMLType)second;
            // TUSCANY-2113, we should compare element names only
            return matches(t1.getElementName(), t2.getElementName());
        }
        return false;
    }
View Full Code Here

    @Test
    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 = new TransformationContextImpl();
        tContext.setTargetDataType(targetDataType);
        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 = new TransformationContextImpl();
        tContext1.setSourceDataType(sourceDataType);
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.