geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r548475 - in /geronimo/server/trunk/modules: geronimo-axis-builder/ geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/ geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/ geronimo-webservic...
Date Mon, 18 Jun 2007 20:15:53 GMT
Author: gawor
Date: Mon Jun 18 13:15:51 2007
New Revision: 548475

URL: http://svn.apache.org/viewvc?view=rev&rev=548475
Log:
handle jaxrpc web services in javaee webservices.xml file

Added:
    geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-axis-builder/pom.xml
    geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java
    geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
    geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/PortInfo.java
    geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/WSDescriptorParser.java
    geronimo/server/trunk/modules/geronimo-webservices-builder/src/test/java/org/apache/geronimo/webservices/builder/ParsingTest.java

Modified: geronimo/server/trunk/modules/geronimo-axis-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis-builder/pom.xml?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis-builder/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-axis-builder/pom.xml Mon Jun 18 13:15:51 2007
@@ -52,6 +52,11 @@
             <artifactId>axis</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

Modified: geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java
Mon Jun 18 13:15:51 2007
@@ -32,6 +32,7 @@
 import java.util.Set;
 import java.util.jar.JarFile;
 
+import javax.jws.WebService;
 import javax.wsdl.Binding;
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
@@ -42,6 +43,7 @@
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.xml.namespace.QName;
 import javax.xml.rpc.handler.HandlerInfo;
+import javax.xml.ws.WebServiceProvider;
 
 import org.apache.axis.constants.Style;
 import org.apache.axis.description.JavaServiceDesc;
@@ -124,8 +126,7 @@
         }
     }
 
-    public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module,
String seiClassName, DeploymentContext context) throws DeploymentException {
-        ClassLoader cl = context.getClassLoader();
+    public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module,
String servletClassName, DeploymentContext context) throws DeploymentException {
         Map sharedContext = ((WebModule) module).getSharedContext();
         Map portInfoMap = (Map) sharedContext.get(KEY);
         PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
@@ -133,15 +134,25 @@
             //not ours
             return false;
         }
+        
+        ClassLoader cl = context.getClassLoader();
+        Class serviceClass = loadClass(servletClassName, cl);        
+        if (isJAXWSWebService(serviceClass)) {
+            // This is a JAX-WS web service so ignore
+            return false;
+        }
+        
+        portInfo.initialize(module.getModuleFile());
+        
         ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, cl);
         JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc();
 
-        targetGBean.setAttribute("pojoClassName", seiClassName);
+        targetGBean.setAttribute("pojoClassName", servletClassName);
         RPCProvider provider = new POJOProvider();
 
         SOAPService service = new SOAPService(null, provider, null);
         service.setServiceDescription(serviceDesc);
-        service.setOption("className", seiClassName);
+        service.setOption("className", servletClassName);
 
         HandlerInfoChainFactory handlerInfoChainFactory = new HandlerInfoChainFactory(serviceInfo.getHandlerInfos());
         service.setOption(org.apache.axis.Constants.ATTR_HANDLERINFOCHAIN, handlerInfoChainFactory);
@@ -180,6 +191,16 @@
             //not ours
             return false;
         }
+        
+        String beanClassName = (String)targetGBean.getAttribute("ejbClass");
+        Class serviceClass = loadClass(beanClassName, classLoader);
+        if (isJAXWSWebService(serviceClass)) {
+            // This is a JAX-WS web service so ignore
+            return false;
+        }
+        
+        portInfo.initialize(module.getModuleFile());
+        
         ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, classLoader);
         targetGBean.setAttribute("serviceInfo", serviceInfo);
         JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc();
@@ -491,6 +512,19 @@
     }
 
 
