Search in sources :

Example 36 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class InterceptorBinding$JAXB method _read.

public static final InterceptorBinding _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final InterceptorBinding interceptorBinding = new InterceptorBinding();
    context.beforeUnmarshal(interceptorBinding, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<String> interceptorClass = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("interceptor-bindingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, InterceptorBinding.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, interceptorBinding);
            interceptorBinding.id = id;
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: descriptions
            final Text descriptionsItem = readText(elementReader, context);
            if (descriptions == null) {
                descriptions = new ArrayList<Text>();
            }
            descriptions.add(descriptionsItem);
        } else if (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: ejbName
            final String ejbNameRaw = elementReader.getElementAsString();
            final String ejbName;
            try {
                ejbName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            interceptorBinding.ejbName = ejbName;
        } else if (("interceptor-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: interceptorClass
            final String interceptorClassItemRaw = elementReader.getElementAsString();
            final String interceptorClassItem;
            try {
                interceptorClassItem = Adapters.collapsedStringAdapterAdapter.unmarshal(interceptorClassItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (interceptorClass == null) {
                interceptorClass = interceptorBinding.interceptorClass;
                if (interceptorClass != null) {
                    interceptorClass.clear();
                } else {
                    interceptorClass = new ArrayList<String>();
                }
            }
            interceptorClass.add(interceptorClassItem);
        } else if (("interceptor-order" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: interceptorOrder
            final InterceptorOrder interceptorOrder = readInterceptorOrder(elementReader, context);
            interceptorBinding.interceptorOrder = interceptorOrder;
        } else if (("exclude-default-interceptors" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: excludeDefaultInterceptors
            final Boolean excludeDefaultInterceptors = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            interceptorBinding.excludeDefaultInterceptors = excludeDefaultInterceptors;
        } else if (("exclude-class-interceptors" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: excludeClassInterceptors
            final Boolean excludeClassInterceptors = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            interceptorBinding.excludeClassInterceptors = excludeClassInterceptors;
        } else if (("method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: method
            final NamedMethod method = readNamedMethod(elementReader, context);
            interceptorBinding.method = method;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-name"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-class"), new QName("http://java.sun.com/xml/ns/javaee", "interceptor-order"), new QName("http://java.sun.com/xml/ns/javaee", "exclude-default-interceptors"), new QName("http://java.sun.com/xml/ns/javaee", "exclude-class-interceptors"), new QName("http://java.sun.com/xml/ns/javaee", "method"));
        }
    }
    if (descriptions != null) {
        try {
            interceptorBinding.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, InterceptorBinding.class, "setDescriptions", Text[].class, e);
        }
    }
    if (interceptorClass != null) {
        interceptorBinding.interceptorClass = interceptorClass;
    }
    context.afterUnmarshal(interceptorBinding, LifecycleCallback.NONE);
    return interceptorBinding;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) NamedMethod$JAXB.readNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.readNamedMethod) NamedMethod$JAXB.writeNamedMethod(org.apache.openejb.jee.NamedMethod$JAXB.writeNamedMethod) InterceptorOrder$JAXB.readInterceptorOrder(org.apache.openejb.jee.InterceptorOrder$JAXB.readInterceptorOrder) InterceptorOrder$JAXB.writeInterceptorOrder(org.apache.openejb.jee.InterceptorOrder$JAXB.writeInterceptorOrder) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 37 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class InterceptorOrder$JAXB method _read.

public static final InterceptorOrder _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final InterceptorOrder interceptorOrder = new InterceptorOrder();
    context.beforeUnmarshal(interceptorOrder, LifecycleCallback.NONE);
    List<String> interceptorClass = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("interceptor-orderType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, InterceptorOrder.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, interceptorOrder);
            interceptorOrder.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 (("interceptor-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: interceptorClass
            final String interceptorClassItemRaw = elementReader.getElementAsString();
            final String interceptorClassItem;
            try {
                interceptorClassItem = Adapters.collapsedStringAdapterAdapter.unmarshal(interceptorClassItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (interceptorClass == null) {
                interceptorClass = interceptorOrder.interceptorClass;
                if (interceptorClass != null) {
                    interceptorClass.clear();
                } else {
                    interceptorClass = new ArrayList<String>();
                }
            }
            interceptorClass.add(interceptorClassItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "interceptor-class"));
        }
    }
    if (interceptorClass != null) {
        interceptorOrder.interceptorClass = interceptorClass;
    }
    context.afterUnmarshal(interceptorOrder, LifecycleCallback.NONE);
    return interceptorOrder;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 38 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class JMSConnectionFactory$JAXB method _read.

public static final JMSConnectionFactory _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JMSConnectionFactory JMSConnectionFactory = new JMSConnectionFactory();
    context.beforeUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<Property> property = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("jms-connection-factoryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JMSConnectionFactory.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, JMSConnectionFactory);
            JMSConnectionFactory.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 (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.name = name;
        } else if (("class-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.className = name;
        } else if (("interface-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.className = name;
        } else if (("resource-adapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.resourceAdapter = name;
        } else if (("user" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.user = name;
        } else if (("password" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.password = name;
        } else if (("client-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: name
            final String nameRaw = elementReader.getElementAsString();
            final String name;
            try {
                name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            JMSConnectionFactory.clientId = name;
        } else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
            JMSConnectionFactory.maxPoolSize = portNumber;
        } else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
            JMSConnectionFactory.minPoolSize = portNumber;
        } else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            JMSConnectionFactory.transactional = Boolean.parseBoolean(elementReader.getElementAsString());
        } else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: property
            final Property propertyItem = readProperty(elementReader, context);
            if (property == null) {
                property = JMSConnectionFactory.property;
                if (property != null) {
                    property.clear();
                } else {
                    property = new ArrayList<>();
                }
            }
            property.add(propertyItem);
        } else if (!Boolean.getBoolean("tomee.xml.passthrough")) {
            // so to pass if not important
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
        }
    }
    if (descriptions != null) {
        try {
            JMSConnectionFactory.description.set(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, JMSConnectionFactory.class, "setDescriptions", Text[].class, e);
        }
    }
    if (property != null) {
        JMSConnectionFactory.property = property;
    }
    context.afterUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
    return JMSConnectionFactory;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) Property$JAXB.readProperty(org.apache.openejb.jee.Property$JAXB.readProperty) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 39 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class JavaWsdlMapping$JAXB method _read.

public static final JavaWsdlMapping _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final JavaWsdlMapping javaWsdlMapping = new JavaWsdlMapping();
    context.beforeUnmarshal(javaWsdlMapping, LifecycleCallback.NONE);
    KeyedCollection<String, PackageMapping> packageMapping = null;
    List<JavaXmlTypeMapping> javaXmlTypeMapping = null;
    KeyedCollection<QName, ExceptionMapping> exceptionMapping = null;
    List<ServiceInterfaceMapping> serviceInterfaceMapping = null;
    KeyedCollection<String, ServiceEndpointInterfaceMapping> serviceEndpointInterfaceMapping = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("java-wsdl-mappingType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, JavaWsdlMapping.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, javaWsdlMapping);
            javaWsdlMapping.id = id;
        } else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
            // ATTRIBUTE: version
            javaWsdlMapping.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
        } else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
            context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"));
        }
    }
    // Read elements
    for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
        if (("package-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: packageMapping
            final PackageMapping packageMappingItem = readPackageMapping(elementReader, context);
            if (packageMapping == null) {
                packageMapping = javaWsdlMapping.packageMapping;
                if (packageMapping != null) {
                    packageMapping.clear();
                } else {
                    packageMapping = new KeyedCollection<String, PackageMapping>();
                }
            }
            packageMapping.add(packageMappingItem);
        } else if (("java-xml-type-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: javaXmlTypeMapping
            final JavaXmlTypeMapping javaXmlTypeMappingItem = readJavaXmlTypeMapping(elementReader, context);
            if (javaXmlTypeMapping == null) {
                javaXmlTypeMapping = javaWsdlMapping.javaXmlTypeMapping;
                if (javaXmlTypeMapping != null) {
                    javaXmlTypeMapping.clear();
                } else {
                    javaXmlTypeMapping = new ArrayList<JavaXmlTypeMapping>();
                }
            }
            javaXmlTypeMapping.add(javaXmlTypeMappingItem);
        } else if (("exception-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: exceptionMapping
            final ExceptionMapping exceptionMappingItem = readExceptionMapping(elementReader, context);
            if (exceptionMapping == null) {
                exceptionMapping = javaWsdlMapping.exceptionMapping;
                if (exceptionMapping != null) {
                    exceptionMapping.clear();
                } else {
                    exceptionMapping = new KeyedCollection<QName, ExceptionMapping>();
                }
            }
            exceptionMapping.add(exceptionMappingItem);
        } else if (("service-interface-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceInterfaceMapping
            final ServiceInterfaceMapping serviceInterfaceMappingItem = readServiceInterfaceMapping(elementReader, context);
            if (serviceInterfaceMapping == null) {
                serviceInterfaceMapping = javaWsdlMapping.serviceInterfaceMapping;
                if (serviceInterfaceMapping != null) {
                    serviceInterfaceMapping.clear();
                } else {
                    serviceInterfaceMapping = new ArrayList<ServiceInterfaceMapping>();
                }
            }
            serviceInterfaceMapping.add(serviceInterfaceMappingItem);
        } else if (("service-endpoint-interface-mapping" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: serviceEndpointInterfaceMapping
            final ServiceEndpointInterfaceMapping serviceEndpointInterfaceMappingItem = readServiceEndpointInterfaceMapping(elementReader, context);
            if (serviceEndpointInterfaceMapping == null) {
                serviceEndpointInterfaceMapping = javaWsdlMapping.serviceEndpointInterfaceMapping;
                if (serviceEndpointInterfaceMapping != null) {
                    serviceEndpointInterfaceMapping.clear();
                } else {
                    serviceEndpointInterfaceMapping = new KeyedCollection<String, ServiceEndpointInterfaceMapping>();
                }
            }
            serviceEndpointInterfaceMapping.add(serviceEndpointInterfaceMappingItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "package-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "java-xml-type-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "exception-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "service-interface-mapping"), new QName("http://java.sun.com/xml/ns/javaee", "service-endpoint-interface-mapping"));
        }
    }
    if (packageMapping != null) {
        javaWsdlMapping.packageMapping = packageMapping;
    }
    if (javaXmlTypeMapping != null) {
        javaWsdlMapping.javaXmlTypeMapping = javaXmlTypeMapping;
    }
    if (exceptionMapping != null) {
        javaWsdlMapping.exceptionMapping = exceptionMapping;
    }
    if (serviceInterfaceMapping != null) {
        javaWsdlMapping.serviceInterfaceMapping = serviceInterfaceMapping;
    }
    if (serviceEndpointInterfaceMapping != null) {
        javaWsdlMapping.serviceEndpointInterfaceMapping = serviceEndpointInterfaceMapping;
    }
    context.afterUnmarshal(javaWsdlMapping, LifecycleCallback.NONE);
    return javaWsdlMapping;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping) JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping) ExceptionMapping$JAXB.readExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.readExceptionMapping) ExceptionMapping$JAXB.writeExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.writeExceptionMapping) ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping) ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping) ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping) ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) PackageMapping$JAXB.readPackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.readPackageMapping) PackageMapping$JAXB.writePackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.writePackageMapping) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 40 with RuntimeContext

