Search in sources :

Example 6 with InjectionTarget$JAXB.readInjectionTarget

use of org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget 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 7 with InjectionTarget$JAXB.readInjectionTarget

use of org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget in project tomee by apache.

the class EnvEntry$JAXB method _read.

public static final EnvEntry _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final EnvEntry envEntry = new EnvEntry();
    context.beforeUnmarshal(envEntry, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    Set<InjectionTarget> injectionTarget = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("env-entryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, EnvEntry.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, envEntry);
            envEntry.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 (("env-entry-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryName
            final String envEntryNameRaw = elementReader.getElementAsString();
            final String envEntryName;
            try {
                envEntryName = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryName = envEntryName;
        } else if (("env-entry-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryType
            final String envEntryTypeRaw = elementReader.getElementAsString();
            final String envEntryType;
            try {
                envEntryType = Adapters.collapsedStringAdapterAdapter.unmarshal(envEntryTypeRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryType = envEntryType;
        } else if (("env-entry-value" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: envEntryValue
            // don't trim
            final String envEntryValueRaw = elementReader.getElementText();
            final String envEntryValue;
            try {
                envEntryValue = Adapters.stringAdapterAdapter.unmarshal(envEntryValueRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, StringAdapter.class, String.class, String.class, e);
                continue;
            }
            envEntry.envEntryValue = envEntryValue;
        } 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;
            }
            envEntry.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 = envEntry.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;
            }
            envEntry.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", "env-entry-name"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-type"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry-value"), 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 {
            envEntry.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, EnvEntry.class, "setDescriptions", Text[].class, e);
        }
    }
    if (injectionTarget != null) {
        envEntry.injectionTarget = injectionTarget;
    }
    context.afterUnmarshal(envEntry, LifecycleCallback.NONE);
    return envEntry;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 8 with InjectionTarget$JAXB.readInjectionTarget

use of org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget in project tomee by apache.

the class EjbLocalRef$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final EjbLocalRef ejbLocalRef, RuntimeContext context) throws Exception {
    if (ejbLocalRef == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (EjbLocalRef.class != ejbLocalRef.getClass()) {
        context.unexpectedSubclass(writer, ejbLocalRef, EjbLocalRef.class);
        return;
    }
    context.beforeMarshal(ejbLocalRef, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = ejbLocalRef.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(ejbLocalRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = ejbLocalRef.getDescriptions();
    } catch (final Exception e) {
        context.getterError(ejbLocalRef, "descriptions", EjbLocalRef.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(ejbLocalRef, "descriptions");
            }
        }
    }
    // ELEMENT: ejbRefName
    final String ejbRefNameRaw = ejbLocalRef.ejbRefName;
    String ejbRefName = null;
    try {
        ejbRefName = Adapters.collapsedStringAdapterAdapter.marshal(ejbRefNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "ejbRefName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbRefName != null) {
        writer.writeStartElement(prefix, "ejb-ref-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbRefName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(ejbLocalRef, "ejbRefName");
    }
    // ELEMENT: ejbRefType
    final EjbRefType ejbRefType = ejbLocalRef.ejbRefType;
    if (ejbRefType != null) {
        writer.writeStartElement(prefix, "ejb-ref-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(toStringEjbRefType(ejbLocalRef, null, context, ejbRefType));
        writer.writeEndElement();
    }
    // ELEMENT: localHome
    final String localHomeRaw = ejbLocalRef.localHome;
    String localHome = null;
    try {
        localHome = Adapters.collapsedStringAdapterAdapter.marshal(localHomeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "localHome", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (localHome != null) {
        writer.writeStartElement(prefix, "local-home", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(localHome);
        writer.writeEndElement();
    }
    // ELEMENT: local
    final String localRaw = ejbLocalRef.local;
    String local = null;
    try {
        local = Adapters.collapsedStringAdapterAdapter.marshal(localRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "local", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (local != null) {
        writer.writeStartElement(prefix, "local", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(local);
        writer.writeEndElement();
    }
    // ELEMENT: ejbLink
    final String ejbLinkRaw = ejbLocalRef.ejbLink;
    String ejbLink = null;
    try {
        ejbLink = Adapters.collapsedStringAdapterAdapter.marshal(ejbLinkRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "ejbLink", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbLink != null) {
        writer.writeStartElement(prefix, "ejb-link", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbLink);
        writer.writeEndElement();
    }
    // ELEMENT: mappedName
    final String mappedNameRaw = ejbLocalRef.mappedName;
    String mappedName = null;
    try {
        mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "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 = ejbLocalRef.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(ejbLocalRef, "injectionTarget");
            }
        }
    }
    // ELEMENT: lookupName
    final String lookupNameRaw = ejbLocalRef.lookupName;
    String lookupName = null;
    try {
        lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbLocalRef, "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(ejbLocalRef, LifecycleCallback.NONE);
}
Also used : EjbRefType$JAXB.parseEjbRefType(org.apache.openejb.jee.EjbRefType$JAXB.parseEjbRefType) EjbRefType$JAXB.toStringEjbRefType(org.apache.openejb.jee.EjbRefType$JAXB.toStringEjbRefType) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 9 with InjectionTarget$JAXB.readInjectionTarget

use of org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget in project tomee by apache.

the class EjbRef$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final EjbRef ejbRef, RuntimeContext context) throws Exception {
    if (ejbRef == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (EjbRef.class != ejbRef.getClass()) {
        context.unexpectedSubclass(writer, ejbRef, EjbRef.class);
        return;
    }
    context.beforeMarshal(ejbRef, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = ejbRef.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(ejbRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = ejbRef.getDescriptions();
    } catch (final Exception e) {
        context.getterError(ejbRef, "descriptions", EjbRef.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(ejbRef, "descriptions");
            }
        }
    }
    // ELEMENT: ejbRefName
    final String ejbRefNameRaw = ejbRef.ejbRefName;
    String ejbRefName = null;
    try {
        ejbRefName = Adapters.collapsedStringAdapterAdapter.marshal(ejbRefNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "ejbRefName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbRefName != null) {
        writer.writeStartElement(prefix, "ejb-ref-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbRefName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(ejbRef, "ejbRefName");
    }
    // ELEMENT: ejbRefType
    final EjbRefType ejbRefType = ejbRef.ejbRefType;
    if (ejbRefType != null) {
        writer.writeStartElement(prefix, "ejb-ref-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(toStringEjbRefType(ejbRef, null, context, ejbRefType));
        writer.writeEndElement();
    }
    // ELEMENT: home
    final String homeRaw = ejbRef.home;
    String home = null;
    try {
        home = Adapters.collapsedStringAdapterAdapter.marshal(homeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "home", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (home != null) {
        writer.writeStartElement(prefix, "home", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(home);
        writer.writeEndElement();
    }
    // ELEMENT: remote
    final String remoteRaw = ejbRef.remote;
    String remote = null;
    try {
        remote = Adapters.collapsedStringAdapterAdapter.marshal(remoteRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "remote", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (remote != null) {
        writer.writeStartElement(prefix, "remote", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(remote);
        writer.writeEndElement();
    }
    // ELEMENT: ejbLink
    final String ejbLinkRaw = ejbRef.ejbLink;
    String ejbLink = null;
    try {
        ejbLink = Adapters.collapsedStringAdapterAdapter.marshal(ejbLinkRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "ejbLink", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (ejbLink != null) {
        writer.writeStartElement(prefix, "ejb-link", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(ejbLink);
        writer.writeEndElement();
    }
    // ELEMENT: mappedName
    final String mappedNameRaw = ejbRef.mappedName;
    String mappedName = null;
    try {
        mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "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 = ejbRef.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(ejbRef, "injectionTarget");
            }
        }
    }
    // ELEMENT: lookupName
    final String lookupNameRaw = ejbRef.lookupName;
    String lookupName = null;
    try {
        lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(ejbRef, "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(ejbRef, LifecycleCallback.NONE);
}
Also used : EjbRefType$JAXB.parseEjbRefType(org.apache.openejb.jee.EjbRefType$JAXB.parseEjbRefType) EjbRefType$JAXB.toStringEjbRefType(org.apache.openejb.jee.EjbRefType$JAXB.toStringEjbRefType) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 10 with InjectionTarget$JAXB.readInjectionTarget

use of org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget in project tomee by apache.

the class ResourceEnvRef$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ResourceEnvRef resourceEnvRef, RuntimeContext context) throws Exception {
    if (resourceEnvRef == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ResourceEnvRef.class != resourceEnvRef.getClass()) {
        context.unexpectedSubclass(writer, resourceEnvRef, ResourceEnvRef.class);
        return;
    }
    context.beforeMarshal(resourceEnvRef, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = resourceEnvRef.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(resourceEnvRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = resourceEnvRef.getDescriptions();
    } catch (final Exception e) {
        context.getterError(resourceEnvRef, "descriptions", ResourceEnvRef.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(resourceEnvRef, "descriptions");
            }
        }
    }
    // ELEMENT: resourceEnvRefName
    final String resourceEnvRefNameRaw = resourceEnvRef.resourceEnvRefName;
    String resourceEnvRefName = null;
    try {
        resourceEnvRefName = Adapters.collapsedStringAdapterAdapter.marshal(resourceEnvRefNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(resourceEnvRef, "resourceEnvRefName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (resourceEnvRefName != null) {
        writer.writeStartElement(prefix, "resource-env-ref-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(resourceEnvRefName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(resourceEnvRef, "resourceEnvRefName");
    }
    // ELEMENT: resourceEnvRefType
    final String resourceEnvRefTypeRaw = resourceEnvRef.resourceEnvRefType;
    String resourceEnvRefType = null;
    try {
        resourceEnvRefType = Adapters.collapsedStringAdapterAdapter.marshal(resourceEnvRefTypeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(resourceEnvRef, "resourceEnvRefType", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (resourceEnvRefType != null) {
        writer.writeStartElement(prefix, "resource-env-ref-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(resourceEnvRefType);
        writer.writeEndElement();
    }
    // ELEMENT: mappedName
    final String mappedNameRaw = resourceEnvRef.mappedName;
    String mappedName = null;
    try {
        mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(resourceEnvRef, "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 = resourceEnvRef.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(resourceEnvRef, "injectionTarget");
            }
        }
    }
    // ELEMENT: lookupName
    final String lookupNameRaw = resourceEnvRef.lookupName;
    String lookupName = null;
    try {
        lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(resourceEnvRef, "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(resourceEnvRef, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Aggregations

CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)18 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)18 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)18 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)18 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)18 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)18 QName (javax.xml.namespace.QName)10 Attribute (org.metatype.sxc.util.Attribute)9 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)9 InjectionTarget (org.apache.openejb.jee.InjectionTarget)8 LinkedHashSet (java.util.LinkedHashSet)5 ArrayList (java.util.ArrayList)4 EjbRefType$JAXB.parseEjbRefType (org.apache.openejb.jee.EjbRefType$JAXB.parseEjbRefType)4 EjbRefType$JAXB.toStringEjbRefType (org.apache.openejb.jee.EjbRefType$JAXB.toStringEjbRefType)4 EjbJar (org.apache.openejb.jee.EjbJar)3 EnvEntry (org.apache.openejb.jee.EnvEntry)3 Assembler (org.apache.openejb.assembler.classic.Assembler)2 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)2 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)2 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)2