Search in sources :

Example 1 with ServiceImplBean

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

the class WsDeployer method processPorts.

private void processPorts(final EjbModule ejbModule) throws OpenEJBException {
    // map existing webservice port declarations by servlet link
    Webservices webservices = ejbModule.getWebservices();
    final Map<String, PortComponent> portMap = new TreeMap<>();
    if (webservices != null) {
        for (final WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
            for (final PortComponent portComponent : webserviceDescription.getPortComponent()) {
                final ServiceImplBean serviceImplBean = portComponent.getServiceImplBean();
                if (serviceImplBean != null && serviceImplBean.getEjbLink() != null) {
                    portMap.put(serviceImplBean.getEjbLink(), portComponent);
                }
            }
        }
    }
    final Map<String, EjbDeployment> deploymentsByEjbName = ejbModule.getOpenejbJar().getDeploymentsByEjbName();
    WebserviceDescription webserviceDescription;
    for (final EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
        // skip if this is not a webservices endpoint
        if (!(enterpriseBean instanceof SessionBean)) {
            continue;
        }
        final SessionBean sessionBean = (SessionBean) enterpriseBean;
        if (sessionBean.getSessionType() == SessionType.STATEFUL) {
            continue;
        }
        if (sessionBean.getSessionType() == SessionType.MANAGED) {
            continue;
        }
        if (sessionBean.getServiceEndpoint() == null) {
            continue;
        }
        final EjbDeployment deployment = deploymentsByEjbName.get(sessionBean.getEjbName());
        if (deployment == null) {
            continue;
        }
        final Class<?> ejbClass;
        try {
            ejbClass = ejbModule.getClassLoader().loadClass(sessionBean.getEjbClass());
        } catch (final ClassNotFoundException e) {
            throw new OpenEJBException("Unable to load ejb class: " + sessionBean.getEjbClass(), e);
        }
        // for now, skip all non jaxws beans
        if (!JaxWsUtils.isWebService(ejbClass)) {
            continue;
        }
        // create webservices dd if not defined
        if (webservices == null) {
            webservices = new Webservices();
            ejbModule.setWebservices(webservices);
        }
        webserviceDescription = webservices.getWebserviceDescriptionMap().get(JaxWsUtils.getServiceName(ejbClass));
        if (webserviceDescription == null) {
            webserviceDescription = new WebserviceDescription();
            if (JaxWsUtils.isWebService(ejbClass)) {
                webserviceDescription.setWebserviceDescriptionName(JaxWsUtils.getServiceName(ejbClass));
            }
            // TODO else { /* create webserviceDescription name using some sort of jaxrpc data */ }
            webservices.getWebserviceDescription().add(webserviceDescription);
        }
        // add a port component if we don't alrady have one
        PortComponent portComponent = portMap.get(sessionBean.getEjbName());
        if (portComponent == null) {
            portComponent = new PortComponent();
            if (webserviceDescription.getPortComponentMap().containsKey(JaxWsUtils.getPortQName(ejbClass).getLocalPart())) {
                // when to webservices.xml is defined and when we want to
                // publish more than one port for the same implementation by configuration
                portComponent.setPortComponentName(sessionBean.getEjbName());
            } else {
                // JAX-WS Metadata specification default
                portComponent.setPortComponentName(JaxWsUtils.getPortQName(ejbClass).getLocalPart());
            }
            webserviceDescription.getPortComponent().add(portComponent);
            final ServiceImplBean serviceImplBean = new ServiceImplBean();
            serviceImplBean.setEjbLink(sessionBean.getEjbName());
            portComponent.setServiceImplBean(serviceImplBean);
            // Checking if MTOM must be enabled
            if (portComponent.getProtocolBinding() == null) {
                portComponent.setProtocolBinding(JaxWsUtils.getBindingUriFromAnn(ejbClass));
            }
            configMtomAnnotation(ejbClass, portComponent);
            if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding()) || SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding())) {
                portComponent.setEnableMtom(true);
            }
        }
        // default portId == deploymentId
        if (portComponent.getId() == null) {
            portComponent.setId(deployment.getDeploymentId());
        }
        if (webserviceDescription.getId() == null) {
            webserviceDescription.setId(deployment.getDeploymentId());
        }
        // set service endpoint interface
        if (portComponent.getServiceEndpointInterface() == null) {
            portComponent.setServiceEndpointInterface(sessionBean.getServiceEndpoint());
        }
        // default location is /@WebService.serviceName/@WebService.name
        if (JaxWsUtils.isWebService(ejbClass)) {
            if (portComponent.getWsdlPort() == null) {
                portComponent.setWsdlPort(JaxWsUtils.getPortQName(ejbClass));
            }
            if (webserviceDescription.getWsdlFile() == null) {
                webserviceDescription.setWsdlFile(JaxWsUtils.getServiceWsdlLocation(ejbClass, ejbModule.getClassLoader()));
            }
            if (portComponent.getWsdlService() == null) {
                final Definition definition = getWsdl(ejbModule, webserviceDescription.getWsdlFile());
                if (definition != null && definition.getServices().size() == 1) {
                    final QName serviceQName = (QName) definition.getServices().keySet().iterator().next();
                    portComponent.setWsdlService(serviceQName);
                } else {
                    portComponent.setWsdlService(JaxWsUtils.getServiceQName(ejbClass));
                }
            }
            if (portComponent.getLocation() == null && webserviceDescription.getWsdlFile() != null) {
                // set location based on wsdl port
                final Definition definition = getWsdl(ejbModule, webserviceDescription.getWsdlFile());
                final String locationURI = getLocationFromWsdl(definition, portComponent);
                portComponent.setLocation(locationURI);
            }
            if (portComponent.getProtocolBinding() == null) {
                portComponent.setProtocolBinding(JaxWsUtils.getBindingUriFromAnn(ejbClass));
            }
            // handlers
            if (portComponent.getHandlerChains() == null) {
                final HandlerChains handlerChains = getHandlerChains(ejbClass, sessionBean.getServiceEndpoint(), ejbModule.getClassLoader());
                portComponent.setHandlerChains(handlerChains);
            }
        }
    // TODO else { /* location JAX-RPC services comes from wsdl file */ }
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) PortComponent(org.apache.openejb.jee.PortComponent) ServiceImplBean(org.apache.openejb.jee.ServiceImplBean) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) HandlerChains(org.apache.openejb.jee.HandlerChains) Webservices(org.apache.openejb.jee.Webservices) TreeMap(java.util.TreeMap) SessionBean(org.apache.openejb.jee.SessionBean) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment)

