Search in sources :

Example 51 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class PortComponent$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final PortComponent portComponent, RuntimeContext context) throws Exception {
    if (portComponent == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (PortComponent.class != portComponent.getClass()) {
        context.unexpectedSubclass(writer, portComponent, PortComponent.class);
        return;
    }
    context.beforeMarshal(portComponent, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = portComponent.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(portComponent, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: description
    final String descriptionRaw = portComponent.description;
    String description = null;
    try {
        description = Adapters.collapsedStringAdapterAdapter.marshal(descriptionRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(portComponent, "description", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (description != null) {
        writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(description);
        writer.writeEndElement();
    }
    // ELEMENT: displayName
    final String displayNameRaw = portComponent.displayName;
    String displayName = null;
    try {
        displayName = Adapters.collapsedStringAdapterAdapter.marshal(displayNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(portComponent, "displayName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (displayName != null) {
        writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(displayName);
        writer.writeEndElement();
    }
    // ELEMENT: icon
    final Icon icon = portComponent.icon;
    if (icon != null) {
        writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
        writeIcon(writer, icon, context);
        writer.writeEndElement();
    }
    // ELEMENT: portComponentName
    final String portComponentNameRaw = portComponent.portComponentName;
    String portComponentName = null;
    try {
        portComponentName = Adapters.collapsedStringAdapterAdapter.marshal(portComponentNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(portComponent, "portComponentName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (portComponentName != null) {
        writer.writeStartElement(prefix, "port-component-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(portComponentName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(portComponent, "portComponentName");
    }
    // ELEMENT: wsdlService
    final QName wsdlService = portComponent.wsdlService;
    if (wsdlService != null) {
        writer.writeStartElement(prefix, "wsdl-service", "http://java.sun.com/xml/ns/javaee");
        writer.writeQName(wsdlService);
        writer.writeEndElement();
    }
    // ELEMENT: wsdlPort
    final QName wsdlPort = portComponent.wsdlPort;
    if (wsdlPort != null) {
        writer.writeStartElement(prefix, "wsdl-port", "http://java.sun.com/xml/ns/javaee");
        writer.writeQName(wsdlPort);
        writer.writeEndElement();
    }
    // ELEMENT: enableMtom
    final Boolean enableMtom = portComponent.enableMtom;
    if (enableMtom != null) {
        writer.writeStartElement(prefix, "enable-mtom", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Boolean.toString(enableMtom));
        writer.writeEndElement();
    }
    // ELEMENT: mtomThreshold
    final Integer mtomThreshold = portComponent.mtomThreshold;
    if (mtomThreshold != null) {
        writer.writeStartElement(prefix, "mtom-threshold", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(Integer.toString(mtomThreshold));
        writer.writeEndElement();
    }
    // ELEMENT: addressing
    final Addressing addressing = portComponent.addressing;
    if (addressing != null) {
        writer.writeStartElement(prefix, "addressing", "http://java.sun.com/xml/ns/javaee");
        writeAddressing(writer, addressing, context);
        writer.writeEndElement();
    }
    // ELEMENT: respectBinding
    final RespectBinding respectBinding = portComponent.respectBinding;
    if (respectBinding != null) {
        writer.writeStartElement(prefix, "respect-binding", "http://java.sun.com/xml/ns/javaee");
        writeRespectBinding(writer, respectBinding, context);
        writer.writeEndElement();
    }
    // ELEMENT: protocolBinding
    final String protocolBindingRaw = portComponent.protocolBinding;
    String protocolBinding = null;
    try {
        protocolBinding = Adapters.collapsedStringAdapterAdapter.marshal(protocolBindingRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(portComponent, "protocolBinding", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (protocolBinding != null) {
        writer.writeStartElement(prefix, "protocol-binding", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(protocolBinding);
        writer.writeEndElement();
    }
    // ELEMENT: serviceEndpointInterface
    final String serviceEndpointInterfaceRaw = portComponent.serviceEndpointInterface;
    String serviceEndpointInterface = null;
    try {
        serviceEndpointInterface = Adapters.collapsedStringAdapterAdapter.marshal(serviceEndpointInterfaceRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(portComponent, "serviceEndpointInterface", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceEndpointInterface != null) {
        writer.writeStartElement(prefix, "service-endpoint-interface", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceEndpointInterface);
        writer.writeEndElement();
    }
    // ELEMENT: serviceImplBean
    final ServiceImplBean serviceImplBean = portComponent.serviceImplBean;
    if (serviceImplBean != null) {
        writer.writeStartElement(prefix, "service-impl-bean", "http://java.sun.com/xml/ns/javaee");
        writeServiceImplBean(writer, serviceImplBean, context);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(portComponent, "serviceImplBean");
    }
    // ELEMENT: handler
    final List<Handler> handler = portComponent.handler;
    if (handler != null) {
        for (final Handler handlerItem : handler) {
            writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
            if (handlerItem != null) {
                writeHandler(writer, handlerItem, context);
            } else {
                writer.writeXsiNil();
            }
            writer.writeEndElement();
        }
    }
    // ELEMENT: handlerChains
    final HandlerChains handlerChains = portComponent.handlerChains;
    if (handlerChains != null) {
        writer.writeStartElement(prefix, "handler-chains", "http://java.sun.com/xml/ns/javaee");
        writeHandlerChains(writer, handlerChains, context);
        writer.writeEndElement();
    }
    context.afterMarshal(portComponent, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) ServiceImplBean$JAXB.readServiceImplBean(org.apache.openejb.jee.ServiceImplBean$JAXB.readServiceImplBean) ServiceImplBean$JAXB.writeServiceImplBean(org.apache.openejb.jee.ServiceImplBean$JAXB.writeServiceImplBean) QName(javax.xml.namespace.QName) Handler$JAXB.readHandler(org.apache.openejb.jee.Handler$JAXB.readHandler) Handler$JAXB.writeHandler(org.apache.openejb.jee.Handler$JAXB.writeHandler) RespectBinding$JAXB.writeRespectBinding(org.apache.openejb.jee.RespectBinding$JAXB.writeRespectBinding) RespectBinding$JAXB.readRespectBinding(org.apache.openejb.jee.RespectBinding$JAXB.readRespectBinding) HandlerChains$JAXB.readHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains) HandlerChains$JAXB.writeHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains) Addressing$JAXB.writeAddressing(org.apache.openejb.jee.Addressing$JAXB.writeAddressing) Addressing$JAXB.readAddressing(org.apache.openejb.jee.Addressing$JAXB.readAddressing) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 52 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class PortComponent$JAXB method _read.

public static final PortComponent _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final PortComponent portComponent = new PortComponent();
    context.beforeUnmarshal(portComponent, LifecycleCallback.NONE);
    List<Handler> handler = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("port-componentType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, PortComponent.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, portComponent);
            portComponent.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: description
            final String descriptionRaw = elementReader.getElementAsString();
            final String description;
            try {
                description = Adapters.collapsedStringAdapterAdapter.unmarshal(descriptionRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            portComponent.description = description;
        } else if (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: displayName
            final String displayNameRaw = elementReader.getElementAsString();
            final String displayName;
            try {
                displayName = Adapters.collapsedStringAdapterAdapter.unmarshal(displayNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            portComponent.displayName = displayName;
        } else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: icon
            final Icon icon = readIcon(elementReader, context);
            portComponent.icon = icon;
        } else if (("port-component-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portComponentName
            final String portComponentNameRaw = elementReader.getElementAsString();
            final String portComponentName;
            try {
                portComponentName = Adapters.collapsedStringAdapterAdapter.unmarshal(portComponentNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            portComponent.portComponentName = portComponentName;
        } else if (("wsdl-service" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlService
            final QName wsdlService = elementReader.getElementAsQName();
            portComponent.wsdlService = wsdlService;
        } else if (("wsdl-port" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlPort
            final QName wsdlPort = elementReader.getElementAsQName();
            portComponent.wsdlPort = wsdlPort;
        } else if (("enable-mtom" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: enableMtom
            final Boolean enableMtom = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            portComponent.enableMtom = enableMtom;
        } else if (("mtom-threshold" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: mtomThreshold
            final Integer mtomThreshold = Integer.valueOf(elementReader.getElementAsString());
            portComponent.mtomThreshold = mtomThreshold;
        } else if (("addressing" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: addressing
            final Addressing addressing = readAddressing(elementReader, context);
            portComponent.addressing = addressing;
        } else if (("respect-binding" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: respectBinding
            final RespectBinding respectBinding = readRespectBinding(elementReader, context);
            portComponent.respectBinding = respectBinding;
        } else if (("protocol-binding" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: protocolBinding
            final String protocolBindingRaw = elementReader.getElementAsString();
            final String protocolBinding;
            try {
                protocolBinding = Adapters.collapsedStringAdapterAdapter.unmarshal(protocolBindingRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            portComponent.protocolBinding = protocolBinding;
        } else if (("service-endpoint-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceEndpointInterface
            final String serviceEndpointInterfaceRaw = elementReader.getElementAsString();
            final String serviceEndpointInterface;
            try {
                serviceEndpointInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(serviceEndpointInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            portComponent.serviceEndpointInterface = serviceEndpointInterface;
        } else if (("service-impl-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceImplBean
            final ServiceImplBean serviceImplBean = readServiceImplBean(elementReader, context);
            portComponent.serviceImplBean = serviceImplBean;
        } else if (("handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handler
            final Handler handlerItem = readHandler(elementReader, context);
            if (handler == null) {
                handler = portComponent.handler;
                if (handler != null) {
                    handler.clear();
                } else {
                    handler = new ArrayList<Handler>();
                }
            }
            handler.add(handlerItem);
        } else if (("handler-chains" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerChains
            final HandlerChains handlerChains = readHandlerChains(elementReader, context);
            portComponent.handlerChains = handlerChains;
        } else {
            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", "port-component-name"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-service"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-port"), new QName("http://java.sun.com/xml/ns/javaee", "enable-mtom"), new QName("http://java.sun.com/xml/ns/javaee", "mtom-threshold"), new QName("http://java.sun.com/xml/ns/javaee", "addressing"), new QName("http://java.sun.com/xml/ns/javaee", "respect-binding"), new QName("http://java.sun.com/xml/ns/javaee", "protocol-binding"), new QName("http://java.sun.com/xml/ns/javaee", "service-endpoint-interface"), new QName("http://java.sun.com/xml/ns/javaee", "service-impl-bean"), new QName("http://java.sun.com/xml/ns/javaee", "handler"), new QName("http://java.sun.com/xml/ns/javaee", "handler-chains"));
        }
    }
    if (handler != null) {
        portComponent.handler = handler;
    }
    context.afterUnmarshal(portComponent, LifecycleCallback.NONE);
    return portComponent;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) ServiceImplBean$JAXB.readServiceImplBean(org.apache.openejb.jee.ServiceImplBean$JAXB.readServiceImplBean) ServiceImplBean$JAXB.writeServiceImplBean(org.apache.openejb.jee.ServiceImplBean$JAXB.writeServiceImplBean) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Handler$JAXB.readHandler(org.apache.openejb.jee.Handler$JAXB.readHandler) Handler$JAXB.writeHandler(org.apache.openejb.jee.Handler$JAXB.writeHandler) RespectBinding$JAXB.writeRespectBinding(org.apache.openejb.jee.RespectBinding$JAXB.writeRespectBinding) RespectBinding$JAXB.readRespectBinding(org.apache.openejb.jee.RespectBinding$JAXB.readRespectBinding) HandlerChains$JAXB.readHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains) HandlerChains$JAXB.writeHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains) Addressing$JAXB.writeAddressing(org.apache.openejb.jee.Addressing$JAXB.writeAddressing) Addressing$JAXB.readAddressing(org.apache.openejb.jee.Addressing$JAXB.readAddressing) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 53 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class ServiceRef$JAXB method _read.

public static final ServiceRef _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ServiceRef serviceRef = new ServiceRef();
    context.beforeUnmarshal(serviceRef, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<PortComponentRef> portComponentRef = null;
    List<Handler> handler = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("service-refType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ServiceRef.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, serviceRef);
            serviceRef.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 (("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 = serviceRef.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("service-ref-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceRefName
            final String serviceRefNameRaw = elementReader.getElementAsString();
            final String serviceRefName;
            try {
                serviceRefName = Adapters.collapsedStringAdapterAdapter.unmarshal(serviceRefNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            serviceRef.serviceRefName = serviceRefName;
        } else if (("service-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceInterface
            final String serviceInterfaceRaw = elementReader.getElementAsString();
            final String serviceInterface;
            try {
                serviceInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(serviceInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            serviceRef.serviceInterface = serviceInterface;
        } else if (("service-ref-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceRefType
            final String serviceRefTypeRaw = elementReader.getElementAsString();
            final String serviceRefType;
            try {
                serviceRefType = Adapters.collapsedStringAdapterAdapter.unmarshal(serviceRefTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            serviceRef.serviceRefType = serviceRefType;
        } else if (("wsdl-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlFile
            final String wsdlFileRaw = elementReader.getElementAsString();
            final String wsdlFile;
            try {
                wsdlFile = Adapters.collapsedStringAdapterAdapter.unmarshal(wsdlFileRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            serviceRef.wsdlFile = wsdlFile;
        } else if (("jaxrpc-mapping-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: jaxrpcMappingFile
            final String jaxrpcMappingFileRaw = elementReader.getElementAsString();
            final String jaxrpcMappingFile;
            try {
                jaxrpcMappingFile = Adapters.collapsedStringAdapterAdapter.unmarshal(jaxrpcMappingFileRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            serviceRef.jaxrpcMappingFile = jaxrpcMappingFile;
        } else if (("service-qname" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceQname
            final QName serviceQname = elementReader.getElementAsQName();
            serviceRef.serviceQname = serviceQname;
        } else if (("port-component-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portComponentRef
            final PortComponentRef portComponentRefItem = readPortComponentRef(elementReader, context);
            if (portComponentRef == null) {
                portComponentRef = serviceRef.portComponentRef;
                if (portComponentRef != null) {
                    portComponentRef.clear();
                } else {
                    portComponentRef = new ArrayList<PortComponentRef>();
                }
            }
            portComponentRef.add(portComponentRefItem);
        } else if (("handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handler
            final Handler handlerItem = readHandler(elementReader, context);
            if (handler == null) {
                handler = serviceRef.handler;
                if (handler != null) {
                    handler.clear();
                } else {
                    handler = new ArrayList<Handler>();
                }
            }
            handler.add(handlerItem);
        } else if (("handler-chains" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerChains
            final HandlerChains handlerChains = readHandlerChains(elementReader, context);
            serviceRef.handlerChains = handlerChains;
        } 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;
            }
            serviceRef.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 = serviceRef.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;
            }
            serviceRef.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", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "service-ref-name"), new QName("http://java.sun.com/xml/ns/javaee", "service-interface"), new QName("http://java.sun.com/xml/ns/javaee", "service-ref-type"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-file"), new QName("http://java.sun.com/xml/ns/javaee", "jaxrpc-mapping-file"), new QName("http://java.sun.com/xml/ns/javaee", "service-qname"), new QName("http://java.sun.com/xml/ns/javaee", "port-component-ref"), new QName("http://java.sun.com/xml/ns/javaee", "handler"), new QName("http://java.sun.com/xml/ns/javaee", "handler-chains"), 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 {
            serviceRef.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ServiceRef.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            serviceRef.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ServiceRef.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        serviceRef.icon = icon;
    }
    if (portComponentRef != null) {
        serviceRef.portComponentRef = portComponentRef;
    }
    if (handler != null) {
        serviceRef.handler = handler;
    }
    if (injectionTarget != null) {
        serviceRef.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(serviceRef, LifecycleCallback.NONE);
    return serviceRef;
}
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) Handler$JAXB.readHandler(org.apache.openejb.jee.Handler$JAXB.readHandler) Handler$JAXB.writeHandler(org.apache.openejb.jee.Handler$JAXB.writeHandler) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) HandlerChains$JAXB.readHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains) HandlerChains$JAXB.writeHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains) PortComponentRef$JAXB.readPortComponentRef(org.apache.openejb.jee.PortComponentRef$JAXB.readPortComponentRef) PortComponentRef$JAXB.writePortComponentRef(org.apache.openejb.jee.PortComponentRef$JAXB.writePortComponentRef) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 54 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class ApplicationClient$JAXB method _read.

public static final ApplicationClient _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ApplicationClient applicationClient = new ApplicationClient();
    context.beforeUnmarshal(applicationClient, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    KeyedCollection<String, EnvEntry> envEntry = null;
    KeyedCollection<String, EjbRef> ejbRef = null;
    KeyedCollection<String, EjbLocalRef> ejbLocalRef = null;
    KeyedCollection<String, ServiceRef> serviceRef = null;
    KeyedCollection<String, ResourceRef> resourceRef = null;
    KeyedCollection<String, ResourceEnvRef> resourceEnvRef = null;
    KeyedCollection<String, MessageDestinationRef> messageDestinationRef = null;
    KeyedCollection<String, PersistenceContextRef> persistenceContextRef = null;
    KeyedCollection<String, PersistenceUnitRef> persistenceUnitRef = null;
    List<org.apache.openejb.jee.LifecycleCallback> postConstruct = null;
    List<org.apache.openejb.jee.LifecycleCallback> preDestroy = null;
    KeyedCollection<String, MessageDestination> messageDestination = null;
    KeyedCollection<String, DataSource> dataSource = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("application-clientType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ApplicationClient.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, applicationClient);
            applicationClient.id = id;
        } else if (("metadata-complete" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: metadataComplete
            final Boolean metadataComplete = ("1".equals(attribute.getValue()) || "true".equals(attribute.getValue()));
            applicationClient.metadataComplete = metadataComplete;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            applicationClient.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("", "metadata-complete"), new QName("", "version"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("module-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: moduleName
            final String moduleNameRaw = elementReader.getElementAsString();
            final String moduleName;
            try {
                moduleName = Adapters.collapsedStringAdapterAdapter.unmarshal(moduleNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            applicationClient.moduleName = moduleName;
        } 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 (("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 = applicationClient.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("env-entry" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntry
            final EnvEntry envEntryItem = readEnvEntry(elementReader, context);
            if (envEntry == null) {
                envEntry = applicationClient.envEntry;
                if (envEntry != null) {
                    envEntry.clear();
                } else {
                    envEntry = new KeyedCollection<String, EnvEntry>();
                }
            }
            envEntry.add(envEntryItem);
        } else if (("ejb-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbRef
            final EjbRef ejbRefItem = readEjbRef(elementReader, context);
            if (ejbRef == null) {
                ejbRef = applicationClient.ejbRef;
                if (ejbRef != null) {
                    ejbRef.clear();
                } else {
                    ejbRef = new KeyedCollection<String, EjbRef>();
                }
            }
            ejbRef.add(ejbRefItem);
        } else if (("ejb-local-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbLocalRef
            final EjbLocalRef ejbLocalRefItem = readEjbLocalRef(elementReader, context);
            if (ejbLocalRef == null) {
                ejbLocalRef = applicationClient.ejbLocalRef;
                if (ejbLocalRef != null) {
                    ejbLocalRef.clear();
                } else {
                    ejbLocalRef = new KeyedCollection<String, EjbLocalRef>();
                }
            }
            ejbLocalRef.add(ejbLocalRefItem);
        } else if (("service-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceRef
            final ServiceRef serviceRefItem = readServiceRef(elementReader, context);
            if (serviceRef == null) {
                serviceRef = applicationClient.serviceRef;
                if (serviceRef != null) {
                    serviceRef.clear();
                } else {
                    serviceRef = new KeyedCollection<String, ServiceRef>();
                }
            }
            serviceRef.add(serviceRefItem);
        } else if (("resource-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resourceRef
            final ResourceRef resourceRefItem = readResourceRef(elementReader, context);
            if (resourceRef == null) {
                resourceRef = applicationClient.resourceRef;
                if (resourceRef != null) {
                    resourceRef.clear();
                } else {
                    resourceRef = new KeyedCollection<String, ResourceRef>();
                }
            }
            resourceRef.add(resourceRefItem);
        } else if (("resource-env-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resourceEnvRef
            final ResourceEnvRef resourceEnvRefItem = readResourceEnvRef(elementReader, context);
            if (resourceEnvRef == null) {
                resourceEnvRef = applicationClient.resourceEnvRef;
                if (resourceEnvRef != null) {
                    resourceEnvRef.clear();
                } else {
                    resourceEnvRef = new KeyedCollection<String, ResourceEnvRef>();
                }
            }
            resourceEnvRef.add(resourceEnvRefItem);
        } else if (("message-destination-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: messageDestinationRef
            final MessageDestinationRef messageDestinationRefItem = readMessageDestinationRef(elementReader, context);
            if (messageDestinationRef == null) {
                messageDestinationRef = applicationClient.messageDestinationRef;
                if (messageDestinationRef != null) {
                    messageDestinationRef.clear();
                } else {
                    messageDestinationRef = new KeyedCollection<String, MessageDestinationRef>();
                }
            }
            messageDestinationRef.add(messageDestinationRefItem);
        } else if (("persistence-context-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceContextRef
            final PersistenceContextRef persistenceContextRefItem = readPersistenceContextRef(elementReader, context);
            if (persistenceContextRef == null) {
                persistenceContextRef = applicationClient.persistenceContextRef;
                if (persistenceContextRef != null) {
                    persistenceContextRef.clear();
                } else {
                    persistenceContextRef = new KeyedCollection<String, PersistenceContextRef>();
                }
            }
            persistenceContextRef.add(persistenceContextRefItem);
        } else if (("persistence-unit-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: persistenceUnitRef
            final PersistenceUnitRef persistenceUnitRefItem = readPersistenceUnitRef(elementReader, context);
            if (persistenceUnitRef == null) {
                persistenceUnitRef = applicationClient.persistenceUnitRef;
                if (persistenceUnitRef != null) {
                    persistenceUnitRef.clear();
                } else {
                    persistenceUnitRef = new KeyedCollection<String, PersistenceUnitRef>();
                }
            }
            persistenceUnitRef.add(persistenceUnitRefItem);
        } else if (("post-construct" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: postConstruct
            final org.apache.openejb.jee.LifecycleCallback postConstructItem = readLifecycleCallback(elementReader, context);
            if (postConstruct == null) {
                postConstruct = applicationClient.postConstruct;
                if (postConstruct != null) {
                    postConstruct.clear();
                } else {
                    postConstruct = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
                }
            }
            postConstruct.add(postConstructItem);
        } else if (("pre-destroy" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: preDestroy
            final org.apache.openejb.jee.LifecycleCallback preDestroyItem = readLifecycleCallback(elementReader, context);
            if (preDestroy == null) {
                preDestroy = applicationClient.preDestroy;
                if (preDestroy != null) {
                    preDestroy.clear();
                } else {
                    preDestroy = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
                }
            }
            preDestroy.add(preDestroyItem);
        } else if (("callback-handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: callbackHandler
            final String callbackHandlerRaw = elementReader.getElementAsString();
            final String callbackHandler;
            try {
                callbackHandler = Adapters.collapsedStringAdapterAdapter.unmarshal(callbackHandlerRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            applicationClient.callbackHandler = callbackHandler;
        } else if (("message-destination" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: messageDestination
            final MessageDestination messageDestinationItem = readMessageDestination(elementReader, context);
            if (messageDestination == null) {
                messageDestination = applicationClient.messageDestination;
                if (messageDestination != null) {
                    messageDestination.clear();
                } else {
                    messageDestination = new KeyedCollection<String, MessageDestination>();
                }
            }
            messageDestination.add(messageDestinationItem);
        } else if (("data-source" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: dataSource
            final DataSource dataSourceItem = readDataSource(elementReader, context);
            if (dataSource == null) {
                dataSource = applicationClient.dataSource;
                if (dataSource != null) {
                    dataSource.clear();
                } else {
                    dataSource = new KeyedCollection<String, DataSource>();
                }
            }
            dataSource.add(dataSourceItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "module-name"), 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", "env-entry"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-local-ref"), new QName("http://java.sun.com/xml/ns/javaee", "service-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-env-ref"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-ref"), new QName("http://java.sun.com/xml/ns/javaee", "post-construct"), new QName("http://java.sun.com/xml/ns/javaee", "pre-destroy"), new QName("http://java.sun.com/xml/ns/javaee", "callback-handler"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination"), new QName("http://java.sun.com/xml/ns/javaee", "data-source"));
        }
    }
    if (descriptions != null) {
        try {
            applicationClient.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ApplicationClient.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            applicationClient.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, ApplicationClient.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        applicationClient.icon = icon;
    }
    if (envEntry != null) {
        applicationClient.envEntry = envEntry;
    }
    if (ejbRef != null) {
        applicationClient.ejbRef = ejbRef;
    }
    if (ejbLocalRef != null) {
        applicationClient.ejbLocalRef = ejbLocalRef;
    }
    if (serviceRef != null) {
        applicationClient.serviceRef = serviceRef;
    }
    if (resourceRef != null) {
        applicationClient.resourceRef = resourceRef;
    }
    if (resourceEnvRef != null) {
        applicationClient.resourceEnvRef = resourceEnvRef;
    }
    if (messageDestinationRef != null) {
        applicationClient.messageDestinationRef = messageDestinationRef;
    }
    if (persistenceContextRef != null) {
        applicationClient.persistenceContextRef = persistenceContextRef;
    }
    if (persistenceUnitRef != null) {
        applicationClient.persistenceUnitRef = persistenceUnitRef;
    }
    if (postConstruct != null) {
        applicationClient.postConstruct = postConstruct;
    }
    if (preDestroy != null) {
        applicationClient.preDestroy = preDestroy;
    }
    if (messageDestination != null) {
        applicationClient.messageDestination = messageDestination;
    }
    if (dataSource != null) {
        applicationClient.dataSource = dataSource;
    }
    context.afterUnmarshal(applicationClient, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
    return applicationClient;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) PersistenceContextRef$JAXB.readPersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef$JAXB.readPersistenceContextRef) PersistenceContextRef$JAXB.writePersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef$JAXB.writePersistenceContextRef) ArrayList(java.util.ArrayList) MessageDestinationRef$JAXB.writeMessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef$JAXB.writeMessageDestinationRef) MessageDestinationRef$JAXB.readMessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef$JAXB.readMessageDestinationRef) EjbRef$JAXB.readEjbRef(org.apache.openejb.jee.EjbRef$JAXB.readEjbRef) EjbRef$JAXB.writeEjbRef(org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef) ResourceEnvRef$JAXB.readResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef) ResourceEnvRef$JAXB.writeResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef$JAXB.writeResourceEnvRef) PersistenceUnitRef$JAXB.readPersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef$JAXB.readPersistenceUnitRef) PersistenceUnitRef$JAXB.writePersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef$JAXB.writePersistenceUnitRef) EnvEntry$JAXB.readEnvEntry(org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry) EnvEntry$JAXB.writeEnvEntry(org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader) EjbLocalRef$JAXB.writeEjbLocalRef(org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef) EjbLocalRef$JAXB.readEjbLocalRef(org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef) MessageDestination$JAXB.readMessageDestination(org.apache.openejb.jee.MessageDestination$JAXB.readMessageDestination) MessageDestination$JAXB.writeMessageDestination(org.apache.openejb.jee.MessageDestination$JAXB.writeMessageDestination) 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) DataSource$JAXB.writeDataSource(org.apache.openejb.jee.DataSource$JAXB.writeDataSource) DataSource$JAXB.readDataSource(org.apache.openejb.jee.DataSource$JAXB.readDataSource) ResourceRef$JAXB.readResourceRef(org.apache.openejb.jee.ResourceRef$JAXB.readResourceRef) ResourceRef$JAXB.writeResourceRef(org.apache.openejb.jee.ResourceRef$JAXB.writeResourceRef) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) LifecycleCallback$JAXB.readLifecycleCallback(org.apache.openejb.jee.LifecycleCallback$JAXB.readLifecycleCallback) LifecycleCallback$JAXB.writeLifecycleCallback(org.apache.openejb.jee.LifecycleCallback$JAXB.writeLifecycleCallback) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) ServiceRef$JAXB.readServiceRef(org.apache.openejb.jee.ServiceRef$JAXB.readServiceRef) ServiceRef$JAXB.writeServiceRef(org.apache.openejb.jee.ServiceRef$JAXB.writeServiceRef)

Example 55 with Icon$JAXB.readIcon

use of org.apache.openejb.jee.Icon$JAXB.readIcon in project tomee by apache.

the class Connector$JAXB method _read.

public static final Connector _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Connector connector = new Connector();
    context.beforeUnmarshal(connector, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<String> requiredWorkContext = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("connectorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Connector.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, connector);
            connector.id = id;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            connector.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
        } else if (("metadata-complete" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: metadataComplete
            final Boolean metadataComplete = ("1".equals(attribute.getValue()) || "true".equals(attribute.getValue()));
            connector.metadataComplete = metadataComplete;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"), new QName("", "metadata-complete"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("module-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: moduleName
            final String moduleNameRaw = elementReader.getElementAsString();
            final String moduleName;
            try {
                moduleName = Adapters.collapsedStringAdapterAdapter.unmarshal(moduleNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connector.moduleName = moduleName;
        } 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 (("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 = connector.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("vendor-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: vendorName
            final String vendorNameRaw = elementReader.getElementAsString();
            final String vendorName;
            try {
                vendorName = Adapters.collapsedStringAdapterAdapter.unmarshal(vendorNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connector.vendorName = vendorName;
        } else if (("eis-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: eisType
            final String eisTypeRaw = elementReader.getElementAsString();
            final String eisType;
            try {
                eisType = Adapters.collapsedStringAdapterAdapter.unmarshal(eisTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connector.eisType = eisType;
        } else if (("resourceadapter-version" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resourceAdapterVersion
            final String resourceAdapterVersionRaw = elementReader.getElementAsString();
            final String resourceAdapterVersion;
            try {
                resourceAdapterVersion = Adapters.collapsedStringAdapterAdapter.unmarshal(resourceAdapterVersionRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connector.resourceAdapterVersion = resourceAdapterVersion;
        } else if (("license" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: license
            final License license = readLicense(elementReader, context);
            connector.license = license;
        } else if (("resourceadapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resourceAdapter
            final ResourceAdapter resourceAdapter = readResourceAdapter(elementReader, context);
            connector.resourceAdapter = resourceAdapter;
        } else if (("required-work-context" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: requiredWorkContext
            final String requiredWorkContextItemRaw = elementReader.getElementAsString();
            final String requiredWorkContextItem;
            try {
                requiredWorkContextItem = Adapters.collapsedStringAdapterAdapter.unmarshal(requiredWorkContextItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (requiredWorkContext == null) {
                requiredWorkContext = connector.requiredWorkContext;
                if (requiredWorkContext != null) {
                    requiredWorkContext.clear();
                } else {
                    requiredWorkContext = new ArrayList<String>();
                }
            }
            requiredWorkContext.add(requiredWorkContextItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "module-name"), 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", "vendor-name"), new QName("http://java.sun.com/xml/ns/javaee", "eis-type"), new QName("http://java.sun.com/xml/ns/javaee", "resourceadapter-version"), new QName("http://java.sun.com/xml/ns/javaee", "license"), new QName("http://java.sun.com/xml/ns/javaee", "resourceadapter"), new QName("http://java.sun.com/xml/ns/javaee", "required-work-context"));
        }
    }
    if (descriptions != null) {
        try {
            connector.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Connector.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            connector.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Connector.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        connector.icon = icon;
    }
    if (requiredWorkContext != null) {
        connector.requiredWorkContext = requiredWorkContext;
    }
    context.afterUnmarshal(connector, LifecycleCallback.NONE);
    return connector;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) License$JAXB.readLicense(org.apache.openejb.jee.License$JAXB.readLicense) License$JAXB.writeLicense(org.apache.openejb.jee.License$JAXB.writeLicense) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) ResourceAdapter$JAXB.readResourceAdapter(org.apache.openejb.jee.ResourceAdapter$JAXB.readResourceAdapter) ResourceAdapter$JAXB.writeResourceAdapter(org.apache.openejb.jee.ResourceAdapter$JAXB.writeResourceAdapter) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)74 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)74 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)74 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)70 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)70 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)69 ArrayList (java.util.ArrayList)40 QName (javax.xml.namespace.QName)40 Attribute (org.metatype.sxc.util.Attribute)37 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)37 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)12 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)12 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)12 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)12 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)12 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)12 EnvEntry$JAXB.readEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.readEnvEntry)12 EnvEntry$JAXB.writeEnvEntry (org.apache.openejb.jee.EnvEntry$JAXB.writeEnvEntry)12 MessageDestinationRef$JAXB.readMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.readMessageDestinationRef)12 MessageDestinationRef$JAXB.writeMessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef$JAXB.writeMessageDestinationRef)12