geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r525383 - in /geronimo/server/trunk/modules: geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
Date Wed, 04 Apr 2007 03:24:27 GMT
Author: gawor
Date: Tue Apr  3 20:24:26 2007
New Revision: 525383

URL: http://svn.apache.org/viewvc?view=rev&rev=525383
Log:
applied patch for G3045

Modified:
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?view=diff&rev=525383&r1=525382&r2=525383
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
Tue Apr  3 20:24:26 2007
@@ -56,6 +56,8 @@
 import org.apache.geronimo.xbeans.javaee.WebserviceDescriptionType;
 import org.apache.geronimo.xbeans.javaee.WebservicesDocument;
 import org.apache.geronimo.xbeans.javaee.WebservicesType;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
 
 public class Axis2Builder extends JAXWSServiceBuilder {
 
@@ -83,74 +85,83 @@
         log.debug("Parsing descriptor " + wsDDUrl);
 
         Map<String, PortInfo> map = null;
+        XmlCursor cursor = null;
 
         try {
-            WebservicesType wst = WebservicesDocument.Factory.parse(in).getWebservices();
+            XmlObject xobj = XmlObject.Factory.parse(in);
+           
+            cursor = xobj.newCursor();
+            cursor.toStartDoc();
+            cursor.toFirstChild();
+            //the checking is needed as we also send JAX-RPC based webservices.xml here
+            if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI()))
{
+                WebservicesDocument wd = (WebservicesDocument)xobj.changeType(WebservicesDocument.type);
+                WebservicesType wst = wd.getWebservices();
+
+                for (WebserviceDescriptionType desc : wst.getWebserviceDescriptionArray())
{
+                    String wsdlFile = null;
+                    if (desc.getWsdlFile() != null) {
+                        wsdlFile = getString(desc.getWsdlFile().getStringValue());
+                    }
+
+                    String serviceName = desc.getWebserviceDescriptionName().getStringValue();
+
+                    for (PortComponentType port : desc.getPortComponentArray()) {
+
+                        PortInfo portInfo = new PortInfo();
+                        String serviceLink = null;
+                        ServiceImplBeanType beanType = port.getServiceImplBean();
+                        if (beanType.getEjbLink() != null) {
+                            serviceLink = beanType.getEjbLink().getStringValue();
+                        } else if (beanType.getServletLink().getStringValue() != null) {
+                            serviceLink = beanType.getServletLink().getStringValue();
+                        }
+                        portInfo.setServiceLink(serviceLink);
+
+                        if (port.getServiceEndpointInterface() != null) {
+                            String sei = port.getServiceEndpointInterface().getStringValue();
+                            portInfo.setServiceEndpointInterfaceName(sei);
+                        }
+
+                        String portName = port.getPortComponentName().getStringValue();
+                        portInfo.setPortName(portName);
+
+                        portInfo.setProtocolBinding(port.getProtocolBinding());
+                        portInfo.setServiceName(serviceName);
+                        portInfo.setWsdlFile(wsdlFile);
+
+                        if (port.getEnableMtom() != null) {
+                            portInfo.setEnableMTOM(port.getEnableMtom().getBooleanValue());
+                        }
+
+                        //TODO: There can be a better method than this :)
+                        if(port.getHandlerChains() != null){
+                            StringBuffer chains = new StringBuffer("<handler-chains xmlns=\"http://java.sun.com/xml/ns/javaee\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
+                            chains.append(port.getHandlerChains().xmlText());
+                            chains.append("</handler-chains>");
+                            portInfo.setHandlersAsXML(chains.toString());
+                        }
+
+                        if (port.getWsdlPort() != null) {
+                            portInfo.setWsdlPort(port.getWsdlPort().getQNameValue());
+                        }
+
+                        if (port.getWsdlService() != null) {
+                            portInfo.setWsdlService(port.getWsdlService().getQNameValue());
+                        }
+
+                        String location = (String) correctedPortLocations.get(serviceLink);
+                        portInfo.setLocation(location);
+
+                        if (map == null) {
+                            map = new HashMap<String, PortInfo>();
+                        }
 
-            for (WebserviceDescriptionType desc : wst.getWebserviceDescriptionArray()) {
-                String wsdlFile = null;
-                if (desc.getWsdlFile() != null) {
-                    wsdlFile = getString(desc.getWsdlFile().getStringValue());
-                }
-
-                String serviceName = desc.getWebserviceDescriptionName().getStringValue();
-
-                for (PortComponentType port : desc.getPortComponentArray()) {
-
-                    PortInfo portInfo = new PortInfo();
-                    String serviceLink = null;
-                    ServiceImplBeanType beanType = port.getServiceImplBean();
-                    if (beanType.getEjbLink() != null) {
-                        serviceLink = beanType.getEjbLink().getStringValue();
-                    } else if (beanType.getServletLink().getStringValue() != null) {
-                        serviceLink = beanType.getServletLink().getStringValue();
-                    }
-                    portInfo.setServiceLink(serviceLink);
-
-                    if (port.getServiceEndpointInterface() != null) {
-                        String sei = port.getServiceEndpointInterface().getStringValue();
-                        portInfo.setServiceEndpointInterfaceName(sei);
+                        map.put(serviceLink, portInfo);
                     }
-
-                    String portName = port.getPortComponentName().getStringValue();
-                    portInfo.setPortName(portName);
-
-                    portInfo.setProtocolBinding(port.getProtocolBinding());
-                    portInfo.setServiceName(serviceName);
-                    portInfo.setWsdlFile(wsdlFile);
-
-                    if (port.getEnableMtom() != null) {
-                        portInfo.setEnableMTOM(port.getEnableMtom().getBooleanValue());
-                    }
-
-                    //portInfo.setHandlers(HandlerChainsTypeImpl.class, port.getHandlerChains());
-                    //TODO: There can be a better method than this :)
-                    if(port.getHandlerChains() != null){
-                        StringBuffer chains = new StringBuffer("<handler-chains xmlns=\"http://java.sun.com/xml/ns/javaee\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
-                        chains.append(port.getHandlerChains().xmlText());
-                        chains.append("</handler-chains>");
-                        portInfo.setHandlersAsXML(chains.toString());
-                    }
-
-                    if (port.getWsdlPort() != null) {
-                        portInfo.setWsdlPort(port.getWsdlPort().getQNameValue());
-                    }
-
-                    if (port.getWsdlService() != null) {
-                        portInfo.setWsdlService(port.getWsdlService().getQNameValue());
-                    }
-
-                    String location = (String) correctedPortLocations.get(serviceLink);
-                    portInfo.setLocation(location);
-
-                    if (map == null) {
-                        map = new HashMap<String, PortInfo>();
-                    }
-
-                    map.put(serviceLink, portInfo);
                 }
             }
-
+            
             return map;
         } catch (FileNotFoundException e) {
             return Collections.EMPTY_MAP;
@@ -160,6 +171,7 @@
             throw new DeploymentException("Unknown deployment error", ex);
         } finally {
             try {
+                cursor.dispose();
                 in.close();
             } catch (IOException e) {
                 // ignore

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?view=diff&rev=525383&r1=525382&r2=525383
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
Tue Apr  3 20:24:26 2007
@@ -81,64 +81,20 @@
         Map portMap = null;
         String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
         JarFile moduleFile = module.getModuleFile();
-        if (containsAnnotation(module, isEJB)) {
-            try {
-                URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
-                InputStream in = wsDDUrl.openStream();
-                portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
-            } catch (IOException e) {
-                // webservices.xml does not exist
-                portMap = discoverWebServices(module, isEJB, servletLocations);
-            }
-
-            if (portMap != null && !portMap.isEmpty()) {
-                EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
-                sharedContext.put(getKey(), portMap);
-            }
+        try {
+            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
+            InputStream in = wsDDUrl.openStream();
+            portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
+        } catch (IOException e) {
+            // webservices.xml does not exist
+            portMap = discoverWebServices(module, isEJB, servletLocations);
         }
 
-    }
-    
-    private boolean containsAnnotation(Module module, boolean isEJB) throws DeploymentException
{
-        if (isEJB) {
-            ClassLoader classLoader = module.getEarContext().getClassLoader();
-            EjbModule ejbModule = (EjbModule) module;
-            for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
-                if (bean.type != EnterpriseBeanInfo.STATELESS) {
-                    continue;
-                }            
-                try {
-                    Class ejbClass = classLoader.loadClass(bean.ejbClass);
-                    if (JAXWSUtils.isWebService(ejbClass)) {
-                        return true;
-                    }
-                } catch (Exception e) {
-                    throw new DeploymentException("Failed to load ejb class "
-                                                  + bean.ejbName, e);
-                }
-            }
-        } else {
-            ClassLoader classLoader = module.getEarContext().getClassLoader();
-            WebAppType webApp = (WebAppType) module.getSpecDD();
-
-            ServletType[] servletTypes = webApp.getServletArray();
-            for (ServletType servletType : servletTypes) {
-                if (servletType.isSetServletClass()) {
-                    String servletClassName = servletType.getServletClass().getStringValue().trim();
-                    try {
-                        Class servletClass = classLoader.loadClass(servletClassName);
-                        if (JAXWSUtils.isWebService(servletClass)) {
-                            return true;
-                        }
-                    } catch (Exception e) {
-                        throw new DeploymentException("Failed to load servlet class "
-                                                      + servletClassName, e);
-                    }
-                }
-            }
-            
+        if (portMap != null && !portMap.isEmpty()) {
+            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+            sharedContext.put(getKey(), portMap);
         }
-        return false;
+
     }
 
     private Map<String, PortInfo> discoverWebServices(Module module,



Mime
View raw message