Search in sources :

Example 16 with XmlRootElement

use of javax.xml.bind.annotation.XmlRootElement in project jbossws-cxf by jbossws.

the class WSProviderPlugin method testOutputDirectory.

/**
 * Sets the main output directory.
 * If the directory does not exist, it will be created.
 */
public void testOutputDirectory() throws Exception {
    provide();
    ClassLoader loader = getArtefactClassLoader();
    Class<?> responseWrapper = loader.loadClass("org.jboss.test.ws.jaxws.smoke.tools.jaxws.AddResponse");
    XmlRootElement rootElement = (XmlRootElement) responseWrapper.getAnnotation(XmlRootElement.class);
    assertNotNull("@XmlRootElement missing from response wrapper", rootElement);
    assertEquals("Wrong namespace", rootElement.namespace(), "http://foo.bar.com/calculator");
    responseWrapper = loader.loadClass("org.jboss.test.ws.jaxws.smoke.tools.jaxws.ProcessListResponse");
    XmlList xmlList = (XmlList) responseWrapper.getDeclaredField("_return").getAnnotation(XmlList.class);
    assertNotNull("@XmlList missing from response wrapper's _return field", xmlList);
    responseWrapper = loader.loadClass("org.jboss.test.ws.jaxws.smoke.tools.jaxws.ProcessCustomResponse");
    XmlJavaTypeAdapter xmlJavaTypeAdapter = (XmlJavaTypeAdapter) responseWrapper.getDeclaredField("_return").getAnnotation(XmlJavaTypeAdapter.class);
    assertNotNull("@XmlJavaTypeAdapter missing from response wrapper's _return field", xmlJavaTypeAdapter);
    assertEquals("org.jboss.test.ws.jaxws.smoke.tools.CustomAdapter", xmlJavaTypeAdapter.value().getName());
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) URLClassLoader(java.net.URLClassLoader) XmlList(javax.xml.bind.annotation.XmlList)

Example 17 with XmlRootElement

use of javax.xml.bind.annotation.XmlRootElement in project ibas-framework by color-coding.

the class SerializerXml method createSchemaElement.

protected void createSchemaElement(Document document, Class<?> type) {
    Element element = this.createSchemaElement(document, type, "" + type.getSimpleName(), true);
    XmlRootElement annotation = type.getAnnotation(XmlRootElement.class);
    if (annotation != null) {
        document.getDocumentElement().setAttribute("targetNamespace", annotation.namespace());
    }
    document.getDocumentElement().appendChild(element);
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) Element(org.w3c.dom.Element)

Example 18 with XmlRootElement

use of javax.xml.bind.annotation.XmlRootElement in project zm-mailbox by Zimbra.

the class JaxbInfo method getRootElementNamespace.

public static String getRootElementNamespace(Class<?> kls) {
    String namespace = null;
    if (kls == null) {
        return null;
    }
    XmlRootElement re = kls.getAnnotation(XmlRootElement.class);
    if (re != null) {
        namespace = re.namespace();
    }
    return namespace;
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement)

Example 19 with XmlRootElement

use of javax.xml.bind.annotation.XmlRootElement in project zm-mailbox by Zimbra.

the class JaxbInfo method getRootElementName.

public static String getRootElementName(Class<?> kls) {
    String name;
    if (kls == null) {
        return null;
    }
    XmlRootElement re = kls.getAnnotation(XmlRootElement.class);
    if (re != null) {
        name = re.name();
    } else {
        name = kls.getName();
        int lastDot = name.lastIndexOf('.');
        if (lastDot >= 0) {
            name = name.substring(lastDot + 1);
        }
    }
    return name;
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement)

Example 20 with XmlRootElement

use of javax.xml.bind.annotation.XmlRootElement in project platformlayer by platformlayer.

the class XmlHelper method getXmlElementInfo.

public static ElementInfo getXmlElementInfo(Class<?> clazz) {
    String elementName = null;
    String namespace = null;
    XmlType xmlType = clazz.getAnnotation(XmlType.class);
    if (xmlType != null) {
        elementName = xmlType.name();
        namespace = xmlType.namespace();
    } else {
        XmlRootElement xmlRootElement = clazz.getAnnotation(XmlRootElement.class);
        if (xmlRootElement != null) {
            elementName = xmlRootElement.name();
            namespace = xmlRootElement.namespace();
        }
    }
    if ("##default".equals(elementName)) {
        elementName = StringUtils.uncapitalize(clazz.getSimpleName());
    }
    if ("##default".equals(namespace)) {
        namespace = null;
    }
    if (namespace == null) {
        Package itemPackage = clazz.getPackage();
        XmlSchema xmlSchema = itemPackage.getAnnotation(XmlSchema.class);
        if (xmlSchema != null) {
            namespace = getXmlNamespace(xmlSchema);
        }
    }
    if (elementName != null && namespace != null) {
        return new ElementInfo(namespace, elementName);
    }
    return null;
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) XmlSchema(javax.xml.bind.annotation.XmlSchema) XmlType(javax.xml.bind.annotation.XmlType)

Aggregations

XmlRootElement (javax.xml.bind.annotation.XmlRootElement)39 XmlSchema (javax.xml.bind.annotation.XmlSchema)11 XmlType (javax.xml.bind.annotation.XmlType)9 QName (javax.xml.namespace.QName)9 LinkedHashSet (java.util.LinkedHashSet)6 TreeSet (java.util.TreeSet)6 TypeElement (javax.lang.model.element.TypeElement)6 AnnotationProcessorHelper.findTypeElement (org.apache.camel.tools.apt.AnnotationProcessorHelper.findTypeElement)6 Method (java.lang.reflect.Method)5 TypeMirror (javax.lang.model.type.TypeMirror)5 Elements (javax.lang.model.util.Elements)5 XmlElements (javax.xml.bind.annotation.XmlElements)5 Metadata (org.apache.camel.spi.Metadata)5 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 XmlAccessorType (javax.xml.bind.annotation.XmlAccessorType)3 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)2 JsonTypeInfo (com.fasterxml.jackson.annotation.JsonTypeInfo)2 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)2