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 2007/06/06 22:57:46 UTC

svn commit: r544948 - in /geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2: Axis2WebServiceContainer.java AxisServiceGenerator.java GeronimoHandlerChainBuilder.java

Author: gawor
Date: Wed Jun  6 13:57:45 2007
New Revision: 544948

URL: http://svn.apache.org/viewvc?view=rev&rev=544948
Log:
added generateServiceFromClass method (right now disabled as it generated NPE when get wsdl is called (bug in axis2))

Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?view=diff&rev=544948&r1=544947&r2=544948
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java Wed Jun  6 13:57:45 2007
@@ -97,23 +97,28 @@
         try {
             this.endpointClass = classLoader.loadClass(this.endpointClassName);
             configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
-            
-            //check to see if the wsdlLocation property is set in portInfo, 
-            //if not checking if wsdlLocation exists in annotation
-            //if already set, annotation should not overwrite it.
-            if (portInfo.getWsdlFile() == null || portInfo.getWsdlFile().equals("")){
-                //getwsdllocation from annotation if it exists
+
+            // check to see if the wsdlLocation property is set in portInfo,
+            // if not checking if wsdlLocation exists in annotation
+            // if already set, annotation should not overwrite it.
+            if (portInfo.getWsdlFile() == null || portInfo.getWsdlFile().equals("")) {
+                // getwsdllocation from annotation if it exists
                 if (JAXWSUtils.containsWsdlLocation(this.endpointClass, classLoader)) {
                     portInfo.setWsdlFile(JAXWSUtils.getServiceWsdlLocation(this.endpointClass, classLoader));
                 }
             }
 
-            if(portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")){ //WSDL file Has been provided
-                AxisServiceGenerator serviceGen = createServiceGenerator();
+            AxisServiceGenerator serviceGen = createServiceGenerator();            
+            if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")) { 
+                // WSDL file has been provided 
                 service = serviceGen.getServiceFromWSDL(portInfo, endpointClass, configurationBaseUrl);
-                                            
-            }else { //No WSDL, Axis2 will handle it. Is it ?
-                service = AxisService.createService(endpointClassName, configurationContext.getAxisConfiguration(), JAXWSMessageReceiver.class);
+            } else {
+                // No WSDL, let Axis2 handle it.
+                
+                // FIXME: AxisServiceGenerator method should be used as it understands annotations
+                // but right now that method causes some problems when WSDL is requested.
+                service = AxisService.createService(endpointClassName, configurationContext.getAxisConfiguration(), JAXWSMessageReceiver.class);                
+                // service = serviceGen.getServiceFromClass(this.endpointClass);
             }
 
             service.setScope(Constants.SCOPE_APPLICATION);
@@ -124,7 +129,7 @@
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-        
+
         this.wsdlQueryHandler = new WSDLQueryHandler(this.service);
     }  
 

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java?view=diff&rev=544948&r1=544947&r2=544948
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java Wed Jun  6 13:57:45 2007
@@ -24,7 +24,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import javax.wsdl.Binding;
 import javax.wsdl.Definition;
@@ -45,6 +44,7 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
 import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -65,6 +65,7 @@
 import org.apache.geronimo.axis2.util.SimpleWSDLLocator;
 import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.PortInfo;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
 
 //TODO: Handle RPC Style Messaging
 
@@ -86,6 +87,26 @@
         this.messageReceiver = messageReceiver;
     }
    
+    public AxisService getServiceFromClass(Class endpointClass) throws Exception {
+        AxisService service = DescriptionFactory.createAxisService(endpointClass);
+        
+        for(Iterator<AxisOperation> opIterator = service.getOperations() ; opIterator.hasNext() ;){
+            AxisOperation operation = opIterator.next();
+            operation.setMessageReceiver(this.messageReceiver);
+        }
+        
+        if (service.getNameSpacesMap() == null) {
+            NamespaceMap map = new NamespaceMap();
+            map.put(Java2WSDLConstants.AXIS2_NAMESPACE_PREFIX,
+                    Java2WSDLConstants.AXIS2_XSD);
+            map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
+                    Java2WSDLConstants.URI_2001_SCHEMA_XSD);
+            service.setNameSpacesMap(map);
+        }
+        
+        return service;
+    }
+    
     public AxisService getServiceFromWSDL(PortInfo portInfo, Class endpointClass, URL configurationBaseUrl) throws Exception {
         String wsdlFile = portInfo.getWsdlFile();
         if (wsdlFile == null || wsdlFile.equals("")) {

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java?view=diff&rev=544948&r1=544947&r2=544948
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java Wed Jun  6 13:57:45 2007
@@ -53,7 +53,7 @@
                 && matchBinding(portInfo, hc.getProtocolBindings())) {
             return super.buildHandlerChain(hc, classLoader);
         } else {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }