Search in sources :

Example 6 with ParamValue$JAXB.readParamValue

use of org.apache.openejb.jee.ParamValue$JAXB.readParamValue in project tomee by apache.

the class Filter$JAXB method _read.

public static final Filter _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Filter filter = new Filter();
    context.beforeUnmarshal(filter, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<ParamValue> initParam = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("filterType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Filter.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, filter);
            filter.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 = filter.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("filter-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: filterName
            final String filterNameRaw = elementReader.getElementAsString();
            final String filterName;
            try {
                filterName = Adapters.collapsedStringAdapterAdapter.unmarshal(filterNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            filter.filterName = filterName;
        } else if (("filter-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: filterClass
            final String filterClassRaw = elementReader.getElementAsString();
            final String filterClass;
            try {
                filterClass = Adapters.collapsedStringAdapterAdapter.unmarshal(filterClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            filter.filterClass = filterClass;
        } else if (("async-supported" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: asyncSupported
            final Boolean asyncSupported = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
            filter.asyncSupported = asyncSupported;
        } else if (("init-param" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: initParam
            final ParamValue initParamItem = readParamValue(elementReader, context);
            if (initParam == null) {
                initParam = filter.initParam;
                if (initParam != null) {
                    initParam.clear();
                } else {
                    initParam = new ArrayList<ParamValue>();
                }
            }
            initParam.add(initParamItem);
        } 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", "filter-name"), new QName("http://java.sun.com/xml/ns/javaee", "filter-class"), new QName("http://java.sun.com/xml/ns/javaee", "async-supported"), new QName("http://java.sun.com/xml/ns/javaee", "init-param"));
        }
    }
    if (descriptions != null) {
        try {
            filter.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Filter.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            filter.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Filter.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        filter.icon = icon;
    }
    if (initParam != null) {
        filter.initParam = initParam;
    }
    context.afterUnmarshal(filter, LifecycleCallback.NONE);
    return filter;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ParamValue$JAXB.readParamValue(org.apache.openejb.jee.ParamValue$JAXB.readParamValue) ParamValue$JAXB.writeParamValue(org.apache.openejb.jee.ParamValue$JAXB.writeParamValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 7 with ParamValue$JAXB.readParamValue

use of org.apache.openejb.jee.ParamValue$JAXB.readParamValue in project tomee by apache.

the class Handler$JAXB method _read.

public static final Handler _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Handler handler = new Handler();
    context.beforeUnmarshal(handler, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    ArrayList<Text> displayNames = null;
    LocalCollection<Icon> icon = null;
    List<ParamValue> initParam = null;
    List<QName> soapHeader = null;
    List<String> soapRole = null;
    List<String> portName = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("handlerType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Handler.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, handler);
            handler.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 = handler.icon;
                if (icon != null) {
                    icon.clear();
                } else {
                    icon = new LocalCollection<Icon>();
                }
            }
            icon.add(iconItem);
        } else if (("handler-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerName
            final String handlerNameRaw = elementReader.getElementAsString();
            final String handlerName;
            try {
                handlerName = Adapters.collapsedStringAdapterAdapter.unmarshal(handlerNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            handler.handlerName = handlerName;
        } else if (("handler-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: handlerClass
            final String handlerClassRaw = elementReader.getElementAsString();
            final String handlerClass;
            try {
                handlerClass = Adapters.collapsedStringAdapterAdapter.unmarshal(handlerClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            handler.handlerClass = handlerClass;
        } else if (("init-param" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: initParam
            final ParamValue initParamItem = readParamValue(elementReader, context);
            if (initParam == null) {
                initParam = handler.initParam;
                if (initParam != null) {
                    initParam.clear();
                } else {
                    initParam = new ArrayList<ParamValue>();
                }
            }
            initParam.add(initParamItem);
        } else if (("soap-header" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: soapHeader
            final QName soapHeaderItem = elementReader.getElementAsQName();
            if (soapHeader == null) {
                soapHeader = handler.soapHeader;
                if (soapHeader != null) {
                    soapHeader.clear();
                } else {
                    soapHeader = new ArrayList<QName>();
                }
            }
            soapHeader.add(soapHeaderItem);
        } else if (("soap-role" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: soapRole
            final String soapRoleItemRaw = elementReader.getElementAsString();
            final String soapRoleItem;
            try {
                soapRoleItem = Adapters.collapsedStringAdapterAdapter.unmarshal(soapRoleItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (soapRole == null) {
                soapRole = handler.soapRole;
                if (soapRole != null) {
                    soapRole.clear();
                } else {
                    soapRole = new ArrayList<String>();
                }
            }
            soapRole.add(soapRoleItem);
        } else if (("port-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portName
            final String portNameItemRaw = elementReader.getElementAsString();
            final String portNameItem;
            try {
                portNameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(portNameItemRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            if (portName == null) {
                portName = handler.portName;
                if (portName != null) {
                    portName.clear();
                } else {
                    portName = new ArrayList<String>();
                }
            }
            portName.add(portNameItem);
        } 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", "handler-name"), new QName("http://java.sun.com/xml/ns/javaee", "handler-class"), new QName("http://java.sun.com/xml/ns/javaee", "init-param"), new QName("http://java.sun.com/xml/ns/javaee", "soap-header"), new QName("http://java.sun.com/xml/ns/javaee", "soap-role"), new QName("http://java.sun.com/xml/ns/javaee", "port-name"));
        }
    }
    if (descriptions != null) {
        try {
            handler.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Handler.class, "setDescriptions", Text[].class, e);
        }
    }
    if (displayNames != null) {
        try {
            handler.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Handler.class, "setDisplayNames", Text[].class, e);
        }
    }
    if (icon != null) {
        handler.icon = icon;
    }
    if (initParam != null) {
        handler.initParam = initParam;
    }
    if (soapHeader != null) {
        handler.soapHeader = soapHeader;
    }
    if (soapRole != null) {
        handler.soapRole = soapRole;
    }
    if (portName != null) {
        handler.portName = portName;
    }
    context.afterUnmarshal(handler, LifecycleCallback.NONE);
    return handler;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ParamValue$JAXB.readParamValue(org.apache.openejb.jee.ParamValue$JAXB.readParamValue) ParamValue$JAXB.writeParamValue(org.apache.openejb.jee.ParamValue$JAXB.writeParamValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 8 with ParamValue$JAXB.readParamValue

use of org.apache.openejb.jee.ParamValue$JAXB.readParamValue in project tomee by apache.

the class ConfigurationFactory method toHandlerChainInfo.

public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
    final List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
    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 9 with ParamValue$JAXB.readParamValue

use of org.apache.openejb.jee.ParamValue$JAXB.readParamValue in project tomee by apache.

the class AppInfoBuilder method buildWebModules.

private void buildWebModules(final AppModule appModule, final JndiEncInfoBuilder jndiEncInfoBuilder, final AppInfo appInfo) throws OpenEJBException {
    for (final WebModule webModule : appModule.getWebModules()) {
        final WebApp webApp = webModule.getWebApp();
        final WebAppInfo webAppInfo = new WebAppInfo();
        webAppInfo.description = webApp.getDescription();
        webAppInfo.displayName = webApp.getDisplayName();
        webAppInfo.path = webModule.getJarLocation();
        webAppInfo.moduleId = webModule.getModuleId();
        webAppInfo.watchedResources.addAll(webModule.getWatchedResources());
        webAppInfo.validationInfo = ValidatorBuilder.getInfo(webModule.getValidationConfig());
        webAppInfo.uniqueId = webModule.getUniqueId();
        webAppInfo.restApplications.addAll(webModule.getRestApplications());
        webAppInfo.restClass.addAll(webModule.getRestClasses());
        webAppInfo.ejbWebServices.addAll(webModule.getEjbWebServices());
        webAppInfo.ejbRestServices.addAll(webModule.getEjbRestServices());
        webAppInfo.jaxRsProviders.addAll(webModule.getJaxrsProviders());
        for (final Map.Entry<String, Set<String>> entry : webModule.getWebAnnotatedClasses().entrySet()) {
            final ClassListInfo info = new ClassListInfo();
            info.name = entry.getKey();
            info.list.addAll(entry.getValue());
            webAppInfo.webAnnotatedClasses.add(info);
        }
        for (final Map.Entry<String, Set<String>> entry : webModule.getJsfAnnotatedClasses().entrySet()) {
            final ClassListInfo info = new ClassListInfo();
            info.name = entry.getKey();
            info.list.addAll(entry.getValue());
            webAppInfo.jsfAnnotatedClasses.add(info);
        }
        webAppInfo.host = webModule.getHost();
        if (!webModule.isStandaloneModule() && USE_EAR_AS_CONTEXT_ROOT_BASE) {
            webAppInfo.contextRoot = appModule.getModuleId() + "/" + webModule.getContextRoot();
        } else {
            webAppInfo.contextRoot = webModule.getContextRoot();
        }
        webAppInfo.sessionTimeout = 30;
        if (webModule.getWebApp() != null && webModule.getWebApp().getSessionConfig() != null) {
            for (final SessionConfig sessionConfig : webModule.getWebApp().getSessionConfig()) {
                if (sessionConfig.getSessionTimeout() != null) {
                    webAppInfo.sessionTimeout = sessionConfig.getSessionTimeout();
                    break;
                }
            }
        }
        jndiEncInfoBuilder.build(webApp, webModule.getJarLocation(), webAppInfo.moduleId, webModule.getModuleUri(), webAppInfo.jndiEnc, webAppInfo.jndiEnc);
        webAppInfo.portInfos.addAll(this.configureWebservices(webModule.getWebservices()));
        for (final Servlet servlet : webModule.getWebApp().getServlet()) {
            final ServletInfo servletInfo = new ServletInfo();
            servletInfo.servletName = servlet.getServletName();
            servletInfo.servletClass = servlet.getServletClass();
            servletInfo.mappings = webModule.getWebApp().getServletMappings(servletInfo.servletName);
            for (final ParamValue pv : servlet.getInitParam()) {
                final ParamValueInfo pvi = new ParamValueInfo();
                pvi.name = pv.getParamName();
                pvi.value = pv.getParamValue();
                servletInfo.initParams.add(pvi);
            }
            webAppInfo.servlets.add(servletInfo);
        }
        for (final Listener listener : webModule.getWebApp().getListener()) {
            final ListenerInfo listenerInfo = new ListenerInfo();
            listenerInfo.classname = listener.getListenerClass();
            webAppInfo.listeners.add(listenerInfo);
        }
        for (final Filter filter : webModule.getWebApp().getFilter()) {
            final FilterInfo filterInfo = new FilterInfo();
            filterInfo.name = filter.getFilterName();
            filterInfo.classname = filter.getFilterClass();
            filterInfo.mappings = webModule.getWebApp().getFilterMappings(filter.getFilterName());
            for (final ParamValue pv : filter.getInitParam()) {
                filterInfo.initParams.put(pv.getParamName(), pv.getParamValue());
            }
            webAppInfo.filters.add(filterInfo);
        }
        appInfo.webApps.add(webAppInfo);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) MessageListener(org.apache.openejb.jee.MessageListener) Listener(org.apache.openejb.jee.Listener) SessionConfig(org.apache.openejb.jee.SessionConfig) ParamValue(org.apache.openejb.jee.ParamValue) ClassListInfo(org.apache.openejb.assembler.classic.ClassListInfo) ServletInfo(org.apache.openejb.assembler.classic.ServletInfo) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) ListenerInfo(org.apache.openejb.assembler.classic.ListenerInfo) ParamValueInfo(org.apache.openejb.assembler.classic.ParamValueInfo) Filter(org.apache.openejb.jee.Filter) Servlet(org.apache.openejb.jee.Servlet) Map(java.util.Map) HashMap(java.util.HashMap) FilterInfo(org.apache.openejb.assembler.classic.FilterInfo) WebApp(org.apache.openejb.jee.WebApp)

Example 10 with ParamValue$JAXB.readParamValue

use of org.apache.openejb.jee.ParamValue$JAXB.readParamValue in project tomee by apache.

the class Validator$JAXB method _read.

public static final Validator _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final Validator validator = new Validator();
    context.beforeUnmarshal(validator, LifecycleCallback.NONE);
    ArrayList<Text> descriptions = null;
    List<ParamValue> initParam = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("validatorType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, Validator.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, validator);
            validator.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 (("validator-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: validatorClass
            final String validatorClassRaw = elementReader.getElementAsString();
            final String validatorClass;
            try {
                validatorClass = Adapters.collapsedStringAdapterAdapter.unmarshal(validatorClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            validator.validatorClass = validatorClass;
        } else if (("init-param" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: initParam
            final ParamValue initParamItem = readParamValue(elementReader, context);
            if (initParam == null) {
                initParam = validator.initParam;
                if (initParam != null) {
                    initParam.clear();
                } else {
                    initParam = new ArrayList<ParamValue>();
                }
            }
            initParam.add(initParamItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "validator-class"), new QName("http://java.sun.com/xml/ns/javaee", "init-param"));
        }
    }
    if (descriptions != null) {
        try {
            validator.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
        } catch (final Exception e) {
            context.setterError(reader, Validator.class, "setDescriptions", Text[].class, e);
        }
    }
    if (initParam != null) {
        validator.initParam = initParam;
    }
    context.afterUnmarshal(validator, LifecycleCallback.NONE);
    return validator;
}
Also used : Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ParamValue$JAXB.readParamValue(org.apache.openejb.jee.ParamValue$JAXB.readParamValue) ParamValue$JAXB.writeParamValue(org.apache.openejb.jee.ParamValue$JAXB.writeParamValue) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Aggregations

ParamValue$JAXB.readParamValue (org.apache.openejb.jee.ParamValue$JAXB.readParamValue)10 ParamValue$JAXB.writeParamValue (org.apache.openejb.jee.ParamValue$JAXB.writeParamValue)10 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)10 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)10 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)10 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)8 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)8 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)8 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 Attribute (org.metatype.sxc.util.Attribute)5 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)5 AbsoluteOrdering$JAXB.readAbsoluteOrdering (org.apache.openejb.jee.AbsoluteOrdering$JAXB.readAbsoluteOrdering)2 AbsoluteOrdering$JAXB.writeAbsoluteOrdering (org.apache.openejb.jee.AbsoluteOrdering$JAXB.writeAbsoluteOrdering)2 DataSource$JAXB.readDataSource (org.apache.openejb.jee.DataSource$JAXB.readDataSource)2 DataSource$JAXB.writeDataSource (org.apache.openejb.jee.DataSource$JAXB.writeDataSource)2 EjbLocalRef$JAXB.readEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.readEjbLocalRef)2 EjbLocalRef$JAXB.writeEjbLocalRef (org.apache.openejb.jee.EjbLocalRef$JAXB.writeEjbLocalRef)2 EjbRef$JAXB.readEjbRef (org.apache.openejb.jee.EjbRef$JAXB.readEjbRef)2 EjbRef$JAXB.writeEjbRef (org.apache.openejb.jee.EjbRef$JAXB.writeEjbRef)2