import org.apache.cxf.tools.common.model.JavaAnnotatable;
import org.apache.cxf.tools.java2wsdl.generator.wsdl11.model.WrapperBeanClass;
public class WrapperBeanAnnotator implements Annotator {
public void annotate(final JavaAnnotatable clz) {
WrapperBeanClass beanClass = null;
if (clz instanceof WrapperBeanClass) {
beanClass = (WrapperBeanClass) clz;
} else {
throw new RuntimeException("WrapperBeanAnnotator expect JavaClass as input");
}
JAnnotation xmlRootElement = new JAnnotation(XmlRootElement.class);
xmlRootElement.addElement(new JAnnotationElement("name",
beanClass.getElementName().getLocalPart()));
xmlRootElement.addElement(new JAnnotationElement("namespace",
beanClass.getElementName().getNamespaceURI()));
JAnnotation xmlAccessorType = new JAnnotation(XmlAccessorType.class);
xmlAccessorType.addElement(new JAnnotationElement(null, XmlAccessType.FIELD));
JAnnotation xmlType = new JAnnotation(XmlType.class);
xmlType.addElement(new JAnnotationElement("name",
beanClass.getElementName().getLocalPart()));
xmlType.addElement(new JAnnotationElement("namespace",
beanClass.getElementName().getNamespaceURI()));
// Revisit: why annotation is string?
beanClass.addAnnotation(xmlRootElement);
beanClass.addAnnotation(xmlAccessorType);
beanClass.addAnnotation(xmlType);
}