+    Class<?> loadClass(String className, ClassLoader loader) throws DeploymentException
{
+        try {
+            return loader.loadClass(className);
+        } catch (ClassNotFoundException ex) {
+            throw new DeploymentException("Unable to load Web Service class: " + className);
+        }
+    }
+    
+    static boolean isJAXWSWebService(Class clazz) {
+        return (clazz.isAnnotationPresent(WebService.class) || 
+                clazz.isAnnotationPresent(WebServiceProvider.class));
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
 
     static {

Modified: geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
Mon Jun 18 13:15:51 2007
@@ -130,6 +130,9 @@
 
             GBeanData ejbWebServiceGBean = new GBeanData(ejbWebServiceName, EjbWebServiceGBean.GBEAN_INFO);
 
+            ejbWebServiceGBean.setAttribute("ejbName", ejbName);
+            ejbWebServiceGBean.setAttribute("ejbClass", bean.ejbClass);
+            
             WebServiceBindingType wsBinding = wsBindingMap.get(ejbName);
             if (wsBinding != null) {
                 List<String> ddVirtualHosts = wsBinding.getWebServiceVirtualHost();
@@ -169,6 +172,9 @@
                 ejbWebServiceGBean.setReferencePattern("EjbDeployment", sessionName);
             }
 
+            ejbWebServiceGBean.clearAttribute("ejbName");
+            ejbWebServiceGBean.clearAttribute("ejbClass");
+            
         }
     }
 

Modified: geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/PortInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/PortInfo.java?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/PortInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/PortInfo.java
Mon Jun 18 13:15:51 2007
@@ -17,10 +17,14 @@
 package org.apache.geronimo.webservices.builder;
 
 import java.net.URI;
+import java.util.Map;
+import java.util.jar.JarFile;
+
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.xml.namespace.QName;
 
+import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
 import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