Example 2 with ServiceImplBean

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

the class WsDeployer method processPorts.

private void processPorts(final WebModule webModule) throws OpenEJBException {
    // map existing webservice port declarations by servlet link
    Webservices webservices = webModule.getWebservices();
    final Map<String, PortComponent> portMap = new TreeMap<>();
    if (webservices != null) {
        for (final WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
            for (final PortComponent portComponent : webserviceDescription.getPortComponent()) {
                final ServiceImplBean serviceImplBean = portComponent.getServiceImplBean();
                if (serviceImplBean != null && serviceImplBean.getServletLink() != null) {
                    portMap.put(serviceImplBean.getServletLink(), portComponent);
                }
            }
        }
    }
    // map existing servlet-mapping declarations
    final WebApp webApp = webModule.getWebApp();
    final Map<String, ServletMapping> servletMappings = new TreeMap<>();
    for (final ServletMapping servletMapping : webApp.getServletMapping()) {
        servletMappings.put(servletMapping.getServletName(), servletMapping);
    }
    // add port declarations for Pojo webservices
    WebserviceDescription webserviceDescription;
    for (final Servlet servlet : webApp.getServlet()) {
        // the implementation class will be replaced by the WsServlet in the WsRegistry
        final String className = servlet.getServletClass();
        // Skip JSPs
        if (className == null) {
            continue;
        }
        try {
            final Class<?> clazz = webModule.getClassLoader().loadClass(className);
            if (JaxWsUtils.isWebService(clazz)) {
                // add servlet mapping if not already declared
                ServletMapping servletMapping = servletMappings.get(servlet.getServletName());
                final String serviceName = JaxWsUtils.getServiceName(clazz);
                if (servletMapping == null) {
                    servletMapping = new ServletMapping();
                    servletMapping.setServletName(servlet.getServletName());
                    final String location = "/" + serviceName;
                    servletMapping.getUrlPattern().add(location);
                    webApp.getServletMapping().add(servletMapping);
                }
                // if we don't have a webservices document yet, we're gonna need one now
                if (webservices == null) {
                    webservices = new Webservices();
                    webModule.setWebservices(webservices);
                }
                // add web service description element (maps to service)
                webserviceDescription = webservices.getWebserviceDescriptionMap().get(serviceName);
                if (webserviceDescription == null) {
                    webserviceDescription = new WebserviceDescription();
                    webserviceDescription.setWebserviceDescriptionName(serviceName);
                    webservices.getWebserviceDescription().add(webserviceDescription);
                }
                // define port if not already declared
                PortComponent portComponent = portMap.get(servlet.getServletName());
                if (portComponent == null) {
                    portComponent = new PortComponent();
                    portComponent.setPortComponentName(clazz.getSimpleName());
                    final ServiceImplBean serviceImplBean = new ServiceImplBean();
                    serviceImplBean.setServletLink(servlet.getServletName());
                    portComponent.setServiceImplBean(serviceImplBean);
                    webserviceDescription.getPortComponent().add(portComponent);
                }
                // default portId == host.moduleId.servletName
                if (portComponent.getId() == null) {
                    portComponent.setId(webModule.getHost() + "." + webModule.getModuleId() + "." + servlet.getServletName());
                }
                if (webserviceDescription.getId() == null) {
                    webserviceDescription.setId(webModule.getHost() + "." + webModule.getModuleId() + "." + servlet.getServletName());
                }
                // set port values from annotations if not already set
                if (portComponent.getServiceEndpointInterface() == null) {
                    portComponent.setServiceEndpointInterface(JaxWsUtils.getServiceInterface(clazz));
                }
                if (portComponent.getWsdlPort() == null) {
                    portComponent.setWsdlPort(JaxWsUtils.getPortQName(clazz));
                }
                if (webserviceDescription.getWsdlFile() == null) {
                    webserviceDescription.setWsdlFile(JaxWsUtils.getServiceWsdlLocation(clazz, webModule.getClassLoader()));
                }
                if (portComponent.getWsdlService() == null) {
                    final Definition definition = getWsdl(webModule, webserviceDescription.getWsdlFile());
                    if (definition != null && definition.getServices().size() == 1) {
                        final QName serviceQName = (QName) definition.getServices().keySet().iterator().next();
                        portComponent.setWsdlService(serviceQName);
                    } else {
                        portComponent.setWsdlService(JaxWsUtils.getServiceQName(clazz));
                    }
                }
                if (portComponent.getProtocolBinding() == null) {
                    portComponent.setProtocolBinding(JaxWsUtils.getBindingUriFromAnn(clazz));
                }
                configMtomAnnotation(clazz, portComponent);
                if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding()) || SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding())) {
                    portComponent.setEnableMtom(true);
                }
                // handlers
                if (portComponent.getHandlerChains() == null) {
                    final HandlerChains handlerChains = getHandlerChains(clazz, portComponent.getServiceEndpointInterface(), webModule.getClassLoader());
                    portComponent.setHandlerChains(handlerChains);
                }
            }
        } catch (final Exception e) {
            throw new OpenEJBException("Unable to load servlet class: " + className, e);
        }
    }
}
Also used : ServletMapping(org.apache.openejb.jee.ServletMapping) OpenEJBException(org.apache.openejb.OpenEJBException) PortComponent(org.apache.openejb.jee.PortComponent) ServiceImplBean(org.apache.openejb.jee.ServiceImplBean) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) HandlerChains(org.apache.openejb.jee.HandlerChains) Webservices(org.apache.openejb.jee.Webservices) TreeMap(java.util.TreeMap) MalformedURLException(java.net.MalformedURLException) OpenEJBException(org.apache.openejb.OpenEJBException) IOException(java.io.IOException) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) Servlet(org.apache.openejb.jee.Servlet) WebApp(org.apache.openejb.jee.WebApp)

