Search in sources :

Example 1 with Handler

use of org.apache.openejb.jee.Handler in project tomee by apache.

the class ServiceRef$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ServiceRef serviceRef, RuntimeContext context) throws Exception {
    if (serviceRef == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ServiceRef.class != serviceRef.getClass()) {
        context.unexpectedSubclass(writer, serviceRef, ServiceRef.class);
        return;
    }
    context.beforeMarshal(serviceRef, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = serviceRef.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(serviceRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = serviceRef.getDescriptions();
    } catch (final Exception e) {
        context.getterError(serviceRef, "descriptions", ServiceRef.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = serviceRef.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(serviceRef, "displayNames", ServiceRef.class, "getDisplayNames", e);
    }
    if (displayNames != null) {
        for (final Text displayNamesItem : displayNames) {
            if (displayNamesItem != null) {
                writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, displayNamesItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = serviceRef.icon;
    if (icon != null) {
        for (final Icon iconItem : icon) {
            if (iconItem != null) {
                writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
                writeIcon(writer, iconItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "icon");
            }
        }
    }
    // ELEMENT: serviceRefName
    final String serviceRefNameRaw = serviceRef.serviceRefName;
    String serviceRefName = null;
    try {
        serviceRefName = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceRefName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceRefName != null) {
        writer.writeStartElement(prefix, "service-ref-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceRefName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(serviceRef, "serviceRefName");
    }
    // ELEMENT: serviceInterface
    final String serviceInterfaceRaw = serviceRef.serviceInterface;
    String serviceInterface = null;
    try {
        serviceInterface = Adapters.collapsedStringAdapterAdapter.marshal(serviceInterfaceRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceInterface", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceInterface != null) {
        writer.writeStartElement(prefix, "service-interface", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceInterface);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(serviceRef, "serviceInterface");
    }
    // ELEMENT: serviceRefType
    final String serviceRefTypeRaw = serviceRef.serviceRefType;
    String serviceRefType = null;
    try {
        serviceRefType = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefTypeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceRefType", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceRefType != null) {
        writer.writeStartElement(prefix, "service-ref-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceRefType);
        writer.writeEndElement();
    }
    // ELEMENT: wsdlFile
    final String wsdlFileRaw = serviceRef.wsdlFile;
    String wsdlFile = null;
    try {
        wsdlFile = Adapters.collapsedStringAdapterAdapter.marshal(wsdlFileRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "wsdlFile", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (wsdlFile != null) {
        writer.writeStartElement(prefix, "wsdl-file", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(wsdlFile);
        writer.writeEndElement();
    }
    // ELEMENT: jaxrpcMappingFile
    final String jaxrpcMappingFileRaw = serviceRef.jaxrpcMappingFile;
    String jaxrpcMappingFile = null;
    try {
        jaxrpcMappingFile = Adapters.collapsedStringAdapterAdapter.marshal(jaxrpcMappingFileRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "jaxrpcMappingFile", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (jaxrpcMappingFile != null) {
        writer.writeStartElement(prefix, "jaxrpc-mapping-file", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(jaxrpcMappingFile);
        writer.writeEndElement();
    }
    // ELEMENT: serviceQname
    final QName serviceQname = serviceRef.serviceQname;
    if (serviceQname != null) {
        writer.writeStartElement(prefix, "service-qname", "http://java.sun.com/xml/ns/javaee");
        writer.writeQName(serviceQname);
        writer.writeEndElement();
    }
    // ELEMENT: portComponentRef
    final List<PortComponentRef> portComponentRef = serviceRef.portComponentRef;
    if (portComponentRef != null) {
        for (final PortComponentRef portComponentRefItem : portComponentRef) {
            if (portComponentRefItem != null) {
                writer.writeStartElement(prefix, "port-component-ref", "http://java.sun.com/xml/ns/javaee");
                writePortComponentRef(writer, portComponentRefItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "portComponentRef");
            }
        }
    }
    // ELEMENT: handler
    final List<Handler> handler = serviceRef.handler;
    if (handler != null) {
        for (final Handler handlerItem : handler) {
            if (handlerItem != null) {
                writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
                writeHandler(writer, handlerItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "handler");
            }
        }
    }
    // ELEMENT: handlerChains
    final HandlerChains handlerChains = serviceRef.handlerChains;
    if (handlerChains != null) {
        writer.writeStartElement(prefix, "handler-chains", "http://java.sun.com/xml/ns/javaee");
        writeHandlerChains(writer, handlerChains, context);
        writer.writeEndElement();
    }
    // ELEMENT: mappedName
    final String mappedNameRaw = serviceRef.mappedName;
    String mappedName = null;
    try {
        mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (mappedName != null) {
        writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(mappedName);
        writer.writeEndElement();
    }
    // ELEMENT: injectionTarget
    final Set<InjectionTarget> injectionTarget = serviceRef.injectionTarget;
    if (injectionTarget != null) {
        for (final InjectionTarget injectionTargetItem : injectionTarget) {
            if (injectionTargetItem != null) {
                writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
                writeInjectionTarget(writer, injectionTargetItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "injectionTarget");
            }
        }
    }
    // ELEMENT: lookupName
    final String lookupNameRaw = serviceRef.lookupName;
    String lookupName = null;
    try {
        lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (lookupName != null) {
        writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(lookupName);
        writer.writeEndElement();
    }
    context.afterMarshal(serviceRef, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) 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)

Example 2 with Handler

use of org.apache.openejb.jee.Handler in project tomee by apache.

the class HandlerChain$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final HandlerChain handlerChain, RuntimeContext context) throws Exception {
    if (handlerChain == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (HandlerChain.class != handlerChain.getClass()) {
        context.unexpectedSubclass(writer, handlerChain, HandlerChain.class);
        return;
    }
    context.beforeMarshal(handlerChain, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = handlerChain.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(handlerChain, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: serviceNamePattern
    final QName serviceNamePatternRaw = handlerChain.serviceNamePattern;
    String serviceNamePattern = null;
    try {
        serviceNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.marshal(serviceNamePatternRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(handlerChain, "serviceNamePattern", HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
    }
    if (serviceNamePattern != null) {
        writer.writeStartElement(prefix, "service-name-pattern", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceNamePattern);
        writer.writeEndElement();
    }
    // ELEMENT: portNamePattern
    final QName portNamePatternRaw = handlerChain.portNamePattern;
    String portNamePattern = null;
    try {
        portNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.marshal(portNamePatternRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(handlerChain, "portNamePattern", HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
    }
    if (portNamePattern != null) {
        writer.writeStartElement(prefix, "port-name-pattern", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(portNamePattern);
        writer.writeEndElement();
    }
    // ELEMENT: protocolBindings
    final List<String> protocolBindingsRaw = handlerChain.protocolBindings;
    if (protocolBindingsRaw != null) {
        writer.writeStartElement(prefix, "protocol-bindings", "http://java.sun.com/xml/ns/javaee");
        boolean protocolBindingsFirst = true;
        for (final String protocolBindingsItem : protocolBindingsRaw) {
            String protocolBindings = null;
            try {
                protocolBindings = Adapters.collapsedStringAdapterAdapter.marshal(protocolBindingsItem);
            } catch (final Exception e) {
                context.xmlAdapterError(handlerChain, "protocolBindings", CollapsedStringAdapter.class, List.class, List.class, e);
            }
            if (protocolBindings != null) {
                if (!protocolBindingsFirst) {
                    writer.writeCharacters(" ");
                }
                protocolBindingsFirst = false;
                writer.writeCharacters(protocolBindings);
            }
        }
        writer.writeEndElement();
    }
    // ELEMENT: handler
    final List<Handler> handler = handlerChain.handler;
    if (handler != null) {
        for (final Handler handlerItem : handler) {
            if (handlerItem != null) {
                writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
                writeHandler(writer, handlerItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(handlerChain, "handler");
            }
        }
    }
    context.afterMarshal(handlerChain, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) 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) ArrayList(java.util.ArrayList) List(java.util.List) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 3 with Handler

use of org.apache.openejb.jee.Handler in project tomee by apache.

the class HandlerChain$JAXB method _read.

public static final HandlerChain _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final HandlerChain handlerChain = new HandlerChain();
    context.beforeUnmarshal(handlerChain, LifecycleCallback.NONE);
    List<String> protocolBindings = null;
    List<Handler> handler = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("handler-chainType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, HandlerChain.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, handlerChain);
            handlerChain.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 (("service-name-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceNamePattern
            final String serviceNamePatternRaw = elementReader.getElementAsString();
            final QName serviceNamePattern;
            try {
                serviceNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.unmarshal(serviceNamePatternRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
                continue;
            }
            handlerChain.serviceNamePattern = serviceNamePattern;
        } else if (("port-name-pattern" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portNamePattern
            final String portNamePatternRaw = elementReader.getElementAsString();
            final QName portNamePattern;
            try {
                portNamePattern = Adapters.handlerChainsStringQNameAdapterAdapter.unmarshal(portNamePatternRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, HandlerChainsStringQNameAdapter.class, QName.class, QName.class, e);
                continue;
            }
            handlerChain.portNamePattern = portNamePattern;
        } else if (("protocol-bindings" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: protocolBindings
            for (final String protocolBindingsItem : elementReader.getElementAsXmlList()) {
                final String protocolBindingsItem1;
                try {
                    protocolBindingsItem1 = Adapters.collapsedStringAdapterAdapter.unmarshal(protocolBindingsItem);
                } catch (final Exception e) {
                    context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                    continue;
                }
                if (protocolBindings == null) {
                    protocolBindings = handlerChain.protocolBindings;
                    if (protocolBindings != null) {
                        protocolBindings.clear();
                    } else {
                        protocolBindings = new ArrayList<String>();
                    }
                }
                protocolBindings.add(protocolBindingsItem1);
            }
        } 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 = handlerChain.handler;
                if (handler != null) {
                    handler.clear();
                } else {
                    handler = new ArrayList<Handler>();
                }
            }
            handler.add(handlerItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "service-name-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "port-name-pattern"), new QName("http://java.sun.com/xml/ns/javaee", "protocol-bindings"), new QName("http://java.sun.com/xml/ns/javaee", "handler"));
        }
    }
    if (protocolBindings != null) {
        handlerChain.protocolBindings = protocolBindings;
    }
    if (handler != null) {
        handlerChain.handler = handler;
    }
    context.afterUnmarshal(handlerChain, LifecycleCallback.NONE);
    return handlerChain;
}
Also used : 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) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 4 with Handler

use of org.apache.openejb.jee.Handler in project tomee by apache.

the class ConfigurationFactory method toHandlerChainInfo.

public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
    final List<HandlerChainInfo> handlerChains = new ArrayList<>();
    if (chains == null) {
        return handlerChains;
    }
    for (final HandlerChain handlerChain : chains.getHandlerChain()) {
        final HandlerChainInfo handlerChainInfo = new HandlerChainInfo();
        handlerChainInfo.serviceNamePattern = handlerChain.getServiceNamePattern();
        handlerChainInfo.portNamePattern = handlerChain.getPortNamePattern();
        handlerChainInfo.protocolBindings.addAll(handlerChain.getProtocolBindings());
        for (final Handler handler : handlerChain.getHandler()) {
            final HandlerInfo handlerInfo = new HandlerInfo();
            handlerInfo.handlerName = handler.getHandlerName();
            handlerInfo.handlerClass = handler.getHandlerClass();
            handlerInfo.soapHeaders.addAll(handler.getSoapHeader());
            handlerInfo.soapRoles.addAll(handler.getSoapRole());
            for (final ParamValue param : handler.getInitParam()) {
                handlerInfo.initParams.setProperty(param.getParamName(), param.getParamValue());
            }
            handlerChainInfo.handlers.add(handlerInfo);
        }
        handlerChains.add(handlerChainInfo);
    }
    return handlerChains;
}
Also used : HandlerChain(org.apache.openejb.jee.HandlerChain) HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) ArrayList(java.util.ArrayList) Handler(org.apache.openejb.jee.Handler) ParamValue(org.apache.openejb.jee.ParamValue) HandlerInfo(org.apache.openejb.assembler.classic.HandlerInfo)

Example 5 with Handler

use of org.apache.openejb.jee.Handler 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)

Aggregations

CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)6 QName (javax.xml.namespace.QName)6 Handler$JAXB.readHandler (org.apache.openejb.jee.Handler$JAXB.readHandler)6 Handler$JAXB.writeHandler (org.apache.openejb.jee.Handler$JAXB.writeHandler)6 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)6 ArrayList (java.util.ArrayList)5 HandlerChains$JAXB.readHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains)4 HandlerChains$JAXB.writeHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains)4 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)4 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)4 Attribute (org.metatype.sxc.util.Attribute)3 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)3 Addressing$JAXB.readAddressing (org.apache.openejb.jee.Addressing$JAXB.readAddressing)2 Addressing$JAXB.writeAddressing (org.apache.openejb.jee.Addressing$JAXB.writeAddressing)2 Handler (org.apache.openejb.jee.Handler)2 HandlerChain (org.apache.openejb.jee.HandlerChain)2 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)2 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)2 PortComponentRef$JAXB.readPortComponentRef (org.apache.openejb.jee.PortComponentRef$JAXB.readPortComponentRef)2 PortComponentRef$JAXB.writePortComponentRef (org.apache.openejb.jee.PortComponentRef$JAXB.writePortComponentRef)2