Search in sources :

Example 1 with XmlJavaTypeAdapters

use of javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters in project cxf by apache.

the class WrapperClassGenerator method generatePackageInfo.

private void generatePackageInfo(String className, String ns, Class<?> clz) {
    ClassWriter cw = createClassWriter();
    String classFileName = periodToSlashes(className);
    cw.visit(Opcodes.V1_5, Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE, classFileName, null, "java/lang/Object", null);
    boolean q = qualified;
    SchemaInfo si = interfaceInfo.getService().getSchema(ns);
    if (si != null) {
        q = si.isElementFormQualified();
    }
    AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true);
    av0.visit("namespace", ns);
    av0.visitEnum("elementFormDefault", getClassCode(XmlNsForm.class), q ? "QUALIFIED" : "UNQUALIFIED");
    av0.visitEnd();
    if (clz.getPackage() != null && clz.getPackage().getAnnotations() != null) {
        for (Annotation ann : clz.getPackage().getAnnotations()) {
            if (ann instanceof XmlJavaTypeAdapters) {
                av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapters;", true);
                generateXmlJavaTypeAdapters(av0, (XmlJavaTypeAdapters) ann);
                av0.visitEnd();
            } else if (ann instanceof XmlJavaTypeAdapter) {
                av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
                generateXmlJavaTypeAdapter(av0, (XmlJavaTypeAdapter) ann);
                av0.visitEnd();
            }
        }
    }
    cw.visitEnd();
    loadClass(className, clz, cw.toByteArray());
}
Also used : XmlNsForm(javax.xml.bind.annotation.XmlNsForm) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) XmlJavaTypeAdapters(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters) Annotation(java.lang.annotation.Annotation) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Aggregations

Annotation (java.lang.annotation.Annotation)1 XmlNsForm (javax.xml.bind.annotation.XmlNsForm)1 XmlJavaTypeAdapter (javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter)1 XmlJavaTypeAdapters (javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters)1 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)1