Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlType


        }

        public QName resolve(Class<?> type, Annotation[] annotations, Map<Class<?>, QName> clsMap) {
            QName qname = WadlGenerator.this.getJaxbQName(proxy, type, clsMap);
            if (qname == null && supportJaxbXmlType) {
                XmlType root = type.getAnnotation(XmlType.class);
                if (root != null) {
                    XMLName name = AnnotationUtils.getAnnotation(annotations, XMLName.class);
                    if (name == null) {
                        qname = getJaxbQName(root.name(), root.namespace(), type, clsMap);
                    } else {
                        QName tempQName = JAXRSUtils.convertStringToQName(name.value());
                        qname = new QName(tempQName.getNamespaceURI(),
                                          tempQName.getLocalPart(),
                                          getPrefix(tempQName.getNamespaceURI(), clsMap));
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

       
        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

    private static final String DEFAULT_NS = "##default";

    @Override
    public QName findQNameForSoapActionOrType(String soapAction, Class<?> type) {
        XmlType xmlType = type.getAnnotation(XmlType.class);
        if (xmlType == null || xmlType.name() == null) {
            throw new RuntimeException("The type " + type.getName() + " needs to have an XmlType annotation with name");
        }
        // prefer name+ns from the XmlRootElement, and fallback to XmlType
        String localName = null;
        String nameSpace = null;

        XmlRootElement root = type.getAnnotation(XmlRootElement.class);
        if (root != null) {
            localName = ObjectHelper.isEmpty(localName) ? root.name() : localName;
            nameSpace = isInValidNamespace(nameSpace) ? root.namespace() : nameSpace;
        }

        if (ObjectHelper.isEmpty(localName)) {
            localName = xmlType.name();
        }

        if (isInValidNamespace(nameSpace)) {
            XmlSchema xmlSchema = type.getPackage().getAnnotation(XmlSchema.class);
            if (xmlSchema != null) {
                nameSpace = xmlSchema.namespace();
            }
        }

        if (isInValidNamespace(nameSpace)) {
            nameSpace = xmlType.namespace();
        }

        if (ObjectHelper.isEmpty(localName) || isInValidNamespace(nameSpace)) {
            throw new IllegalStateException("Unable to determine localName or namespace for type <" + type.getName() + ">");
        }
View Full Code Here

    public void setChild(JAXBElement<?> wrapper, int i, ElementInfo childElement, Object value) {
        Object wrapperValue = wrapper.getValue();
        Class<?> wrapperClass = wrapperValue.getClass();

        XmlType xmlType = wrapperClass.getAnnotation(XmlType.class);
        String[] properties = xmlType.propOrder();
        String property = properties[i];

        try {
            for (Method m : wrapperClass.getMethods()) {
                if (m.getName().equals("set" + capitalize(property))) {
View Full Code Here

     */
    public List getChildren(JAXBElement<?> wrapper, List<ElementInfo> childElements, TransformationContext context) {
        Object wrapperValue = wrapper.getValue();
        Class<?> wrapperClass = wrapperValue.getClass();

        XmlType xmlType = wrapperClass.getAnnotation(XmlType.class);
        String[] properties = xmlType.propOrder();
        List<Object> elements = new ArrayList<Object>();
        for (String p : properties) {
            try {
                Method method = wrapperClass.getMethod("get" + capitalize(p), (Class[])null);
                Object value = method.invoke(wrapperValue, (Object[])null);
View Full Code Here

            XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
            if (schema != null) {
                namespace = schema.namespace();
            }
        }
        XmlType type = javaType.getAnnotation(XmlType.class);
        if (type != null) {
            String typeNamespace = type.namespace();
            String typeName = type.name();

            if (typeNamespace.equals("##default") && typeName.equals("")) {
                XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
                if (rootElement != null) {
                    namespace = rootElement.namespace();
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

                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

        for( Class<?> xmlTypeClass : xmlTypeClasses ) {
            if( !xmlTypeClass.getPackage().getName().startsWith("org.kie.remote.services.sei") ) {
                continue;
            }
            String className = xmlTypeClass.getSimpleName();
            XmlType xmlTypeAnno = xmlTypeClass.getAnnotation(XmlType.class);
            assertEquals("Name property inequal for " + className, className, xmlTypeAnno.name());
            Set<String> properties = new HashSet<String>(Arrays.asList(xmlTypeAnno.propOrder()));
            Set<String> fields = new HashSet<String>();
            for( Field field : xmlTypeClass.getFields() ) {
                String fieldName = field.getName();
                assertTrue(fieldName + " not present in XmlType propOrder value in " + className, properties.contains(fieldName));
                fields.add(fieldName);
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.