geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r158027 - in geronimo/trunk/modules/jetty/src: java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java java/org/apache/geronimo/jetty/POJOWebServiceServlet.java test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java
Date Fri, 18 Mar 2005 07:36:07 GMT
Author: chirino
Date: Thu Mar 17 23:36:05 2005
New Revision: 158027

URL: http://svn.apache.org/viewcvs?view=rev&rev=158027
Log:
Implemented WSDL port address replacment.

Modified:
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/POJOWebServiceServlet.java
    geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java?view=diff&r1=158026&r2=158027
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyEJBWebServiceContext.java
Thu Mar 17 23:36:05 2005
@@ -17,13 +17,12 @@
 package org.apache.geronimo.jetty;
 
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.InputStream;
-import java.net.URL;
-import java.net.MalformedURLException;
+import java.io.OutputStream;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.mortbay.http.HttpContext;
@@ -31,7 +30,6 @@
 import org.mortbay.http.HttpHandler;
 import org.mortbay.http.HttpRequest;
 import org.mortbay.http.HttpResponse;
-import org.mortbay.util.URI;
 
 /**
  * Delegates requests to a WebServiceContainer which is presumably for an EJB WebService.
@@ -82,37 +80,32 @@
         this.httpContext = httpContext;
     }
 
-    public void handle(HttpRequest request, HttpResponse response) throws HttpException,
IOException {
-        response.setContentType("text/xml");
-
-        if (request.getParameter("wsdl") != null) {
-            doGetWsdl(request, response);
+    public void handle(HttpRequest req, HttpResponse res) throws HttpException, IOException
{
+        req.setContentType("text/xml");
+        RequestAdapter request = new RequestAdapter(req);
+        ResponseAdapter response = new ResponseAdapter(res);
+            
+        if (req.getParameter("wsdl") != null) {
+            try {
+                OutputStream out = response.getOutputStream();
+                webServiceContainer.getWsdl(request,response);
+                //WHO IS RESPONSIBLE FOR CLOSING OUT?
+            } catch (IOException e) {
+                throw e;
+            } catch (Exception e) {
+                throw (HttpException) new HttpException(500, "Could not fetch wsdl!").initCause(e);
+            }
         } else {
-            doInvoke(request, response);
-        }
-
-    }
-
-    private void doInvoke(HttpRequest request, HttpResponse response) throws IOException
{
-        try {
-            webServiceContainer.invoke(new RequestAdapter(request), new ResponseAdapter(response));
-            request.setHandled(true);
-        } catch (IOException e) {
-            throw e;
-        } catch (Exception e) {
-            throw (HttpException) new HttpException(500).initCause(e);
-        }
-    }
-
-    private void doGetWsdl(HttpRequest request, HttpResponse response) throws IOException
{
-        try {
-            webServiceContainer.getWsdl(new RequestAdapter(request), new ResponseAdapter(response));
-        } catch (IOException e) {
-            throw e;
-        } catch (Exception e) {
-            throw (HttpException) new HttpException(500).initCause(e);
+            try {
+                webServiceContainer.invoke(request,response);
+                req.setHandled(true);
+            } catch (IOException e) {
+                throw e;
+            } catch (Exception e) {
+                throw (HttpException) new HttpException(500, "Could not process message!").initCause(e);
+            }
         }
-        //WHO IS RESPONSIBLE FOR CLOSING OUT?
+            
     }
 
     public String getContextPath() {
@@ -121,6 +114,7 @@
 
     public static class RequestAdapter implements WebServiceContainer.Request {
         private final HttpRequest request;
+        private URI uri;
 
         public RequestAdapter(HttpRequest request) {
             this.request = request;
@@ -131,25 +125,16 @@
         }
 
         public java.net.URI getURI() {
-            try {
-                String uriString = request.getURI().toString();
-                //return new java.net.URI(uri.getScheme(),uri.getHost(),uri.getPath(),uri.);
-                return new java.net.URI(uriString);
-            } catch (URISyntaxException e) {
-                throw new IllegalStateException(e.getMessage());
+            if( uri==null ) {
+                try {
+                    String uriString =  request.getScheme()+"://"+request.getHost()+":"+request.getPort()+request.getURI();
+                    //return new java.net.URI(uri.getScheme(),uri.getHost(),uri.getPath(),uri.);
+                    uri = new java.net.URI(uriString);
+                } catch (URISyntaxException e) {
+                    throw new IllegalStateException(e.getMessage());
+                }
             }
-        }
-
-        public String getHost() {
-            return getURI().getHost();
-        }
-
-        public String getPath() {
-            return getURI().getPath();
-        }
-
-        public int getPort() {
-            return getURI().getPort();
+            return uri;
         }
 
         public int getContentLength() {

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/POJOWebServiceServlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/POJOWebServiceServlet.java?view=diff&r1=158026&r2=158027
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/POJOWebServiceServlet.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/POJOWebServiceServlet.java
Thu Mar 17 23:36:05 2005
@@ -19,11 +19,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
+
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -33,7 +32,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.webservices.WebServiceContainer;
-import org.mortbay.util.URI;
 
 /**
  * Delegates requests to a WebServiceContainer which is presumably for a POJO WebService
@@ -69,17 +67,33 @@
 
     public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
         WebServiceContainer service = (WebServiceContainer) req.getAttribute(WEBSERVICE_CONTAINER);
-        try {
-            RequestAdapter request = new RequestAdapter((HttpServletRequest)req);
-            ResponseAdapter response = new ResponseAdapter((HttpServletResponse)res);
-            service.invoke(request,response);
-        } catch (IOException e) {
-            throw e;
-        } catch (ServletException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new ServletException(e);
+
+        res.setContentType("text/xml");
+        RequestAdapter request = new RequestAdapter((HttpServletRequest)req);
+        ResponseAdapter response = new ResponseAdapter((HttpServletResponse)res);
+
+        if (request.getParameter("wsdl") != null) {
+            try {
+                service.getWsdl(request,response);
+            } catch (IOException e) {
+                throw e;
+            } catch (ServletException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new ServletException("Could not fetch wsdl!", e);
+            }
+        } else {            
+            try {
+                service.invoke(request,response);
+            } catch (IOException e) {
+                throw e;
+            } catch (ServletException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new ServletException("Could not process message!", e);
+            }
         }
+            
     }
 
     public String getServletInfo() {
@@ -108,18 +122,6 @@
             } catch (URISyntaxException e) {
                 throw new IllegalStateException(e.getMessage());
             }
-        }
-
-        public String getHost() {
-            return getURI().getHost();
-        }
-
-        public String getPath() {
-            return getURI().getPath();
-        }
-
-        public int getPort() {
-            return getURI().getPort();
         }
 
         public int getContentLength() {

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java?view=diff&r1=158026&r2=158027
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java
(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/app/MockWebServiceContainer.java
Thu Mar 17 23:36:05 2005
@@ -16,13 +16,6 @@
  */
 package org.apache.geronimo.jetty.app;
 
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.webservices.WebServiceContainer;
 
 /**
@@ -34,7 +27,7 @@
     }
 
     public void getWsdl(Request req, Response res) throws Exception {
-
+    
     }
 
 }



Mime
View raw message