Search in sources :

Example 6 with PortComponent$JAXB.writePortComponent

use of org.apache.openejb.jee.PortComponent$JAXB.writePortComponent 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<String, Map<String, WebserviceEndpoint>>();
    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<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);
                    }
                }
            }
        }
        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 7 with PortComponent$JAXB.writePortComponent

use of org.apache.openejb.jee.PortComponent$JAXB.writePortComponent in project tomee by apache.

the class WebserviceDescription$JAXB method _read.

public static final WebserviceDescription _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final WebserviceDescription webserviceDescription = new WebserviceDescription();
    context.beforeUnmarshal(webserviceDescription, LifecycleCallback.NONE);
    KeyedCollection<String, PortComponent> portComponent = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("webservice-descriptionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, WebserviceDescription.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, webserviceDescription);
            webserviceDescription.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: description
            final String descriptionRaw = elementReader.getElementAsString();
            final String description;
            try {
                description = Adapters.collapsedStringAdapterAdapter.unmarshal(descriptionRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webserviceDescription.description = description;
        } else if (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: displayName
            final String displayNameRaw = elementReader.getElementAsString();
            final String displayName;
            try {
                displayName = Adapters.collapsedStringAdapterAdapter.unmarshal(displayNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webserviceDescription.displayName = displayName;
        } else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: icon
            final Icon icon = readIcon(elementReader, context);
            webserviceDescription.icon = icon;
        } else if (("webservice-description-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: webserviceDescriptionName
            final String webserviceDescriptionNameRaw = elementReader.getElementAsString();
            final String webserviceDescriptionName;
            try {
                webserviceDescriptionName = Adapters.collapsedStringAdapterAdapter.unmarshal(webserviceDescriptionNameRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webserviceDescription.webserviceDescriptionName = webserviceDescriptionName;
        } else if (("wsdl-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: wsdlFile
            final String wsdlFileRaw = elementReader.getElementAsString();
            final String wsdlFile;
            try {
                wsdlFile = Adapters.collapsedStringAdapterAdapter.unmarshal(wsdlFileRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webserviceDescription.wsdlFile = wsdlFile;
        } else if (("jaxrpc-mapping-file" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: jaxrpcMappingFile
            final String jaxrpcMappingFileRaw = elementReader.getElementAsString();
            final String jaxrpcMappingFile;
            try {
                jaxrpcMappingFile = Adapters.collapsedStringAdapterAdapter.unmarshal(jaxrpcMappingFileRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            webserviceDescription.jaxrpcMappingFile = jaxrpcMappingFile;
        } else if (("port-component" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: portComponent
            final PortComponent portComponentItem = readPortComponent(elementReader, context);
            if (portComponent == null) {
                portComponent = webserviceDescription.portComponent;
                if (portComponent != null) {
                    portComponent.clear();
                } else {
                    portComponent = new KeyedCollection<String, PortComponent>();
                }
            }
            portComponent.add(portComponentItem);
        } 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", "webservice-description-name"), new QName("http://java.sun.com/xml/ns/javaee", "wsdl-file"), new QName("http://java.sun.com/xml/ns/javaee", "jaxrpc-mapping-file"), new QName("http://java.sun.com/xml/ns/javaee", "port-component"));
        }
    }
    if (portComponent != null) {
        webserviceDescription.portComponent = portComponent;
    }
    context.afterUnmarshal(webserviceDescription, LifecycleCallback.NONE);
    return webserviceDescription;
}
Also used : PortComponent$JAXB.readPortComponent(org.apache.openejb.jee.PortComponent$JAXB.readPortComponent) PortComponent$JAXB.writePortComponent(org.apache.openejb.jee.PortComponent$JAXB.writePortComponent) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) 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 PortComponent$JAXB.writePortComponent

use of org.apache.openejb.jee.PortComponent$JAXB.writePortComponent in project tomee by apache.

the class AxisService method getJaxRpcServiceInfo.

private JaxRpcServiceInfo getJaxRpcServiceInfo(ClassLoader classLoader) throws OpenEJBException {
    // the java to wsdl mapping file
    JavaWsdlMapping mapping = null;
    // the schema data from the wsdl file
    CommonsSchemaInfoBuilder xmlBeansSchemaInfoBuilder = new CommonsSchemaInfoBuilder(null, null);
    // webservice.xml declaration of this service
    PortComponent portComponent = null;
    // wsdl.xml declaration of this service
    Port port = null;
    String wsdlFile = null;
    XmlSchemaInfo schemaInfo = xmlBeansSchemaInfoBuilder.createSchemaInfo();
    JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(mapping, schemaInfo, portComponent, port, wsdlFile, classLoader);
    JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceInfo();
    return serviceInfo;
}
Also used : JaxRpcServiceInfo(org.apache.openejb.server.axis.assembler.JaxRpcServiceInfo) CommonsSchemaInfoBuilder(org.apache.openejb.server.axis.assembler.CommonsSchemaInfoBuilder) PortComponent(org.apache.openejb.jee.PortComponent) JaxRpcServiceInfoBuilder(org.apache.openejb.server.axis.assembler.JaxRpcServiceInfoBuilder) Port(javax.wsdl.Port) JavaWsdlMapping(org.apache.openejb.jee.JavaWsdlMapping) XmlSchemaInfo(org.apache.openejb.server.axis.assembler.XmlSchemaInfo)

Aggregations

PortComponent (org.apache.openejb.jee.PortComponent)6 WebserviceDescription (org.apache.openejb.jee.WebserviceDescription)5 QName (javax.xml.namespace.QName)4 ServiceImplBean (org.apache.openejb.jee.ServiceImplBean)4 TreeMap (java.util.TreeMap)3 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 Definition (javax.wsdl.Definition)2 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)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 PortComponent$JAXB.readPortComponent (org.apache.openejb.jee.PortComponent$JAXB.readPortComponent)2 PortComponent$JAXB.writePortComponent (org.apache.openejb.jee.PortComponent$JAXB.writePortComponent)2 Servlet (org.apache.openejb.jee.Servlet)2 SessionBean (org.apache.openejb.jee.SessionBean)2 Webservices (org.apache.openejb.jee.Webservices)2 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1