Search in sources :

Example 91 with XoXMLStreamReader

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

the class TldTaglib$JAXB method _read.

public static final TldTaglib _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final TldTaglib tldTaglib = new TldTaglib();
    context.beforeUnmarshal(tldTaglib, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<Listener> listener = null;
    List<Tag> tag = null;
    List<TagFile> tagFile = null;
    List<Function> function = null;
    List<TldExtension> taglibExtension = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("tldTaglibType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, TldTaglib.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, tldTaglib);
            tldTaglib.id = id;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            tldTaglib.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"));
        }
    }
    // 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 (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: displayNames
            final Text displayNamesItem = readText(elementReader, context);
            if (displayNames == null) {
                displayNames = new ArrayList<Text>();
            }
            displayNames.add(displayNamesItem);
        } else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: icon
            final Icon iconItem = readIcon(elementReader, context);
            if (icon == null) {
                icon = tldTaglib.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("tlib-version" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: tlibVersion
            final String tlibVersionRaw = elementReader.getElementAsString();
            final String tlibVersion;
            try {
                tlibVersion = Adapters.collapsedStringAdapterAdapter.unmarshal(tlibVersionRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldTaglib.tlibVersion = tlibVersion;
        } else if (("jsp-version" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: jspVersion
            final String jspVersionRaw = elementReader.getElementAsString();
            final String jspVersion;
            try {
                jspVersion = Adapters.collapsedStringAdapterAdapter.unmarshal(jspVersionRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldTaglib.jspVersion = jspVersion;
        } else if (("short-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: shortName
            final String shortNameRaw = elementReader.getElementAsString();
            final String shortName;
            try {
                shortName = Adapters.collapsedStringAdapterAdapter.unmarshal(shortNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldTaglib.shortName = shortName;
        } else if (("uri" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: uri
            final String uriRaw = elementReader.getElementAsString();
            final String uri;
            try {
                uri = Adapters.collapsedStringAdapterAdapter.unmarshal(uriRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            tldTaglib.uri = uri;
        } else if (("validator" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validator
            final Validator validator = readValidator(elementReader, context);
            tldTaglib.validator = validator;
        } else if (("listener" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: listener
            final Listener listenerItem = readListener(elementReader, context);
            if (listener == null) {
                listener = tldTaglib.listener;
                if (listener != null) {
                    listener.clear();
                } else {
                    listener = new ArrayList<Listener>();
                }
            }
            listener.add(listenerItem);
        } else if (("tag" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: tag
            final Tag tagItem = readTag(elementReader, context);
            if (tag == null) {
                tag = tldTaglib.tag;
                if (tag != null) {
                    tag.clear();
                } else {
                    tag = new ArrayList<Tag>();
                }
            }
            tag.add(tagItem);
        } else if (("tag-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: tagFile
            final TagFile tagFileItem = readTagFile(elementReader, context);
            if (tagFile == null) {
                tagFile = tldTaglib.tagFile;
                if (tagFile != null) {
                    tagFile.clear();
                } else {
                    tagFile = new ArrayList<TagFile>();
                }
            }
            tagFile.add(tagFileItem);
        } else if (("function" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: function
            final Function functionItem = readFunction(elementReader, context);
            if (function == null) {
                function = tldTaglib.function;
                if (function != null) {
                    function.clear();
                } else {
                    function = new ArrayList<Function>();
                }
            }
            function.add(functionItem);
        } else if (("taglib-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: taglibExtension
            final TldExtension taglibExtensionItem = readTldExtension(elementReader, context);
            if (taglibExtension == null) {
                taglibExtension = tldTaglib.taglibExtension;
                if (taglibExtension != null) {
                    taglibExtension.clear();
                } else {
                    taglibExtension = new ArrayList<TldExtension>();
                }
            }
            taglibExtension.add(taglibExtensionItem);
        }
    /* else { // we are not the one responsible of the failure so don't fail
                context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "tlib-version"), new QName("http://java.sun.com/xml/ns/javaee", "jsp-version"), new QName("http://java.sun.com/xml/ns/javaee", "short-name"), new QName("http://java.sun.com/xml/ns/javaee", "uri"), new QName("http://java.sun.com/xml/ns/javaee", "validator"), new QName("http://java.sun.com/xml/ns/javaee", "listener"), new QName("http://java.sun.com/xml/ns/javaee", "tag"), new QName("http://java.sun.com/xml/ns/javaee", "tag-file"), new QName("http://java.sun.com/xml/ns/javaee", "function"), new QName("http://java.sun.com/xml/ns/javaee", "taglib-extension"));
            }*/
    }
    if (descriptions != null) {
        try {
            tldTaglib.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, TldTaglib.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            tldTaglib.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, TldTaglib.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        tldTaglib.icon = icon;
    }
    if (listener != null) {
        tldTaglib.listener = listener;
    }
    if (tag != null) {
        tldTaglib.tag = tag;
    }
    if (tagFile != null) {
        tldTaglib.tagFile = tagFile;
    }
    if (function != null) {
        tldTaglib.function = function;
    }
    if (taglibExtension != null) {
        tldTaglib.taglibExtension = taglibExtension;
    }
    context.afterUnmarshal(tldTaglib, LifecycleCallback.NONE);
    return tldTaglib;
}
Also used : Listener$JAXB.readListener(org.apache.openejb.jee.Listener$JAXB.readListener) Listener$JAXB.writeListener(org.apache.openejb.jee.Listener$JAXB.writeListener) Attribute(org.metatype.sxc.util.Attribute) TagFile$JAXB.readTagFile(org.apache.openejb.jee.TagFile$JAXB.readTagFile) TagFile$JAXB.writeTagFile(org.apache.openejb.jee.TagFile$JAXB.writeTagFile) ArrayList(java.util.ArrayList) Function$JAXB.readFunction(org.apache.openejb.jee.Function$JAXB.readFunction) Function$JAXB.writeFunction(org.apache.openejb.jee.Function$JAXB.writeFunction) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) TldExtension$JAXB.readTldExtension(org.apache.openejb.jee.TldExtension$JAXB.readTldExtension) TldExtension$JAXB.writeTldExtension(org.apache.openejb.jee.TldExtension$JAXB.writeTldExtension) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) Tag$JAXB.readTag(org.apache.openejb.jee.Tag$JAXB.readTag) Tag$JAXB.writeTag(org.apache.openejb.jee.Tag$JAXB.writeTag) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) Validator$JAXB.readValidator(org.apache.openejb.jee.Validator$JAXB.readValidator) Validator$JAXB.writeValidator(org.apache.openejb.jee.Validator$JAXB.writeValidator)

Example 92 with XoXMLStreamReader

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

the class WebResourceCollection$JAXB method _read.

public static final WebResourceCollection _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final WebResourceCollection webResourceCollection = new WebResourceCollection();
    context.beforeUnmarshal(webResourceCollection, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<String> urlPattern = null;
    List<String> httpMethod = null;
    List<String> httpMethodOmission = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("web-resource-collectionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, WebResourceCollection.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, webResourceCollection);
            webResourceCollection.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 (("web-resource-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: webResourceName
            final String webResourceNameRaw = elementReader.getElementAsString();
            final String webResourceName;
            try {
                webResourceName = Adapters.collapsedStringAdapterAdapter.unmarshal(webResourceNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webResourceCollection.webResourceName = webResourceName;
        } else 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 (("url-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: urlPattern
            final String urlPatternItemRaw = elementReader.getElementAsString();
            final String urlPatternItem;
            try {
                urlPatternItem = Adapters.trimStringAdapterAdapter.unmarshal(urlPatternItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, TrimStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (urlPattern == null) {
                urlPattern = webResourceCollection.urlPattern;
                if (urlPattern != null) {
                    urlPattern.clear();
                } else {
                    urlPattern = new ArrayList<String>();
                }
            }
            urlPattern.add(urlPatternItem);
        } else if (("http-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: httpMethod
            final String httpMethodItemRaw = elementReader.getElementAsString();
            final String httpMethodItem;
            try {
                httpMethodItem = Adapters.collapsedStringAdapterAdapter.unmarshal(httpMethodItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (httpMethod == null) {
                httpMethod = webResourceCollection.httpMethod;
                if (httpMethod != null) {
                    httpMethod.clear();
                } else {
                    httpMethod = new ArrayList<String>();
                }
            }
            httpMethod.add(httpMethodItem);
        } else if (("http-method-omission" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: httpMethodOmission
            final String httpMethodOmissionItemRaw = elementReader.getElementAsString();
            final String httpMethodOmissionItem;
            try {
                httpMethodOmissionItem = Adapters.collapsedStringAdapterAdapter.unmarshal(httpMethodOmissionItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (httpMethodOmission == null) {
                httpMethodOmission = webResourceCollection.httpMethodOmission;
                if (httpMethodOmission != null) {
                    httpMethodOmission.clear();
                } else {
                    httpMethodOmission = new ArrayList<String>();
                }
            }
            httpMethodOmission.add(httpMethodOmissionItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "web-resource-name"), new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "url-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "http-method"), new QName("http://java.sun.com/xml/ns/javaee", "http-method-omission"));
        }
    }
    if (descriptions != null) {
        try {
            webResourceCollection.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, WebResourceCollection.class, "setDescriptions", Text[].class, e);
        }
    }
    if (urlPattern != null) {
        webResourceCollection.urlPattern = urlPattern;
    }
    if (httpMethod != null) {
        webResourceCollection.httpMethod = httpMethod;
    }
    if (httpMethodOmission != null) {
        webResourceCollection.httpMethodOmission = httpMethodOmission;
    }
    context.afterUnmarshal(webResourceCollection, LifecycleCallback.NONE);
    return webResourceCollection;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 93 with XoXMLStreamReader

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

the class WelcomeFileList$JAXB method _read.

public static final WelcomeFileList _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final WelcomeFileList welcomeFileList = new WelcomeFileList();
    context.beforeUnmarshal(welcomeFileList, LifecycleCallback.NONE);
    List<String> welcomeFile = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("welcome-file-listType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, WelcomeFileList.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, welcomeFileList);
            welcomeFileList.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 (("welcome-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: welcomeFile
            final String welcomeFileItemRaw = elementReader.getElementAsString();
            final String welcomeFileItem;
            try {
                welcomeFileItem = Adapters.collapsedStringAdapterAdapter.unmarshal(welcomeFileItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (welcomeFile == null) {
                welcomeFile = welcomeFileList.welcomeFile;
                if (welcomeFile != null) {
                    welcomeFile.clear();
                } else {
                    welcomeFile = new ArrayList<String>();
                }
            }
            welcomeFile.add(welcomeFileItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "welcome-file"));
        }
    }
    if (welcomeFile != null) {
        welcomeFileList.welcomeFile = welcomeFile;
    }
    context.afterUnmarshal(welcomeFileList, LifecycleCallback.NONE);
    return welcomeFileList;
}
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 94 with XoXMLStreamReader

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

the class WsdlMessageMapping$JAXB method _read.

public static final WsdlMessageMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final WsdlMessageMapping wsdlMessageMapping = new WsdlMessageMapping();
    context.beforeUnmarshal(wsdlMessageMapping, LifecycleCallback.NONE);
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("wsdl-message-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, WsdlMessageMapping.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, wsdlMessageMapping);
            wsdlMessageMapping.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 (("wsdl-message" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlMessage
            final QName wsdlMessage = elementReader.getElementAsQName();
            wsdlMessageMapping.wsdlMessage = wsdlMessage;
        } else if (("wsdl-message-part-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlMessagePartName
            final String wsdlMessagePartNameRaw = elementReader.getElementAsString();
            final String wsdlMessagePartName;
            try {
                wsdlMessagePartName = Adapters.collapsedStringAdapterAdapter.unmarshal(wsdlMessagePartNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            wsdlMessageMapping.wsdlMessagePartName = wsdlMessagePartName;
        } else if (("parameter-mode" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: parameterMode
            final String parameterModeRaw = elementReader.getElementAsString();
            final String parameterMode;
            try {
                parameterMode = Adapters.collapsedStringAdapterAdapter.unmarshal(parameterModeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            wsdlMessageMapping.parameterMode = parameterMode;
        } else if (("soap-header" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: soapHeader
            final Element soapHeader = elementReader.getElementAsDomElement();
            wsdlMessageMapping.soapHeader = soapHeader;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "wsdl-message"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-message-part-name"), new QName("http://java.sun.com/xml/ns/javaee", "parameter-mode"), new QName("http://java.sun.com/xml/ns/javaee", "soap-header"));
        }
    }
    context.afterUnmarshal(wsdlMessageMapping, LifecycleCallback.NONE);
    return wsdlMessageMapping;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 95 with XoXMLStreamReader

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

the class EjbJar$JAXB method _readEnterpriseBeans.

public static final void _readEnterpriseBeans(final XoXMLStreamReader reader, final RuntimeContext context, final EjbJar ejbJar) throws Exception {
    ArrayList<EnterpriseBean> enterpriseBeans = null;
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("message-driven" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: enterpriseBeans
            final org.apache.openejb.jee.MessageDrivenBean enterpriseBeansItem = readMessageDrivenBean(elementReader, context);
            if (enterpriseBeans == null) {
                enterpriseBeans = new ArrayList<EnterpriseBean>();
            }
            enterpriseBeans.add(enterpriseBeansItem);
        } else if (("session" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: enterpriseBeans
            final org.apache.openejb.jee.SessionBean enterpriseBeansItem1 = readSessionBean(elementReader, context);
            if (enterpriseBeans == null) {
                enterpriseBeans = new ArrayList<EnterpriseBean>();
            }
            enterpriseBeans.add(enterpriseBeansItem1);
        } else if (("entity" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: enterpriseBeans
            final org.apache.openejb.jee.EntityBean enterpriseBeansItem2 = readEntityBean(elementReader, context);
            if (enterpriseBeans == null) {
                enterpriseBeans = new ArrayList<EnterpriseBean>();
            }
            enterpriseBeans.add(enterpriseBeansItem2);
        }
    }
    if (enterpriseBeans != null) {
        try {
            ejbJar.setEnterpriseBeans(enterpriseBeans.toArray(new EnterpriseBean[enterpriseBeans.size()]));
        } catch (final Exception e) {
            context.setterError(reader, EjbJar.class, "setEnterpriseBeans", EnterpriseBean[].class, e);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SessionBean$JAXB.writeSessionBean(org.apache.openejb.jee.SessionBean$JAXB.writeSessionBean) SessionBean$JAXB.readSessionBean(org.apache.openejb.jee.SessionBean$JAXB.readSessionBean) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)184 QName (javax.xml.namespace.QName)182 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)182 Attribute (org.metatype.sxc.util.Attribute)182 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)112 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)70 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