Example 3 with ServiceImplBean

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

the class AppInfoBuilder method configureWebservices.

private List<PortInfo> configureWebservices(final Webservices webservices) {
    final List<PortInfo> portMap = new ArrayList<>();
    if (webservices == null) {
        return portMap;
    }
    for (final WebserviceDescription desc : webservices.getWebserviceDescription()) {
        final String wsdlFile = desc.getWsdlFile();
        final String serviceName = desc.getWebserviceDescriptionName();
        for (final PortComponent port : desc.getPortComponent()) {
            final PortInfo portInfo = new PortInfo();
            final ServiceImplBean serviceImplBean = port.getServiceImplBean();
            portInfo.serviceId = desc.getId();
            portInfo.portId = port.getId();
            portInfo.serviceLink = serviceImplBean.getEjbLink();
            if (portInfo.serviceLink == null) {
                portInfo.serviceLink = serviceImplBean.getServletLink();
            }
            portInfo.seiInterfaceName = port.getServiceEndpointInterface();
            portInfo.portName = port.getPortComponentName();
            portInfo.binding = port.getProtocolBinding();
            portInfo.serviceName = serviceName;
            portInfo.wsdlFile = wsdlFile;
            portInfo.mtomEnabled = port.isEnableMtom();
            portInfo.wsdlPort = port.getWsdlPort();
            portInfo.wsdlService = port.getWsdlService();
            portInfo.location = port.getLocation();
            final List<HandlerChainInfo> handlerChains = ConfigurationFactory.toHandlerChainInfo(port.getHandlerChains());
            portInfo.handlerChains.addAll(handlerChains);
            // todo configure jaxrpc mappings here
            portMap.add(portInfo);
        }
    }
    return portMap;
}
Also used : PortInfo(org.apache.openejb.assembler.classic.PortInfo) PortComponent(org.apache.openejb.jee.PortComponent) ServiceImplBean(org.apache.openejb.jee.ServiceImplBean) HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) ArrayList(java.util.ArrayList)