@@ -31,31 +35,28 @@
 public class PortInfo {
     private final String portComponentName;
     private final QName portQName;
-    private final SchemaInfoBuilder schemaInfoBuilder;
-    private final JavaWsdlMappingType javaWsdlMapping;
-    private final ServiceEndpointInterfaceMappingType seiMapping;
     private final String seInterfaceName;
     private final PortComponentHandlerType[] handlers;
-    private final Port port;
     private final URI contextURI;
+    private final SharedPortInfo sharedPortInfo;
+    
+    // set after initialize is called
+    private SchemaInfoBuilder schemaInfoBuilder;
+    private JavaWsdlMappingType javaWsdlMapping;
+    private Port port;
+    private ServiceEndpointInterfaceMappingType seiMapping;
 
-    private final String wsdlLocation;
-
-    public PortInfo(String portComponentName, QName portQName, SchemaInfoBuilder schemaInfoBuilder,
JavaWsdlMappingType javaWsdlMapping, String seiInterfaceName, PortComponentHandlerType[] handlers,
Port port, ServiceEndpointInterfaceMappingType seiMapping, String wsdlLocation, URI contextURI)
{
+    public PortInfo(SharedPortInfo sharedPortInfo, String portComponentName, QName portQName,
String seiInterfaceName, PortComponentHandlerType[] handlers, URI contextURI) {
+        this.sharedPortInfo = sharedPortInfo;
         this.portComponentName = portComponentName;
         this.portQName = portQName;
-        this.schemaInfoBuilder = schemaInfoBuilder;
-        this.javaWsdlMapping = javaWsdlMapping;
         this.seInterfaceName = seiInterfaceName;
         this.handlers = handlers;
-        this.port = port;
-        this.seiMapping = seiMapping;
-        this.wsdlLocation = wsdlLocation;
         this.contextURI = contextURI;
     }
 
     public String getWsdlLocation() {
-        return wsdlLocation;
+        return this.sharedPortInfo.getWsdlLocation();
     }
 
     public String getPortComponentName() {
@@ -65,15 +66,15 @@
     public QName getPortQName() {
         return portQName;
     }
-
+    
     public Port getPort() {
         return port;
     }
-
+    
     public SchemaInfoBuilder getSchemaInfoBuilder() {
         return schemaInfoBuilder;
     }
-
+    
     public Definition getDefinition() {
         return schemaInfoBuilder.getDefinition();
     }
@@ -86,7 +87,6 @@
         return seInterfaceName;
     }
 
-
     public ServiceEndpointInterfaceMappingType getServiceEndpointInterfaceMapping() {
         return seiMapping;
     }
@@ -97,5 +97,28 @@
 
     public URI getContextURI() {
         return contextURI;
+    }
+    
+    public void initialize(JarFile moduleFile) throws DeploymentException {
+        this.sharedPortInfo.initialize(moduleFile);
+        
+        this.schemaInfoBuilder = this.sharedPortInfo.getSchemaInfoBuilder();
+        this.javaWsdlMapping = this.sharedPortInfo.getJavaWsdlMapping();
+                               
+        QName portQName = getPortQName();
+        URI contextURI = getContextURI();
+        String portComponentName = getPortComponentName();
+        String seiInterfaceName = getServiceEndpointInterfaceName();
+                              
+        Map wsdlPortMap = this.schemaInfoBuilder.getPortMap();        
+        Port wsdlPort = (Port) wsdlPortMap.get(portQName.getLocalPart());
+        if (wsdlPort == null) {
+            throw new DeploymentException("No WSDL Port definition for port-component " +
portComponentName);
+        }
+        this.port = wsdlPort;
+                
+        this.seiMapping = this.sharedPortInfo.getSEIMappings().get(seiInterfaceName);
+        
+        this.schemaInfoBuilder.movePortLocation(portQName.getLocalPart(), contextURI.toString());
     }
 }

Added: geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java?view=auto&rev=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java
(added)
+++ geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java
Mon Jun 18 13:15:51 2007
@@ -0,0 +1,106 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.webservices.builder;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarFile;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
+import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
+ */
+public class SharedPortInfo {
+
+    private String jaxrpcMappingFile;
+    private String wsdlLocation;
+    private JavaWsdlMappingType javaWsdlMapping;
+    private SchemaInfoBuilder schemaInfoBuilder;
+
+    public SharedPortInfo(String wsdlLocation, String jaxrpcMappingFile) {
+        this.wsdlLocation = wsdlLocation;
+        this.jaxrpcMappingFile = jaxrpcMappingFile;
+    }
+
+    public String getWsdlLocation() {
+        return this.wsdlLocation;
+    }
+    
+    public String getJaxrpcMappingFile() {
+        return this.jaxrpcMappingFile;
+    }
+    
+    public void initialize(JarFile moduleFile) throws DeploymentException {
+        if (this.jaxrpcMappingFile == null) {
+            throw new DeploymentException("JAX-RPC mapping file is required.");
+        }
+        if (this.wsdlLocation == null) {
+            throw new DeploymentException("WSDL file is required.");
+        }
+        
+        if (this.javaWsdlMapping == null) {
+            URI jaxrpcMappingURI;
+            try {
+                jaxrpcMappingURI = new URI(this.jaxrpcMappingFile);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("Could not construct jaxrpc mapping uri from
"
+                                              + this.jaxrpcMappingFile);
+            }
+
+            this.javaWsdlMapping = WSDescriptorParser.readJaxrpcMapping(moduleFile, jaxrpcMappingURI);
+        }
+        
+        if (this.schemaInfoBuilder == null) {
+            URI wsdlURI;
+            try {
+                wsdlURI = new URI(this.wsdlLocation);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("could not construct wsdl uri from "
+                                              + this.wsdlLocation);
+            }
+
+            this.schemaInfoBuilder = new SchemaInfoBuilder(moduleFile, wsdlURI);
+        }
+    }
+    
+    public JavaWsdlMappingType getJavaWsdlMapping() {
+        return this.javaWsdlMapping;
+    }
+    
+    public SchemaInfoBuilder getSchemaInfoBuilder() {
+        return schemaInfoBuilder;
+    }
+    
+    public Map<String, ServiceEndpointInterfaceMappingType> getSEIMappings() {
+        if (this.javaWsdlMapping == null) {
+            return Collections.emptyMap();
+        }
+        HashMap<String, ServiceEndpointInterfaceMappingType> seiMappings = new HashMap<String,
ServiceEndpointInterfaceMappingType>();
+        ServiceEndpointInterfaceMappingType[] mappings = this.javaWsdlMapping.getServiceEndpointInterfaceMappingArray();
+        for (ServiceEndpointInterfaceMappingType seiMapping : mappings) {
+            seiMappings.put(seiMapping.getServiceEndpointInterface().getStringValue().trim(),
seiMapping);
+        }
+        return seiMappings;
+    }
+    
+}

Propchange: geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/SharedPortInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/WSDescriptorParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/WSDescriptorParser.java?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/WSDescriptorParser.java
(original)
+++ geronimo/server/trunk/modules/geronimo-webservices-builder/src/main/java/org/apache/geronimo/webservices/builder/WSDescriptorParser.java
Mon Jun 18 13:15:51 2007
@@ -34,7 +34,6 @@
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
-import javax.wsdl.Port;
 import javax.xml.namespace.QName;
 import javax.xml.rpc.handler.HandlerInfo;
 import javax.xml.rpc.holders.BigDecimalHolder;
@@ -297,29 +296,13 @@
     public static Map<String,PortInfo> parseWebServiceDescriptor(WebservicesType webservicesType,
JarFile moduleFile, boolean isEJB, Map servletLocations) throws DeploymentException {
         Map<String,PortInfo> portMap = new HashMap<String, PortInfo>();
         WebserviceDescriptionType[] webserviceDescriptions = webservicesType.getWebserviceDescriptionArray();
-        for (WebserviceDescriptionType webserviceDescription : webserviceDescriptions) {
-            URI wsdlURI;
-            try {
-                wsdlURI = new URI(webserviceDescription.getWsdlFile().getStringValue().trim());
-            } catch (URISyntaxException e) {
-                throw new DeploymentException("could not construct wsdl uri from " + webserviceDescription.getWsdlFile().getStringValue(),
e);
-            }
-            URI jaxrpcMappingURI;
-            try {
-                jaxrpcMappingURI = new URI(webserviceDescription.getJaxrpcMappingFile().getStringValue().trim());
-            } catch (URISyntaxException e) {
-                throw new DeploymentException("Could not construct jaxrpc mapping uri from
" + webserviceDescription.getJaxrpcMappingFile(), e);
-            }
-            SchemaInfoBuilder schemaInfoBuilder = new SchemaInfoBuilder(moduleFile, wsdlURI);
-            Map wsdlPortMap = schemaInfoBuilder.getPortMap();
-
-            JavaWsdlMappingType javaWsdlMapping = readJaxrpcMapping(moduleFile, jaxrpcMappingURI);
-            HashMap<String, ServiceEndpointInterfaceMappingType> seiMappings = new
HashMap<String, ServiceEndpointInterfaceMappingType>();
-            ServiceEndpointInterfaceMappingType[] mappings = javaWsdlMapping.getServiceEndpointInterfaceMappingArray();
-            for (ServiceEndpointInterfaceMappingType seiMapping : mappings) {
-                seiMappings.put(seiMapping.getServiceEndpointInterface().getStringValue(),
seiMapping);
-            }
-
+        SharedPortInfo sharedPortInfo;
+        for (WebserviceDescriptionType webserviceDescription : webserviceDescriptions) {
           
+            String wsdlLocation = webserviceDescription.getWsdlFile().getStringValue().trim();
+            String jaxrpcMappingFile = webserviceDescription.getJaxrpcMappingFile().getStringValue().trim();
+            
+            sharedPortInfo = new SharedPortInfo(wsdlLocation, jaxrpcMappingFile);
+            
             PortComponentType[] portComponents = webserviceDescription.getPortComponentArray();
             for (PortComponentType portComponent : portComponents) {
                 String portComponentName = portComponent.getPortComponentName().getStringValue().trim();
@@ -335,32 +318,90 @@
                     linkName = serviceImplBeanType.getServletLink().getStringValue().trim();
                     servletLocation = (String) servletLocations.get(linkName);
                     if (servletLocation == null) {
-                        throw new DeploymentException("No servlet mapping for port " + portQName);
+                        throw new DeploymentException("No servlet mapping for port " + portComponentName);
                     }
-                    schemaInfoBuilder.movePortLocation(portQName.getLocalPart(), servletLocation);
                 } else {
                     linkName = serviceImplBeanType.getEjbLink().getStringValue().trim();
                     servletLocation = (String) servletLocations.get(linkName);
-                    servletLocation = schemaInfoBuilder.movePortLocation(portQName.getLocalPart(),
servletLocation);
                 }
                 PortComponentHandlerType[] handlers = portComponent.getHandlerArray();
-
-                Port port = (Port) wsdlPortMap.get(portQName.getLocalPart());
-                if (port == null) {
-                    throw new DeploymentException("No WSDL Port definition for port-component
" + portComponentName);
+                
+                URI contextURI;
+                try {
+                    contextURI = new URI(servletLocation);
+                } catch (URISyntaxException e) {
+                    throw new DeploymentException("Could not construct URI for web service
location");
                 }
 
-                ServiceEndpointInterfaceMappingType seiMapping = seiMappings.get(seiInterfaceName);
+                PortInfo portInfo = new PortInfo(sharedPortInfo, portComponentName, portQName,
seiInterfaceName, handlers, contextURI);
+
+                if (portMap.put(linkName, portInfo) != null) {
+                    throw new DeploymentException("Ambiguous description of port associated
with j2ee component " + linkName);
+                }
+            }
+        }
+        return portMap;
+    }
 
-                String wsdlLocation = webserviceDescription.getWsdlFile().getStringValue().trim();
+    public static Map<String,PortInfo> parseWebServiceDescriptor(org.apache.geronimo.xbeans.javaee.WebservicesType
webservicesType, JarFile moduleFile, boolean isEJB, Map servletLocations) throws DeploymentException
{
+        Map<String,PortInfo> portMap = new HashMap<String, PortInfo>();
+        org.apache.geronimo.xbeans.javaee.WebserviceDescriptionType[] webserviceDescriptions
= webservicesType.getWebserviceDescriptionArray();
+        SharedPortInfo sharedPortInfo;
+        for (org.apache.geronimo.xbeans.javaee.WebserviceDescriptionType webserviceDescription
: webserviceDescriptions) {
+            String wsdlLocation = null;
+            if (webserviceDescription.isSetWsdlFile()) {
+                wsdlLocation = webserviceDescription.getWsdlFile().getStringValue().trim();
+            }
+            String jaxrpcMappingFile = null;
+            if (webserviceDescription.isSetJaxrpcMappingFile()) {
+                jaxrpcMappingFile = webserviceDescription.getJaxrpcMappingFile().getStringValue().trim();
+            }
+            
+            sharedPortInfo = new SharedPortInfo(wsdlLocation, jaxrpcMappingFile);
+            
+            org.apache.geronimo.xbeans.javaee.PortComponentType[] portComponents = webserviceDescription.getPortComponentArray();
+            for (org.apache.geronimo.xbeans.javaee.PortComponentType portComponent : portComponents)
{
+                String portComponentName = portComponent.getPortComponentName().getStringValue().trim();
+                QName portQName = null;
+                if (portComponent.isSetWsdlPort()) {
+                    portQName = portComponent.getWsdlPort().getQNameValue();
+                }
+                String seiInterfaceName = null;
+                if (portComponent.isSetServiceEndpointInterface()) {
+                    seiInterfaceName = portComponent.getServiceEndpointInterface().getStringValue().trim();
+                }
+                org.apache.geronimo.xbeans.javaee.ServiceImplBeanType serviceImplBeanType
= portComponent.getServiceImplBean();
+                if (isEJB == serviceImplBeanType.isSetServletLink()) {
+                    throw new DeploymentException("Wrong kind of web service described in
web service descriptor: expected " + (isEJB ? "EJB" : "POJO(Servlet)"));
+                }
+                String linkName;
+                String servletLocation;
+                if (serviceImplBeanType.isSetServletLink()) {
+                    linkName = serviceImplBeanType.getServletLink().getStringValue().trim();
+                    servletLocation = (String) servletLocations.get(linkName);
+                    if (servletLocation == null) {
+                        throw new DeploymentException("No servlet mapping for port " + portComponentName);
+                    }
+                } else {
+                    linkName = serviceImplBeanType.getEjbLink().getStringValue().trim();
+                    servletLocation = (String) servletLocations.get(linkName);
+                }
+                PortComponentHandlerType[] handlers = null;
+                if (portComponent.getHandlerArray() != null) {
+                    handlers = new PortComponentHandlerType[portComponent.getHandlerArray().length];
+                    for (int i=0; i<portComponent.getHandlerArray().length; i++) {
+                        handlers[i] = (PortComponentHandlerType)portComponent.getHandlerArray()[i].changeType(PortComponentHandlerType.type);
+                    }
+                }
+                
                 URI contextURI;
                 try {
                     contextURI = new URI(servletLocation);
                 } catch (URISyntaxException e) {
-                    throw new DeploymentException("Could not construct URI for web service
location", e);
+                    throw new DeploymentException("Could not construct URI for web service
location");
                 }
 
-                PortInfo portInfo = new PortInfo(portComponentName, portQName, schemaInfoBuilder,
javaWsdlMapping, seiInterfaceName, handlers, port, seiMapping, wsdlLocation, contextURI);
+                PortInfo portInfo = new PortInfo(sharedPortInfo, portComponentName, portQName,
seiInterfaceName, handlers, contextURI);
 
                 if (portMap.put(linkName, portInfo) != null) {
                     throw new DeploymentException("Ambiguous description of port associated
with j2ee component " + linkName);
@@ -369,18 +410,21 @@
         }
         return portMap;
     }
-
+    
     public static Map<String,PortInfo> parseWebServiceDescriptor(URL wsDDUrl, JarFile
moduleFile, boolean isEJB, Map servletLocations) throws DeploymentException {
-            WebservicesType webservicesType = getWebservicesType(wsDDUrl);
-        if (webservicesType != null) {
-            return parseWebServiceDescriptor(webservicesType, moduleFile, isEJB, servletLocations);
+        XmlObject webservicesType = getWebservicesType(wsDDUrl);
+        if (webservicesType instanceof WebservicesType) {
+            WebservicesType webServices = (WebservicesType)webservicesType;
+            return parseWebServiceDescriptor(webServices, moduleFile, isEJB, servletLocations);
+        } else if (webservicesType instanceof org.apache.geronimo.xbeans.javaee.WebservicesType)
{
+            org.apache.geronimo.xbeans.javaee.WebservicesType webServices = (org.apache.geronimo.xbeans.javaee.WebservicesType)webservicesType;
+            return parseWebServiceDescriptor(webServices, moduleFile, isEJB, servletLocations);
         } else {
             return null;
         }
-
     }
-
-    static WebservicesType getWebservicesType(URL wsDDUrl) throws DeploymentException {
+    
+    static XmlObject getWebservicesType(URL wsDDUrl) throws DeploymentException {
         try {
             XmlObject webservicesDocumentUntyped = XmlObject.Factory.parse(wsDDUrl);
             XmlCursor cursor = webservicesDocumentUntyped.newCursor();
@@ -389,31 +433,45 @@
                     while(cursor.toNextToken()  != XmlCursor.TokenType.START) {}
                 }
                 QName qname = cursor.getName();
-                if (!WebservicesDocument.type.getDocumentElementName().equals(qname)) {
-                    //not a jaxrpc/j2ee 1.4 webservices document.
-                    //TODO handle jaxrpc inside a jee5 webservices document.
+                if (WebservicesDocument.type.getDocumentElementName().equals(qname)) {
+                    return getJ2EEWebServices(webservicesDocumentUntyped);
+                } else if (org.apache.geronimo.xbeans.javaee.WebservicesDocument.type.getDocumentElementName().equals(qname))
{
+                    return getJavaEEWebServices(webservicesDocumentUntyped);
+                } else {
                     return null;
                 }
             } finally {
                 cursor.dispose();
             }
-
-            WebservicesDocument webservicesDocument;
-            if (webservicesDocumentUntyped instanceof WebservicesDocument) {
-                webservicesDocument = (WebservicesDocument) webservicesDocumentUntyped;
-            } else {
-                webservicesDocument = (WebservicesDocument) webservicesDocumentUntyped.changeType(WebservicesDocument.type);
-            }
-            XmlBeansUtil.validateDD(webservicesDocument);
-            return webservicesDocument.getWebservices();
         } catch (XmlException e) {
             throw new DeploymentException("Could not read descriptor document", e);
         } catch (IOException e) {
             return null;
         }
-
     }
 
+    private static XmlObject getJ2EEWebServices(XmlObject webservicesDocumentUntyped) throws
XmlException {
+        WebservicesDocument webservicesDocument;
+        if (webservicesDocumentUntyped instanceof WebservicesDocument) {
+            webservicesDocument = (WebservicesDocument) webservicesDocumentUntyped;
+        } else {
+            webservicesDocument = (WebservicesDocument) webservicesDocumentUntyped.changeType(WebservicesDocument.type);
+        }
+        XmlBeansUtil.validateDD(webservicesDocument);
+        return webservicesDocument.getWebservices();
+    }
+    
+    private static XmlObject getJavaEEWebServices(XmlObject webservicesDocumentUntyped) throws
XmlException {
+        org.apache.geronimo.xbeans.javaee.WebservicesDocument webservicesDocument;
+        if (webservicesDocumentUntyped instanceof org.apache.geronimo.xbeans.javaee.WebservicesDocument)
{
+            webservicesDocument = (org.apache.geronimo.xbeans.javaee.WebservicesDocument)
webservicesDocumentUntyped;
+        } else {
+            webservicesDocument = (org.apache.geronimo.xbeans.javaee.WebservicesDocument)
webservicesDocumentUntyped.changeType(org.apache.geronimo.xbeans.javaee.WebservicesDocument.type);
+        }
+        XmlBeansUtil.validateDD(webservicesDocument);
+        return webservicesDocument.getWebservices();        
+    }
+    
     public static List<HandlerInfo> createHandlerInfoList(PortComponentHandlerType[]
handlers, ClassLoader classLoader) throws DeploymentException {
         List<HandlerInfo> list = new ArrayList<HandlerInfo>();
         for (PortComponentHandlerType handler : handlers) {

Modified: geronimo/server/trunk/modules/geronimo-webservices-builder/src/test/java/org/apache/geronimo/webservices/builder/ParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-webservices-builder/src/test/java/org/apache/geronimo/webservices/builder/ParsingTest.java?view=diff&rev=548475&r1=548474&r2=548475
==============================================================================
--- geronimo/server/trunk/modules/geronimo-webservices-builder/src/test/java/org/apache/geronimo/webservices/builder/ParsingTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-webservices-builder/src/test/java/org/apache/geronimo/webservices/builder/ParsingTest.java
Mon Jun 18 13:15:51 2007
@@ -121,7 +121,7 @@
 
     public void testWebservicesJee5() throws Exception {
         URL url = getClass().getClassLoader().getResource("webservices-jee5.xml");
-        assertNull(WSDescriptorParser.getWebservicesType(url));
+        assertNotNull(WSDescriptorParser.getWebservicesType(url));
     }
 
 }



Mime
View raw message