use of javax.xml.bind.annotation.XmlMimeType in project cxf by apache.
the class ReflectionServiceFactoryBean method addMimeType.
private void addMimeType(final XmlSchemaElement element, final Annotation[] annotations) {
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation instanceof XmlMimeType) {
MimeAttribute attr = new MimeAttribute();
attr.setValue(((XmlMimeType) annotation).value());
element.addMetaInfo(MimeAttribute.MIME_QNAME, attr);
}
}
}
}
use of javax.xml.bind.annotation.XmlMimeType in project cxf by apache.
the class WrapperBeanFieldAnnotator method annotate.
public void annotate(final JavaAnnotatable field) {
JavaField jField = null;
if (field instanceof JavaField) {
jField = (JavaField) field;
} else {
throw new RuntimeException("WrapperBeanFiledAnnotator expect JavaField as input");
}
String rawName = jField.getRawName();
boolean hasEl = false;
for (Annotation ann : jField.getJaxbAnnotaions()) {
if (ann instanceof XmlMimeType) {
JAnnotation mimeAnno = new JAnnotation(XmlMimeType.class);
mimeAnno.addElement(new JAnnotationElement("value", ((XmlMimeType) ann).value()));
jField.addAnnotation(mimeAnno);
} else if (ann instanceof XmlJavaTypeAdapter) {
JAnnotation jaxbAnn = new JAnnotation(XmlJavaTypeAdapter.class);
jaxbAnn.addElement(new JAnnotationElement("value", ((XmlJavaTypeAdapter) ann).value()));
jaxbAnn.addElement(new JAnnotationElement("type", ((XmlJavaTypeAdapter) ann).type()));
jField.addAnnotation(jaxbAnn);
} else if (ann instanceof XmlAttachmentRef) {
JAnnotation jaxbAnn = new JAnnotation(XmlAttachmentRef.class);
jField.addAnnotation(jaxbAnn);
} else if (ann instanceof XmlList) {
JAnnotation jaxbAnn = new JAnnotation(XmlList.class);
jField.addAnnotation(jaxbAnn);
} else if (ann instanceof XmlElement) {
hasEl = true;
XmlElement el = (XmlElement) ann;
JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
xmlElementAnnotation.addElement(new JAnnotationElement("name", el.name()));
if (!StringUtils.isEmpty(el.namespace())) {
xmlElementAnnotation.addElement(new JAnnotationElement("namespace", el.namespace()));
}
if (el.nillable()) {
xmlElementAnnotation.addElement(new JAnnotationElement("nillable", el.nillable(), true));
}
if (el.required()) {
xmlElementAnnotation.addElement(new JAnnotationElement("required", el.required(), true));
}
if (!StringUtils.isEmpty(el.defaultValue())) {
xmlElementAnnotation.addElement(new JAnnotationElement("defaultValue", el.defaultValue()));
}
jField.addAnnotation(xmlElementAnnotation);
}
}
if (!hasEl) {
JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
xmlElementAnnotation.addElement(new JAnnotationElement("name", rawName));
if (!StringUtils.isEmpty(jField.getTargetNamespace())) {
xmlElementAnnotation.addElement(new JAnnotationElement("namespace", jField.getTargetNamespace()));
}
jField.addAnnotation(xmlElementAnnotation);
}
}
use of javax.xml.bind.annotation.XmlMimeType in project jbossws-cxf by jbossws.
the class SOAP11EndpointBean method namespace.
@XmlMimeType("text/plain")
public DataHandler namespace(@XmlMimeType("text/plain") DataHandler data) {
try {
String name = (String) getContent(data);
String type = (String) data.getContentType();
log.info("User " + name + " requested namespace with content type [" + type + "]");
return new DataHandler("Hello " + name, "text/plain");
} catch (IOException e) {
throw new WebServiceException(e);
}
}
use of javax.xml.bind.annotation.XmlMimeType in project jbossws-cxf by jbossws.
the class SOAP12EndpointBean method namespace.
@XmlMimeType("text/plain")
public DataHandler namespace(@XmlMimeType("text/plain") DataHandler data) {
try {
String name = (String) getContent(data);
String type = (String) data.getContentType();
log.info("User " + name + " requested namespace with content type [" + type + "]");
return new DataHandler("Hello " + name, "text/plain");
} catch (IOException e) {
throw new WebServiceException(e);
}
}
use of javax.xml.bind.annotation.XmlMimeType in project jbossws-cxf by jbossws.
the class EndpointBean method namespace.
@XmlMimeType("text/plain")
public DataHandler namespace(@XmlMimeType("text/plain") DataHandler data) {
try {
String name = (String) getContent(data);
String type = (String) data.getContentType();
log.info("User " + name + " requested namespace with content type [" + type + "]");
return new DataHandler("Hello " + name, "text/plain");
} catch (IOException e) {
throw new WebServiceException(e);
}
}
Aggregations