Example 4 with ServiceImplBean

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

the class SunConversion method mergeEjbConfig.

private void mergeEjbConfig(final EjbModule ejbModule, final SunEjbJar sunEjbJar) {
    final EjbJar ejbJar = ejbModule.getEjbJar();
    final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
    if (openejbJar == null) {
        return;
    }
    if (sunEjbJar == null) {
        return;
    }
    if (sunEjbJar.getEnterpriseBeans() == null) {
        return;
    }
    final Map<String, Map<String, WebserviceEndpoint>> endpointMap = new HashMap<>();
    for (final Ejb ejb : sunEjbJar.getEnterpriseBeans().getEjb()) {
        final EjbDeployment deployment = openejbJar.getDeploymentsByEjbName().get(ejb.getEjbName());
        if (deployment == null) {
            // warn no matching deployment
            continue;
        }
        // ejb jndi name is the deploymentId
        if (ejb.getJndiName() != null) {
            deployment.setDeploymentId(ejb.getJndiName());
        }
        // map ejb-ref jndi name declaration to deploymentId
        final Map<String, EjbLink> linksMap = deployment.getEjbLinksMap();
        for (final EjbRef ref : ejb.getEjbRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getEjbRefName();
                refName = normalize(refName);
                EjbLink link = linksMap.get(refName);
                if (link == null) {
                    link = new EjbLink();
                    link.setEjbRefName(refName);
                    linksMap.put(refName, link);
                    deployment.getEjbLink().add(link);
                }
                link.setDeployentId(ref.getJndiName());
            }
        }
        final Map<String, ResourceLink> resourceLinksMap = deployment.getResourceLinksMap();
        for (final ResourceRef ref : ejb.getResourceRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getResRefName();
                refName = normalize(refName);
                ResourceLink link = resourceLinksMap.get(refName);
                if (link == null) {
                    link = new ResourceLink();
                    link.setResRefName(refName);
                    resourceLinksMap.put(refName, link);
                    deployment.getResourceLink().add(link);
                }
                link.setResId(ref.getJndiName());
            }
        }
        for (final ResourceEnvRef ref : ejb.getResourceEnvRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getResourceEnvRefName();
                refName = normalize(refName);
                ResourceLink link = resourceLinksMap.get(refName);
                if (link == null) {
                    link = new ResourceLink();
                    link.setResRefName(refName);
                    resourceLinksMap.put(refName, link);
                    deployment.getResourceLink().add(link);
                }
                link.setResId(ref.getJndiName());
            }
        }
        for (final MessageDestinationRef ref : ejb.getMessageDestinationRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getMessageDestinationRefName();
                refName = normalize(refName);
                ResourceLink link = resourceLinksMap.get(refName);
                if (link == null) {
                    link = new ResourceLink();
                    link.setResRefName(refName);
                    resourceLinksMap.put(refName, link);
                    deployment.getResourceLink().add(link);
                }
                link.setResId(ref.getJndiName());
            }
        }
        final EnterpriseBean bean = ejbJar.getEnterpriseBeansByEjbName().get(ejb.getEjbName());
        if (bean != null) {
            final Map<String, ServiceRef> serviceRefMap = bean.getServiceRefMap();
            for (final org.apache.openejb.jee.sun.ServiceRef ref : ejb.getServiceRef()) {
                String refName = ref.getServiceRefName();
                refName = normalize(refName);
                final ServiceRef serviceRef = serviceRefMap.get(refName);
                if (serviceRef != null) {
                    final Map<String, PortComponentRef> ports = new TreeMap<>();
                    for (final PortComponentRef portComponentRef : serviceRef.getPortComponentRef()) {
                        ports.put(portComponentRef.getServiceEndpointInterface(), portComponentRef);
                    }
                    for (final PortInfo portInfo : ref.getPortInfo()) {
                        final PortComponentRef portComponentRef = ports.get(portInfo.getServiceEndpointInterface());
                        if (portComponentRef != null) {
                            final WsdlPort wsdlPort = portInfo.getWsdlPort();
                            if (wsdlPort != null) {
                                final QName qname = new QName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalpart());
                                portComponentRef.setQName(qname);
                            }
                            for (final StubProperty stubProperty : portInfo.getStubProperty()) {
                                final String name = stubProperty.getName();
                                final String value = stubProperty.getValue();
                                portComponentRef.getProperties().setProperty(name, value);
                            }
                        }
                    }
                    final String wsdlOverride = ref.getWsdlOverride();
                    if (wsdlOverride != null && wsdlOverride.length() > 0) {
                        final String serviceId = extractServiceId(wsdlOverride);
                        serviceRef.setMappedName(serviceId);
                    }
                }
            }
        }
        if (ejb.getMdbResourceAdapter() != null) {
            // resource adapter id is the MDB container ID
            final String resourceAdapterId = ejb.getMdbResourceAdapter().getResourceAdapterMid();
            deployment.setContainerId(resourceAdapterId);
        }
        endpointMap.put(ejb.getEjbName(), ejb.getWebserviceEndpointMap());
    }
    // map wsdl locations
    if (ejbModule.getWebservices() != null) {
        final Map<String, org.apache.openejb.jee.sun.WebserviceDescription> sunDescriptions = sunEjbJar.getEnterpriseBeans().getWebserviceDescriptionMap();
        for (final WebserviceDescription description : ejbModule.getWebservices().getWebserviceDescription()) {
            final org.apache.openejb.jee.sun.WebserviceDescription sunDescription = sunDescriptions.get(description.getWebserviceDescriptionName());
            // get the serviceId if specified
            String serviceId = null;
            if (sunDescription != null) {
                serviceId = extractSerivceId(sunDescription.getWsdlPublishLocation(), description.getWsdlFile());
            }
            if (serviceId != null) {
                description.setId(serviceId);
            }
            for (final PortComponent port : description.getPortComponent()) {
                // set the ejb bind location
                final ServiceImplBean bean = port.getServiceImplBean();
                if (bean != null && bean.getEjbLink() != null) {
                    final Map<String, WebserviceEndpoint> endpoints = endpointMap.get(bean.getEjbLink());
                    if (endpoints != null) {
                        final WebserviceEndpoint endpoint = endpoints.get(port.getPortComponentName());
                        if (endpoint != null && endpoint.getEndpointAddressUri() != null) {
                            port.setLocation(endpoint.getEndpointAddressUri());
                        }
                    }
                }
            }
        }
    }
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) PortComponent(org.apache.openejb.jee.PortComponent) HashMap(java.util.HashMap) WsdlPort(org.apache.openejb.jee.sun.WsdlPort) PortInfo(org.apache.openejb.jee.sun.PortInfo) MessageDestinationRef(org.apache.openejb.jee.sun.MessageDestinationRef) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) ResourceLink(org.apache.openejb.jee.oejb3.ResourceLink) EjbRef(org.apache.openejb.jee.sun.EjbRef) ResourceEnvRef(org.apache.openejb.jee.sun.ResourceEnvRef) EjbJar(org.apache.openejb.jee.EjbJar) SunEjbJar(org.apache.openejb.jee.sun.SunEjbJar) ServiceImplBean(org.apache.openejb.jee.ServiceImplBean) QName(javax.xml.namespace.QName) StubProperty(org.apache.openejb.jee.sun.StubProperty) WebserviceEndpoint(org.apache.openejb.jee.sun.WebserviceEndpoint) TreeMap(java.util.TreeMap) EjbLink(org.apache.openejb.jee.oejb3.EjbLink) PortComponentRef(org.apache.openejb.jee.PortComponentRef) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) ResourceRef(org.apache.openejb.jee.sun.ResourceRef) Ejb(org.apache.openejb.jee.sun.Ejb) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) ServiceRef(org.apache.openejb.jee.ServiceRef)

