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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations