Search in sources :

Example 1 with WebserviceDescription$JAXB.readWebserviceDescription

use of org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription in project tomee by apache.

the class SunConversion method convertModule.

public void convertModule(final WebModule webModule) {
    if (webModule == null) {
        return;
    }
    final WebApp webApp = webModule.getWebApp();
    if (webApp == null) {
        return;
    }
    final SunWebApp sunWebApp = getSunWebApp(webModule);
    if (sunWebApp == null) {
        return;
    }
    if (sunWebApp.getContextRoot() != null) {
        webModule.setContextRoot(sunWebApp.getContextRoot());
    }
    // map ejb-refs
    final Map<String, JndiReference> refMap = new TreeMap<String, JndiReference>();
    refMap.putAll(webApp.getEjbRefMap());
    refMap.putAll(webApp.getEjbLocalRefMap());
    // map ejb-ref jndi name declaration to deploymentId
    for (final EjbRef ref : sunWebApp.getEjbRef()) {
        if (ref.getJndiName() != null) {
            final String refName = ref.getEjbRefName();
            JndiReference ejbRef = refMap.get(refName);
            if (ejbRef == null) {
                ejbRef = new org.apache.openejb.jee.EjbRef();
                ejbRef.setName(refName);
                refMap.put(refName, ejbRef);
                webApp.getEjbRef().add((org.apache.openejb.jee.EjbRef) ejbRef);
            }
            ejbRef.setMappedName(ref.getJndiName());
        }
    }
    // map resource-env-refs and message-destination-refs
    final Map<String, JndiReference> resEnvMap = new TreeMap<String, JndiReference>();
    resEnvMap.putAll(webApp.getResourceRefMap());
    resEnvMap.putAll(webApp.getResourceEnvRefMap());
    resEnvMap.putAll(webApp.getMessageDestinationRefMap());
    for (final ResourceRef ref : sunWebApp.getResourceRef()) {
        if (ref.getJndiName() != null) {
            String refName = ref.getResRefName();
            refName = normalize(refName);
            final JndiReference resEnvRef = resEnvMap.get(refName);
            if (resEnvRef != null) {
                resEnvRef.setMappedName(ref.getJndiName());
            }
        }
    }
    for (final ResourceEnvRef ref : sunWebApp.getResourceEnvRef()) {
        if (ref.getJndiName() != null) {
            String refName = ref.getResourceEnvRefName();
            refName = normalize(refName);
            final JndiReference resEnvRef = resEnvMap.get(refName);
            if (resEnvRef != null) {
                resEnvRef.setMappedName(ref.getJndiName());
            }
        }
    }
    for (final MessageDestinationRef ref : sunWebApp.getMessageDestinationRef()) {
        if (ref.getJndiName() != null) {
            String refName = ref.getMessageDestinationRefName();
            refName = normalize(refName);
            final JndiReference resEnvRef = resEnvMap.get(refName);
            if (resEnvRef != null) {
                resEnvRef.setMappedName(ref.getJndiName());
            }
        }
    }
    final Map<String, ServiceRef> serviceRefMap = webApp.getServiceRefMap();
    for (final org.apache.openejb.jee.sun.ServiceRef ref : sunWebApp.getServiceRef()) {
        String refName = ref.getServiceRefName();
        refName = normalize(refName);
        final ServiceRef serviceRef = serviceRefMap.get(refName);
        if (serviceRef != null) {
            final Map<String, PortComponentRef> ports = new TreeMap<String, PortComponentRef>();
            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);
            }
        }
    }
    // map wsdl locations
    if (webModule.getWebservices() != null) {
        final Map<String, WebserviceDescription> descriptions = webModule.getWebservices().getWebserviceDescriptionMap();
        for (final org.apache.openejb.jee.sun.WebserviceDescription sunDescription : sunWebApp.getWebserviceDescription()) {
            final WebserviceDescription description = descriptions.get(sunDescription.getWebserviceDescriptionName());
            if (description == null) {
                continue;
            }
            final String serviceId = extractSerivceId(sunDescription.getWsdlPublishLocation(), description.getWsdlFile());
            if (serviceId != null) {
                description.setId(serviceId);
            }
        }
    }
}
Also used : SunWebApp(org.apache.openejb.jee.sun.SunWebApp) WsdlPort(org.apache.openejb.jee.sun.WsdlPort) PortInfo(org.apache.openejb.jee.sun.PortInfo) MessageDestinationRef(org.apache.openejb.jee.sun.MessageDestinationRef) JndiReference(org.apache.openejb.jee.JndiReference) EjbRef(org.apache.openejb.jee.sun.EjbRef) ResourceEnvRef(org.apache.openejb.jee.sun.ResourceEnvRef) QName(javax.xml.namespace.QName) StubProperty(org.apache.openejb.jee.sun.StubProperty) TreeMap(java.util.TreeMap) PortComponentRef(org.apache.openejb.jee.PortComponentRef) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) ResourceRef(org.apache.openejb.jee.sun.ResourceRef) ServiceRef(org.apache.openejb.jee.ServiceRef) SunWebApp(org.apache.openejb.jee.sun.SunWebApp) WebApp(org.apache.openejb.jee.WebApp)

Example 2 with WebserviceDescription$JAXB.readWebserviceDescription

use of org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription 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<String, PortComponent>();
    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 3 with WebserviceDescription$JAXB.readWebserviceDescription

use of org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription 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<String, PortComponent>();
    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<String, ServletMapping>();
    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 4 with WebserviceDescription$JAXB.readWebserviceDescription

use of org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription in project tomee by apache.

the class Webservices$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final Webservices webservices, RuntimeContext context) throws Exception {
    if (webservices == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (Webservices.class != webservices.getClass()) {
        context.unexpectedSubclass(writer, webservices, Webservices.class);
        return;
    }
    context.beforeMarshal(webservices, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = webservices.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(webservices, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ATTRIBUTE: version
    final String versionRaw = webservices.version;
    if (versionRaw != null) {
        String version = null;
        try {
            version = Adapters.collapsedStringAdapterAdapter.marshal(versionRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(webservices, "version", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "version", version);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = webservices.getDescriptions();
    } catch (final Exception e) {
        context.getterError(webservices, "descriptions", Webservices.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(webservices, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = webservices.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(webservices, "displayNames", Webservices.class, "getDisplayNames", e);
    }
    if (displayNames != null) {
        for (final Text displayNamesItem : displayNames) {
            if (displayNamesItem != null) {
                writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, displayNamesItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(webservices, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = webservices.icon;
    if (icon != null) {
        for (final Icon iconItem : icon) {
            if (iconItem != null) {
                writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
                writeIcon(writer, iconItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(webservices, "icon");
            }
        }
    }
    // ELEMENT: webserviceDescription
    final KeyedCollection<String, WebserviceDescription> webserviceDescription = webservices.webserviceDescription;
    if (webserviceDescription != null) {
        for (final WebserviceDescription webserviceDescriptionItem : webserviceDescription) {
            if (webserviceDescriptionItem != null) {
                writer.writeStartElement(prefix, "webservice-description", "http://java.sun.com/xml/ns/javaee");
                writeWebserviceDescription(writer, webserviceDescriptionItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(webservices, "webserviceDescription");
            }
        }
    }
    context.afterMarshal(webservices, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) WebserviceDescription$JAXB.writeWebserviceDescription(org.apache.openejb.jee.WebserviceDescription$JAXB.writeWebserviceDescription) WebserviceDescription$JAXB.readWebserviceDescription(org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription) 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)

Example 5 with WebserviceDescription$JAXB.readWebserviceDescription

use of org.apache.openejb.jee.WebserviceDescription$JAXB.readWebserviceDescription in project tomee by apache.

the class AppInfoBuilder method configureWebservices.

private List<PortInfo> configureWebservices(final Webservices webservices) {
    final List<PortInfo> portMap = new ArrayList<PortInfo>();
    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)

Aggregations

WebserviceDescription (org.apache.openejb.jee.WebserviceDescription)7 QName (javax.xml.namespace.QName)5 PortComponent (org.apache.openejb.jee.PortComponent)5 TreeMap (java.util.TreeMap)4 ServiceImplBean (org.apache.openejb.jee.ServiceImplBean)4 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 Webservices (org.apache.openejb.jee.Webservices)3 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Definition (javax.wsdl.Definition)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 HandlerChains (org.apache.openejb.jee.HandlerChains)2 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)2 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)2 PortComponentRef (org.apache.openejb.jee.PortComponentRef)2 ServiceRef (org.apache.openejb.jee.ServiceRef)2 Servlet (org.apache.openejb.jee.Servlet)2 SessionBean (org.apache.openejb.jee.SessionBean)2 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)2