You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/06/03 23:21:10 UTC

svn commit: r781555 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/ jaxws/geronimo-jaxws-builder/src/main/java/or...

Author: gawor
Date: Wed Jun  3 21:21:10 2009
New Revision: 781555

URL: http://svn.apache.org/viewvc?rev=781555&view=rev
Log:
catch @WebServiceProvider servies without WSDL early (GERONIMO-4664)

Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?rev=781555&r1=781554&r2=781555&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java (original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java Wed Jun  3 21:21:10 2009
@@ -27,8 +27,6 @@
 import java.util.Map;
 import java.util.jar.JarFile;
 
-import javax.xml.ws.http.HTTPBinding;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.axis2.pojo.POJOWebServiceContainerFactoryGBean;
@@ -206,17 +204,22 @@
     @Override
     protected void initialize(GBeanData targetGBean, Class serviceClass, PortInfo portInfo, Module module) 
         throws DeploymentException {
+        String serviceName = (portInfo.getServiceName() == null ? serviceClass.getName() : portInfo.getServiceName());
         if (isWsdlSet(portInfo, serviceClass)) {
-            log.debug("Service " + portInfo.getServiceName() + " has WSDL.");
+            log.debug("Service " + serviceName + " has WSDL.");
             return;
         }
         
         if (isHTTPBinding(portInfo, serviceClass)) {
-            log.debug("Service " + portInfo.getServiceName() + " is HTTPBinding.  Only SOAP 1.1 or 1.2 is supported.");
+            log.debug("Service " + serviceName + " has HTTPBinding.");
             return;
         }
         
-        log.debug("Service " + portInfo.getServiceName() + " does not have WSDL. Generating WSDL...");
+        if (JAXWSUtils.isWebServiceProvider(serviceClass)) {
+            throw new DeploymentException("WSDL must be specified for @WebServiceProvider service " + serviceName);
+        }
+
+        log.debug("Service " + serviceName + " does not have WSDL. Generating WSDL...");
 
         WsdlGenerator wsdlGenerator = getWsdlGenerator();
         
@@ -238,31 +241,8 @@
         String wsdlFile = wsdlGenerator.generateWsdl(module, serviceClass.getName(), module.getEarContext(), options);
         portInfo.setWsdlFile(wsdlFile);
         
-        log.debug("Generated " + wsdlFile + " for service " + portInfo.getServiceName());        
-    }
-    
-    private boolean isWsdlSet(PortInfo portInfo, Class serviceClass) {
-        return (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().trim().equals(""))
-                || JAXWSUtils.containsWsdlLocation(serviceClass, serviceClass.getClassLoader());
-    }
-    
-    private boolean isHTTPBinding(PortInfo portInfo, Class serviceClass) {
-        String bindingURI = "";
-        String bindingURIFromAnnot;
-        
-        if (portInfo.getProtocolBinding() != null) {
-            bindingURI = JAXWSUtils.getBindingURI(portInfo.getProtocolBinding());
-        }        
-        bindingURIFromAnnot = JAXWSUtils.getBindingURIFromAnnot(serviceClass, serviceClass.getClassLoader());
-        
-        if (bindingURI != null && !bindingURI.trim().equals("")) {
-            return bindingURI.equals(HTTPBinding.HTTP_BINDING);
-        } else if (bindingURIFromAnnot != null && !bindingURIFromAnnot.trim().equals("")) {
-            return bindingURIFromAnnot.equals(HTTPBinding.HTTP_BINDING);
-        } 
-        
-        return false;  
-    }
+        log.debug("Generated " + wsdlFile + " for service " + serviceName);
+    }    
         
     public static final GBeanInfo GBEAN_INFO;
 

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java?rev=781555&r1=781554&r2=781555&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java (original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java Wed Jun  3 21:21:10 2009
@@ -211,11 +211,22 @@
     
     private void generateWSDL(Class serviceClass, PortInfo portInfo, Module module) 
         throws DeploymentException {
+        String serviceName = (portInfo.getServiceName() == null ? serviceClass.getName() : portInfo.getServiceName());
         if (isWsdlSet(portInfo, serviceClass)) {
-            LOG.debug("Service " + portInfo.getServiceName() + " has WSDL.");
+            LOG.debug("Service " + serviceName + " has WSDL.");
             return;
         }        
-        LOG.debug("Service " + portInfo.getServiceName() + " does not have WSDL. Generating WSDL...");
+        
+        if (isHTTPBinding(portInfo, serviceClass)) {
+            LOG.debug("Service " + serviceName + " has HTTPBinding.");
+            return;
+        }
+        
+        if (JAXWSUtils.isWebServiceProvider(serviceClass)) {            
+            throw new DeploymentException("WSDL must be specified for @WebServiceProvider service " + serviceName);
+        }
+        
+        LOG.debug("Service " + serviceName + " does not have WSDL. Generating WSDL...");
         
         WsdlGenerator wsdlGenerator = getWsdlGenerator();
         
@@ -239,13 +250,8 @@
         String wsdlFile = wsdlGenerator.generateWsdl(module, serviceClass.getName(), module.getEarContext(), options);
         portInfo.setWsdlFile(wsdlFile);
         
-        LOG.debug("Generated " + wsdlFile + " for service " + portInfo.getServiceName()); 
-    }   
-    
-    private boolean isWsdlSet(PortInfo portInfo, Class serviceClass) {
-        return (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().trim().equals(""))
-                || JAXWSUtils.containsWsdlLocation(serviceClass, serviceClass.getClassLoader());
-    }    
+        LOG.debug("Generated " + wsdlFile + " for service " + serviceName);
+    }     
     
     public static final GBeanInfo GBEAN_INFO;
 

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=781555&r1=781554&r2=781555&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java Wed Jun  3 21:21:10 2009
@@ -23,6 +23,8 @@
 import java.util.Map;
 import java.util.jar.JarFile;
 
