Search in sources :

Example 66 with Attribute

use of org.metatype.sxc.util.Attribute in project tomee by apache.

the class Method$JAXB method _read.

public static final Method _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Method method = new Method();
    context.beforeUnmarshal(method, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("methodType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Method.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, method);
            method.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbName
            final String ejbNameRaw = elementReader.getElementAsString();
            final String ejbName;
            try {
                ejbName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            method.ejbName = ejbName;
        } else if (("method-intf" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: methodIntf
            final MethodIntf methodIntf = parseMethodIntf(elementReader, context, elementReader.getElementAsString());
            if (methodIntf != null) {
                method.methodIntf = methodIntf;
            }
        } else if (("method-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: methodName
            final String methodNameRaw = elementReader.getElementAsString();
            final String methodName;
            try {
                methodName = Adapters.collapsedStringAdapterAdapter.unmarshal(methodNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            method.methodName = methodName;
        } else if (("method-params" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: methodParams
            final MethodParams methodParams = readMethodParams(elementReader, context);
            method.methodParams = methodParams;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-name"), new QName("http://java.sun.com/xml/ns/javaee", "method-intf"), new QName("http://java.sun.com/xml/ns/javaee", "method-name"), new QName("http://java.sun.com/xml/ns/javaee", "method-params"));
        }
    }
    if (descriptions != null) {
        try {
            method.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Method.class, "setDescriptions", Text[].class, e);
        }
    }
    context.afterUnmarshal(method, LifecycleCallback.NONE);
    return method;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) MethodParams$JAXB.writeMethodParams(org.apache.openejb.jee.MethodParams$JAXB.writeMethodParams) MethodParams$JAXB.readMethodParams(org.apache.openejb.jee.MethodParams$JAXB.readMethodParams) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) MethodIntf$JAXB.parseMethodIntf(org.apache.openejb.jee.MethodIntf$JAXB.parseMethodIntf) MethodIntf$JAXB.toStringMethodIntf(org.apache.openejb.jee.MethodIntf$JAXB.toStringMethodIntf) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 67 with Attribute

use of org.metatype.sxc.util.Attribute in project tomee by apache.

the class MethodPermission$JAXB method _read.

public static final MethodPermission _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final MethodPermission methodPermission = new MethodPermission();
    context.beforeUnmarshal(methodPermission, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<String> roleName = null;
    List<Method> method = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("method-permissionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, MethodPermission.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, methodPermission);
            methodPermission.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("role-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: roleName
            final String roleNameItemRaw = elementReader.getElementAsString();
            final String roleNameItem;
            try {
                roleNameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(roleNameItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (roleName == null) {
                roleName = methodPermission.roleName;
                if (roleName != null) {
                    roleName.clear();
                } else {
                    roleName = new ArrayList<String>();
                }
            }
            roleName.add(roleNameItem);
        } else if (("unchecked" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: unchecked
            final Empty unchecked = readEmpty(elementReader, context);
            methodPermission.unchecked = unchecked;
        } else if (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: method
            final Method methodItem = readMethod(elementReader, context);
            if (method == null) {
                method = methodPermission.method;
                if (method != null) {
                    method.clear();
                } else {
                    method = new ArrayList<Method>();
                }
            }
            method.add(methodItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "role-name"), new QName("http://java.sun.com/xml/ns/javaee", "unchecked"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
        }
    }
    if (descriptions != null) {
        try {
            methodPermission.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, MethodPermission.class, "setDescriptions", Text[].class, e);
        }
    }
    if (roleName != null) {
        methodPermission.roleName = roleName;
    }
    if (method != null) {
        methodPermission.method = method;
    }
    context.afterUnmarshal(methodPermission, LifecycleCallback.NONE);
    return methodPermission;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Method$JAXB.readMethod(org.apache.openejb.jee.Method$JAXB.readMethod) Method$JAXB.writeMethod(org.apache.openejb.jee.Method$JAXB.writeMethod) Empty$JAXB.writeEmpty(org.apache.openejb.jee.Empty$JAXB.writeEmpty) Empty$JAXB.readEmpty(org.apache.openejb.jee.Empty$JAXB.readEmpty) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 68 with Attribute

use of org.metatype.sxc.util.Attribute in project tomee by apache.

the class MultipartConfig$JAXB method _read.

public static final MultipartConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final MultipartConfig multipartConfig = new MultipartConfig();
    context.beforeUnmarshal(multipartConfig, LifecycleCallback.NONE);
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("multipart-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, MultipartConfig.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute);
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("location" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: location
            final String locationRaw = elementReader.getElementAsString();
            final String location;
            try {
                location = Adapters.collapsedStringAdapterAdapter.unmarshal(locationRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            multipartConfig.location = location;
        } else if (("max-file-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: maxFileSize
            final Long maxFileSize = Long.valueOf(elementReader.getElementAsString());
            multipartConfig.maxFileSize = maxFileSize;
        } else if (("max-request-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: maxRequestSize
            final Long maxRequestSize = Long.valueOf(elementReader.getElementAsString());
            multipartConfig.maxRequestSize = maxRequestSize;
        } else if (("file-size-threshold" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: fileSizeThreshold
            final Integer fileSizeThreshold = Integer.valueOf(elementReader.getElementAsString());
            multipartConfig.fileSizeThreshold = fileSizeThreshold;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "location"), new QName("http://java.sun.com/xml/ns/javaee", "max-file-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-request-size"), new QName("http://java.sun.com/xml/ns/javaee", "file-size-threshold"));
        }
    }
    context.afterUnmarshal(multipartConfig, LifecycleCallback.NONE);
    return multipartConfig;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 69 with Attribute

use of org.metatype.sxc.util.Attribute in project tomee by apache.

the class PersistenceContextRef$JAXB method _read.

public static final PersistenceContextRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final PersistenceContextRef persistenceContextRef = new PersistenceContextRef();
    context.beforeUnmarshal(persistenceContextRef, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Property> persistenceProperty = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("persistence-context-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, PersistenceContextRef.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, persistenceContextRef);
            persistenceContextRef.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("persistence-context-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceContextRefName
            final String persistenceContextRefNameRaw = elementReader.getElementAsString();
            final String persistenceContextRefName;
            try {
                persistenceContextRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceContextRefNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceContextRef.persistenceContextRefName = persistenceContextRefName;
        } else if (("persistence-unit-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceUnitName
            final String persistenceUnitNameRaw = elementReader.getElementAsString();
            final String persistenceUnitName;
            try {
                persistenceUnitName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceContextRef.persistenceUnitName = persistenceUnitName;
        } else if (("persistence-context-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceContextType
            final PersistenceContextType persistenceContextType = parsePersistenceContextType(elementReader, context, elementReader.getElementAsString());
            if (persistenceContextType != null) {
                persistenceContextRef.persistenceContextType = persistenceContextType;
            }
        } else if (("persistence-context-synchronization" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceContextType
            final PersistenceContextSynchronization synchronization = parsePersistenceContextSynchronization(elementReader, context, elementReader.getElementAsString());
            if (synchronization != null) {
                persistenceContextRef.persistenceContextSynchronization = synchronization;
            }
        } else if (("persistence-property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceProperty
            final Property persistencePropertyItem = readProperty(elementReader, context);
            if (persistenceProperty == null) {
                persistenceProperty = persistenceContextRef.persistenceProperty;
                if (persistenceProperty != null) {
                    persistenceProperty.clear();
                } else {
                    persistenceProperty = new ArrayList<Property>();
                }
            }
            persistenceProperty.add(persistencePropertyItem);
        } else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mappedName
            final String mappedNameRaw = elementReader.getElementAsString();
            final String mappedName;
            try {
                mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceContextRef.mappedName = mappedName;
        } else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: injectionTarget
            final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
            if (injectionTarget == null) {
                injectionTarget = persistenceContextRef.injectionTarget;
                if (injectionTarget != null) {
                    injectionTarget.clear();
                } else {
                    injectionTarget = new LinkedHashSet<InjectionTarget>();
                }
            }
            injectionTarget.add(injectionTargetItem);
        } else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lookupName
            final String lookupNameRaw = elementReader.getElementAsString();
            final String lookupName;
            try {
                lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceContextRef.lookupName = lookupName;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-type"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-property"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
        }
    }
    if (descriptions != null) {
        try {
            persistenceContextRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, PersistenceContextRef.class, "setDescriptions", Text[].class, e);
        }
    }
    if (persistenceProperty != null) {
        persistenceContextRef.persistenceProperty = persistenceProperty;
    }
    if (injectionTarget != null) {
        persistenceContextRef.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(persistenceContextRef, LifecycleCallback.NONE);
    return persistenceContextRef;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PersistenceContextType$JAXB.parsePersistenceContextType(org.apache.openejb.jee.PersistenceContextType$JAXB.parsePersistenceContextType) PersistenceContextType$JAXB.toStringPersistenceContextType(org.apache.openejb.jee.PersistenceContextType$JAXB.toStringPersistenceContextType) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) Property$JAXB.writeProperty(org.apache.openejb.jee.Property$JAXB.writeProperty) Property$JAXB.readProperty(org.apache.openejb.jee.Property$JAXB.readProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 70 with Attribute

use of org.metatype.sxc.util.Attribute in project tomee by apache.

the class PersistenceUnitRef$JAXB method _read.

public static final PersistenceUnitRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final PersistenceUnitRef persistenceUnitRef = new PersistenceUnitRef();
    context.beforeUnmarshal(persistenceUnitRef, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("persistence-unit-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, PersistenceUnitRef.class);
        }
    }
    // Read attributes
    for (final Attribute attribute : reader.getAttributes()) {
        if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: id
            final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
            context.addXmlId(reader, id, persistenceUnitRef);
            persistenceUnitRef.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("persistence-unit-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceUnitRefName
            final String persistenceUnitRefNameRaw = elementReader.getElementAsString();
            final String persistenceUnitRefName;
            try {
                persistenceUnitRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitRefNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceUnitRef.persistenceUnitRefName = persistenceUnitRefName;
        } else if (("persistence-unit-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceUnitName
            final String persistenceUnitNameRaw = elementReader.getElementAsString();
            final String persistenceUnitName;
            try {
                persistenceUnitName = Adapters.collapsedStringAdapterAdapter.unmarshal(persistenceUnitNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceUnitRef.persistenceUnitName = persistenceUnitName;
        } else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mappedName
            final String mappedNameRaw = elementReader.getElementAsString();
            final String mappedName;
            try {
                mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceUnitRef.mappedName = mappedName;
        } else if (("injection-target" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: injectionTarget
            final InjectionTarget injectionTargetItem = readInjectionTarget(elementReader, context);
            if (injectionTarget == null) {
                injectionTarget = persistenceUnitRef.injectionTarget;
                if (injectionTarget != null) {
                    injectionTarget.clear();
                } else {
                    injectionTarget = new LinkedHashSet<InjectionTarget>();
                }
            }
            injectionTarget.add(injectionTargetItem);
        } else if (("lookup-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: lookupName
            final String lookupNameRaw = elementReader.getElementAsString();
            final String lookupName;
            try {
                lookupName = Adapters.collapsedStringAdapterAdapter.unmarshal(lookupNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            persistenceUnitRef.lookupName = lookupName;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-name"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "injection-target"), new QName("http://java.sun.com/xml/ns/javaee", "lookup-name"));
        }
    }
    if (descriptions != null) {
        try {
            persistenceUnitRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, PersistenceUnitRef.class, "setDescriptions", Text[].class, e);
        }
    }
    if (injectionTarget != null) {
        persistenceUnitRef.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(persistenceUnitRef, LifecycleCallback.NONE);
    return persistenceUnitRef;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

QName (javax.xml.namespace.QName)190 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)190 Attribute (org.metatype.sxc.util.Attribute)190 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)182 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)116 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)78 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)77 ArrayList (java.util.ArrayList)69 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)37 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)37 JAXBObject (org.metatype.sxc.jaxb.JAXBObject)18 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)9 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)9 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)7 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)7 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)7 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)7 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)7 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)7 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)7