Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlType


       
        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
        if (root != null) {
            return getQNameFromNamespaceAndName(root.namespace(), root.name(), cls, pluralName);
        } else if (cls.getAnnotation(XmlType.class) != null) {
            XmlType xmlType = cls.getAnnotation(XmlType.class);
            return getQNameFromNamespaceAndName(xmlType.namespace(), xmlType.name(), cls, pluralName);
        } else {
            return new QName(getPackageNamespace(cls), cls.getSimpleName());
        }
    }
View Full Code Here


            if (elementName.equals("##default")) {
                elementName = jaxbDecapitalize(javaType.getSimpleName());
            }
            elementQName = new QName(elementNamespace, elementName);
        }
        XmlType type = javaType.getAnnotation(XmlType.class);
        if (type != null) {
            String typeNamespace = type.namespace();
            String typeName = type.name();

            if (typeNamespace.equals("##default")) {
                // namespace is from the package
                typeNamespace = namespace;
            }
View Full Code Here

       * those Java beans as input to the JAXB mapping. */
      catch (NoSuchMethodException nsme)
      {
         /* For each getter in the exception and its superclasses, a property of
          * the same type and name is added to the bean. */
         XmlType xmlType = (XmlType)faultBean.getAnnotation(XmlType.class);
         if (xmlType == null)
            throw new WebServiceException("@XmlType missing from fault bean: " + faultBeanName);

         AccessorFactory accessorFactory = getAccessorFactory(faultBean);

         String[] propertyNames = xmlType.propOrder();
         int propertyCount = propertyNames.length;
         propertyTypes = new Class[propertyCount];
         faultBeanProperties = new WrappedParameter[propertyCount];
         serviceExceptionGetters = new Method[propertyCount];

View Full Code Here

       
        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
        if (root != null) {
            return getQNameFromNamespaceAndName(root.namespace(), root.name(), cls, pluralName);
        } else if (cls.getAnnotation(XmlType.class) != null) {
            XmlType xmlType = cls.getAnnotation(XmlType.class);
            return getQNameFromNamespaceAndName(xmlType.namespace(), xmlType.name(), cls, pluralName);
        } else {
            return new QName(getPackageNamespace(cls), cls.getSimpleName());
        }
    }
View Full Code Here

            //if doc-literal, the part element name should be used, but for RPC, the message part name
            try {
                Method faultMethod = ex.getClass().getMethod("getFaultInfo");
                if (faultMethod != null) {
                    Class<?> faultClass = faultMethod.getReturnType();
                    XmlType exType = faultClass.getAnnotation(XmlType.class);
                    exClassName = exType.name();
                    result = findRaisesType(exList, exClassName);
                }
            } catch (Exception exp) {
                //Ignore it
            }
View Full Code Here

       
        XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
        if (root != null) {
            return getQNameFromNamespaceAndName(root.namespace(), root.name(), cls, pluralName);
        } else if (cls.getAnnotation(XmlType.class) != null) {
            XmlType xmlType = cls.getAnnotation(XmlType.class);
            return getQNameFromNamespaceAndName(xmlType.namespace(), xmlType.name(), cls, pluralName);
        } else {
            return new QName(getPackageNamespace(cls), cls.getSimpleName());
        }
    }
View Full Code Here

            if (s.getNamespaceURI().equals(part.getElementQName().getNamespaceURI())) {
                schemaInfo = s;
                break;
            }
        }
        XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
        boolean respectXmlTypeNS = false;
        XmlSchema faultBeanSchema = null;
        if (xmlTypeAnno != null && !StringUtils.isEmpty(xmlTypeAnno.namespace())
            && !xmlTypeAnno.namespace().equals(part.getElementQName().getNamespaceURI())) {
            respectXmlTypeNS = true;
            NamespaceMap nsMap = new NamespaceMap();
            nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, xmlTypeAnno.namespace());
            nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
           
            SchemaInfo faultBeanSchemaInfo = createSchemaIfNeeded(xmlTypeAnno.namespace(), nsMap);
            faultBeanSchema = faultBeanSchemaInfo.getSchema();           
        }
       
        XmlSchema schema = null;
        if (schemaInfo == null) {
            NamespaceMap nsMap = new NamespaceMap();
            nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, part.getElementQName().getNamespaceURI());
            nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
            schemaInfo = createSchemaIfNeeded(part.getElementQName().getNamespaceURI(), nsMap);

        }
        schema = schemaInfo.getSchema();
      

        // Before updating everything, make sure we haven't added this
        // type yet.  Multiple methods that throw the same exception
        // types will cause duplicates.
        String faultTypeName = xmlTypeAnno != null && !StringUtils.isEmpty(xmlTypeAnno.name())
               ? xmlTypeAnno.name()  :  part.getElementQName().getLocalPart();
        XmlSchemaType existingType = schema.getTypeByName(faultTypeName);
        if (existingType != null) {
            return;
        }