use of org.metatype.sxc.jaxb.RuntimeContext in project tomee by apache.

the class JavaWsdlMapping$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final JavaWsdlMapping javaWsdlMapping, RuntimeContext context) throws Exception {
    if (javaWsdlMapping == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (JavaWsdlMapping.class != javaWsdlMapping.getClass()) {
        context.unexpectedSubclass(writer, javaWsdlMapping, JavaWsdlMapping.class);
        return;
    }
    context.beforeMarshal(javaWsdlMapping, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = javaWsdlMapping.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(javaWsdlMapping, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ATTRIBUTE: version
    final String versionRaw = javaWsdlMapping.version;
    if (versionRaw != null) {
        String version = null;
        try {
            version = Adapters.collapsedStringAdapterAdapter.marshal(versionRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(javaWsdlMapping, "version", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "version", version);
    }
    // ELEMENT: packageMapping
    final KeyedCollection<String, PackageMapping> packageMapping = javaWsdlMapping.packageMapping;
    if (packageMapping != null) {
        for (final PackageMapping packageMappingItem : packageMapping) {
            if (packageMappingItem != null) {
                writer.writeStartElement(prefix, "package-mapping", "http://java.sun.com/xml/ns/javaee");
                writePackageMapping(writer, packageMappingItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(javaWsdlMapping, "packageMapping");
            }
        }
    }
    // ELEMENT: javaXmlTypeMapping
    final List<JavaXmlTypeMapping> javaXmlTypeMapping = javaWsdlMapping.javaXmlTypeMapping;
    if (javaXmlTypeMapping != null) {
        for (final JavaXmlTypeMapping javaXmlTypeMappingItem : javaXmlTypeMapping) {
            if (javaXmlTypeMappingItem != null) {
                writer.writeStartElement(prefix, "java-xml-type-mapping", "http://java.sun.com/xml/ns/javaee");
                writeJavaXmlTypeMapping(writer, javaXmlTypeMappingItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: exceptionMapping
    final KeyedCollection<QName, ExceptionMapping> exceptionMapping = javaWsdlMapping.exceptionMapping;
    if (exceptionMapping != null) {
        for (final ExceptionMapping exceptionMappingItem : exceptionMapping) {
            if (exceptionMappingItem != null) {
                writer.writeStartElement(prefix, "exception-mapping", "http://java.sun.com/xml/ns/javaee");
                writeExceptionMapping(writer, exceptionMappingItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: serviceInterfaceMapping
    final List<ServiceInterfaceMapping> serviceInterfaceMapping = javaWsdlMapping.serviceInterfaceMapping;
    if (serviceInterfaceMapping != null) {
        for (final ServiceInterfaceMapping serviceInterfaceMappingItem : serviceInterfaceMapping) {
            if (serviceInterfaceMappingItem != null) {
                writer.writeStartElement(prefix, "service-interface-mapping", "http://java.sun.com/xml/ns/javaee");
                writeServiceInterfaceMapping(writer, serviceInterfaceMappingItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: serviceEndpointInterfaceMapping
    final KeyedCollection<String, ServiceEndpointInterfaceMapping> serviceEndpointInterfaceMapping = javaWsdlMapping.serviceEndpointInterfaceMapping;
    if (serviceEndpointInterfaceMapping != null) {
        for (final ServiceEndpointInterfaceMapping serviceEndpointInterfaceMappingItem : serviceEndpointInterfaceMapping) {
            if (serviceEndpointInterfaceMappingItem != null) {
                writer.writeStartElement(prefix, "service-endpoint-interface-mapping", "http://java.sun.com/xml/ns/javaee");
                writeServiceEndpointInterfaceMapping(writer, serviceEndpointInterfaceMappingItem, context);
                writer.writeEndElement();
            }
        }
    }
    context.afterMarshal(javaWsdlMapping, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) QName(javax.xml.namespace.QName) JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.readJavaXmlTypeMapping) JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping(org.apache.openejb.jee.JavaXmlTypeMapping$JAXB.writeJavaXmlTypeMapping) ExceptionMapping$JAXB.readExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.readExceptionMapping) ExceptionMapping$JAXB.writeExceptionMapping(org.apache.openejb.jee.ExceptionMapping$JAXB.writeExceptionMapping) ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.writeServiceEndpointInterfaceMapping) ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping(org.apache.openejb.jee.ServiceEndpointInterfaceMapping$JAXB.readServiceEndpointInterfaceMapping) ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.readServiceInterfaceMapping) ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping(org.apache.openejb.jee.ServiceInterfaceMapping$JAXB.writeServiceInterfaceMapping) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) PackageMapping$JAXB.readPackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.readPackageMapping) PackageMapping$JAXB.writePackageMapping(org.apache.openejb.jee.PackageMapping$JAXB.writePackageMapping)

Aggregations

RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)380 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)300 QName (javax.xml.namespace.QName)202 Attribute (org.metatype.sxc.util.Attribute)190 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)182 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)155 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)154 ArrayList (java.util.ArrayList)91 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)74 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)74 JAXBObject (org.metatype.sxc.jaxb.JAXBObject)39 List (java.util.List)22 InjectionTarget$JAXB.readInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget)18 InjectionTarget$JAXB.writeInjectionTarget (org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget)18 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)14 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)14 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)14 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)14 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)14 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)14