Search in sources :

Example 1 with XmlAccessorOrder

use of jakarta.xml.bind.annotation.XmlAccessorOrder in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method preProcessXmlAccessorOrder.

/**
 * Process package and class @XmlAccessorOrder. Class level annotation
 * overrides a package level annotation.
 */
private void preProcessXmlAccessorOrder(JavaClass javaClass, TypeInfo info, NamespaceInfo packageNamespace) {
    XmlAccessorOrder order = null;
    // class level annotation overrides package level annotation
    if (helper.isAnnotationPresent(javaClass, XmlAccessorOrder.class)) {
        order = (XmlAccessorOrder) helper.getAnnotation(javaClass, XmlAccessorOrder.class);
        info.setXmlAccessOrder(XmlAccessOrder.fromValue(order.value().name()));
    }
}
Also used : XmlAccessorOrder(jakarta.xml.bind.annotation.XmlAccessorOrder)

Example 2 with XmlAccessorOrder

use of jakarta.xml.bind.annotation.XmlAccessorOrder in project eclipselink by eclipse-ee4j.

the class AnnotationsProcessor method getPackageInfoForPackage.

public PackageInfo getPackageInfoForPackage(JavaPackage pack, String packageName) {
    PackageInfo packageInfo = packageToPackageInfoMappings.get(packageName);
    if (packageInfo == null) {
        XmlSchema xmlSchema = (XmlSchema) helper.getAnnotation(pack, XmlSchema.class);
        packageInfo = new PackageInfo();
        NamespaceInfo namespaceInfo = processNamespaceInformation(xmlSchema);
        packageInfo.setNamespaceInfo(namespaceInfo);
        // if it's still null, generate based on package name
        if (namespaceInfo.getNamespace() == null) {
            namespaceInfo.setNamespace(EMPTY_STRING);
        }
        if (helper.isAnnotationPresent(pack, XmlAccessorType.class)) {
            XmlAccessorType xmlAccessorType = (XmlAccessorType) helper.getAnnotation(pack, XmlAccessorType.class);
            packageInfo.setAccessType(XmlAccessType.fromValue(xmlAccessorType.value().name()));
        }
        if (helper.isAnnotationPresent(pack, XmlAccessorOrder.class)) {
            XmlAccessorOrder xmlAccessorOrder = (XmlAccessorOrder) helper.getAnnotation(pack, XmlAccessorOrder.class);
            packageInfo.setAccessOrder(XmlAccessOrder.fromValue(xmlAccessorOrder.value().name()));
        }
        if (CompilerHelper.ACCESSOR_FACTORY_ANNOTATION_CLASS != null && helper.isAnnotationPresent(pack, CompilerHelper.ACCESSOR_FACTORY_ANNOTATION_CLASS)) {
            Annotation xmlAccessorFactory = helper.getAnnotation(pack, CompilerHelper.ACCESSOR_FACTORY_ANNOTATION_CLASS);
            Class<?> xmlAccessorFactoryClass = null;
            try {
                xmlAccessorFactoryClass = PrivilegedAccessHelper.invokeMethod(CompilerHelper.ACCESSOR_FACTORY_VALUE_METHOD, xmlAccessorFactory, new Object[] {});
                packageInfo.setAccessorFactory(new AccessorFactoryWrapper(PrivilegedAccessHelper.newInstanceFromClass(xmlAccessorFactoryClass)));
            } catch (Exception ex) {
                throw JAXBException.errorInstantiatingAccessorFactory(xmlAccessorFactoryClass, ex);
            }
        } else if (CompilerHelper.OLD_ACCESSOR_FACTORY_ANNOTATION_CLASS != null && helper.isAnnotationPresent(pack, CompilerHelper.OLD_ACCESSOR_FACTORY_ANNOTATION_CLASS)) {
            Annotation xmlAccessorFactory = helper.getAnnotation(pack, CompilerHelper.OLD_ACCESSOR_FACTORY_ANNOTATION_CLASS);
            Class<?> xmlAccessorFactoryClass = null;
            try {
                xmlAccessorFactoryClass = PrivilegedAccessHelper.invokeMethod(CompilerHelper.OLD_ACCESSOR_FACTORY_VALUE_METHOD, xmlAccessorFactory, new Object[] {});
                packageInfo.setAccessorFactory(new AccessorFactoryWrapper(PrivilegedAccessHelper.newInstanceFromClass(xmlAccessorFactoryClass)));
            } catch (Exception ex) {
                throw JAXBException.errorInstantiatingAccessorFactory(xmlAccessorFactoryClass, ex);
            }
        } else if (CompilerHelper.INTERNAL_ACCESSOR_FACTORY_ANNOTATION_CLASS != null && helper.isAnnotationPresent(pack, CompilerHelper.INTERNAL_ACCESSOR_FACTORY_ANNOTATION_CLASS)) {
            Annotation xmlAccessorFactory = helper.getAnnotation(pack, CompilerHelper.INTERNAL_ACCESSOR_FACTORY_ANNOTATION_CLASS);
            Class<?> xmlAccessorFactoryClass = null;
            try {
                xmlAccessorFactoryClass = PrivilegedAccessHelper.invokeMethod(CompilerHelper.INTERNAL_ACCESSOR_FACTORY_VALUE_METHOD, xmlAccessorFactory, new Object[] {});
                packageInfo.setAccessorFactory(new AccessorFactoryWrapper(PrivilegedAccessHelper.newInstanceFromClass(xmlAccessorFactoryClass)));
            } catch (Exception ex) {
                throw JAXBException.errorInstantiatingAccessorFactory(xmlAccessorFactoryClass, ex);
            }
        }
        packageToPackageInfoMappings.put(packageName, packageInfo);
    }
    return packageInfo;
}
Also used : XmlAccessorOrder(jakarta.xml.bind.annotation.XmlAccessorOrder) XmlSchema(jakarta.xml.bind.annotation.XmlSchema) AccessorFactoryWrapper(org.eclipse.persistence.internal.jaxb.AccessorFactoryWrapper) XmlAccessorType(jakarta.xml.bind.annotation.XmlAccessorType) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass) JavaAnnotation(org.eclipse.persistence.jaxb.javamodel.JavaAnnotation) Annotation(java.lang.annotation.Annotation) InvocationTargetException(java.lang.reflect.InvocationTargetException) JAXBException(org.eclipse.persistence.exceptions.JAXBException) ConversionException(org.eclipse.persistence.exceptions.ConversionException)

Aggregations

XmlAccessorOrder (jakarta.xml.bind.annotation.XmlAccessorOrder)2 XmlAccessorType (jakarta.xml.bind.annotation.XmlAccessorType)1 XmlSchema (jakarta.xml.bind.annotation.XmlSchema)1 Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConversionException (org.eclipse.persistence.exceptions.ConversionException)1 JAXBException (org.eclipse.persistence.exceptions.JAXBException)1 AccessorFactoryWrapper (org.eclipse.persistence.internal.jaxb.AccessorFactoryWrapper)1 JavaAnnotation (org.eclipse.persistence.jaxb.javamodel.JavaAnnotation)1 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)1