View Full Code Here

                schemaInfo = s;
                break;
            }
        }
        XmlAccessorOrder xmlAccessorOrder = cls.getAnnotation(XmlAccessorOrder.class);
        XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
        String[] propertyOrder = null;
        boolean respectXmlTypeNS = false;
        XmlSchema faultBeanSchema = null;
        if (xmlTypeAnno != null && !StringUtils.isEmpty(xmlTypeAnno.namespace())
            && !xmlTypeAnno.namespace().equals(part.getElementQName().getNamespaceURI())) {
            respectXmlTypeNS = true;
            NamespaceMap nsMap = new NamespaceMap();
            nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, xmlTypeAnno.namespace());
            nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
           
            SchemaInfo faultBeanSchemaInfo = createSchemaIfNeeded(xmlTypeAnno.namespace(), nsMap);
            faultBeanSchema = faultBeanSchemaInfo.getSchema();
        }
       
        if (xmlTypeAnno != null &&  xmlTypeAnno.propOrder().length > 0) {
            propertyOrder = xmlTypeAnno.propOrder();
            //TODO: handle @XmlAccessOrder
        }
                       
        XmlSchema schema = null;
        if (schemaInfo == null) {
            NamespaceMap nsMap = new NamespaceMap();
            nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, part.getElementQName().getNamespaceURI());
            nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
            schemaInfo = createSchemaIfNeeded(part.getElementQName().getNamespaceURI(), nsMap);

        }
        schema = schemaInfo.getSchema();
      

        // Before updating everything, make sure we haven't added this
        // type yet.  Multiple methods that throw the same exception
        // types will cause duplicates.
        String faultTypeName = xmlTypeAnno != null && !StringUtils.isEmpty(xmlTypeAnno.name())
               ? xmlTypeAnno.name()  :  part.getElementQName().getLocalPart();
        XmlSchemaType existingType = schema.getTypeByName(faultTypeName);
        if (existingType != null) {
            return;
        }
View Full Code Here

        docBuilderFactory.setNamespaceAware(true);
    }

    private Element javaAttributes(Class<?> wrpCls, Map<String, Source> extMapping) {
        XmlRootElement xmlRootElement = wrpCls.getAnnotation(XmlRootElement.class);
        XmlType xmlType = wrpCls.getAnnotation(XmlType.class);
        Element xmlbindings = xmlbindings(wrpCls, extMapping);
        extMapping.put(wrpCls.getPackage().getName(), new DOMSource(xmlbindings));
        Element javatypes = child(xmlbindings, "java-types");
        Element javatype = null;
        NodeList javatypeList = xmlbindings.getElementsByTagNameNS(OXMTNS, "java-type");
        for (int i = 0; javatype == null && i < javatypeList.getLength(); i++) {
            Element e = (Element) javatypeList.item(i);
            if (wrpCls.getName().equals(e.getAttribute("name"))) {
                javatype = e;
            }
        }
        if (javatype == null) {
            javatype = javatypes.getOwnerDocument().createElementNS(OXMTNS, "java-type");
            javatype.setAttribute("name", wrpCls.getName());
            javatypes.appendChild(javatype);
            if (xmlRootElement != null) {
                Element r = javatype.getOwnerDocument().createElementNS(OXMTNS, "xml-root-element");
                r.setAttribute("name", xmlRootElement.name());
                r.setAttribute("namespace", xmlRootElement.namespace());
                javatype.appendChild(r);
            }
            if (xmlType != null) {
                Element r = javatype.getOwnerDocument().createElementNS(OXMTNS, "xml-type");
                r.setAttribute("name", xmlType.name());
                r.setAttribute("namespace", xmlType.namespace());
                StringBuilder propOrdr = new StringBuilder();
                if (xmlType.propOrder() != null) {
                    for (int pi = 0; pi < xmlType.propOrder().length; pi++) {
                        propOrdr.append(xmlType.propOrder()[pi]);
                        propOrdr.append(" ");
                    }
                }
                r.setAttribute("prop-order", propOrdr.toString().trim());
                javatype.appendChild(r);
View Full Code Here

    public static String getTagName(Class<?> handled) {
        if (TAG_NAMES.containsKey(handled)) {
            return TAG_NAMES.get(handled);
        }

        XmlType xmlType = handled.getAnnotation(XmlType.class);
        if (xmlType != null && xmlType.name() != null && xmlType.name().trim().length() > 0) {
            TAG_NAMES.put(handled, xmlType.name());
            return xmlType.name();
        } else {
            XmlRootElement xmlRoot = handled.getAnnotation(XmlRootElement.class);
            if (xmlRoot != null && xmlRoot.name() != null && xmlRoot.name().trim().length() > 0) {
                TAG_NAMES.put(handled, xmlRoot.name());
                return xmlRoot.name();
View Full Code Here

TOP

Related Classes of javax.xml.bind.annotation.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.