+import javax.xml.ws.http.HTTPBinding;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.DeploymentException;
@@ -229,4 +231,27 @@
             throw new DeploymentException("Unable to load Web Service class: " + className, ex);
         }
     }
+    
+    protected boolean isWsdlSet(PortInfo portInfo, Class serviceClass) {
+        return (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().trim().equals(""))
+                || JAXWSUtils.containsWsdlLocation(serviceClass, serviceClass.getClassLoader());
+    }
+    
+    protected boolean isHTTPBinding(PortInfo portInfo, Class serviceClass) {
+        String bindingURI = "";
+        String bindingURIFromAnnot;
+        
+        if (portInfo.getProtocolBinding() != null) {
+            bindingURI = JAXWSUtils.getBindingURI(portInfo.getProtocolBinding());
+        }        
+        bindingURIFromAnnot = JAXWSUtils.getBindingURIFromAnnot(serviceClass, serviceClass.getClassLoader());
+        
+        if (bindingURI != null && !bindingURI.trim().equals("")) {
+            return bindingURI.equals(HTTPBinding.HTTP_BINDING);
+        } else if (bindingURIFromAnnot != null && !bindingURIFromAnnot.trim().equals("")) {
+            return bindingURIFromAnnot.equals(HTTPBinding.HTTP_BINDING);
+        } 
+        
+        return false;  
+    }
 }

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java?rev=781555&r1=781554&r2=781555&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java Wed Jun  3 21:21:10 2009
@@ -88,6 +88,10 @@
                  isProperWebService(clazz));
     }
     
+    public static boolean isWebServiceProvider(Class clazz) {
+        return (clazz.isAnnotationPresent(WebServiceProvider.class) && isProperWebService(clazz));
+    }
+    
     private static boolean isProperWebService(Class clazz) {
         int modifiers = clazz.getModifiers();
         return (Modifier.isPublic(modifiers) &&