Example 5 with ServiceImplBean

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

the class PortComponent$JAXB method _write.

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

Aggregations

QName (javax.xml.namespace.QName)5 PortComponent (org.apache.openejb.jee.PortComponent)4 ServiceImplBean (org.apache.openejb.jee.ServiceImplBean)4 WebserviceDescription (org.apache.openejb.jee.WebserviceDescription)4 TreeMap (java.util.TreeMap)3 ArrayList (java.util.ArrayList)2 Definition (javax.wsdl.Definition)2 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 Addressing$JAXB.readAddressing (org.apache.openejb.jee.Addressing$JAXB.readAddressing)2 Addressing$JAXB.writeAddressing (org.apache.openejb.jee.Addressing$JAXB.writeAddressing)2 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)2 Handler$JAXB.readHandler (org.apache.openejb.jee.Handler$JAXB.readHandler)2 Handler$JAXB.writeHandler (org.apache.openejb.jee.Handler$JAXB.writeHandler)2 HandlerChains (org.apache.openejb.jee.HandlerChains)2 HandlerChains$JAXB.readHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains)2 HandlerChains$JAXB.writeHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains)2 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)2 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)2 RespectBinding$JAXB.readRespectBinding (org.apache.openejb.jee.RespectBinding$JAXB.readRespectBinding)2