cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r531379 - in /incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet: CXFServlet.java ServletController.java ServletDestination.java ServletTransportFactory.java
Date Mon, 23 Apr 2007 08:41:47 GMT
Author: dkulp
Date: Mon Apr 23 01:41:47 2007
New Revision: 531379

URL: http://svn.apache.org/viewvc?view=rev&rev=531379
Log:
Back out some of the servlet changes

Modified:
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?view=diff&rev=531379&r1=531378&r2=531379
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Mon Apr 23 01:41:47 2007
@@ -78,6 +78,9 @@
     public void init(ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
 
+        BusFactory.setDefaultBus(null);
+        BusFactory.setThreadDefaultBus(null);
+
         String busid = servletConfig.getInitParameter("bus.id");
         if (null != busid) {
             WeakReference<Bus> ref = BUS_MAP.get(busid);
@@ -98,6 +101,9 @@
         if (null != busid) {
             BUS_MAP.put(busid, new WeakReference<Bus>(bus));
         }
+        
+        BusFactory.setDefaultBus(null);
+        BusFactory.setThreadDefaultBus(null);
     }
     
     private void loadBusNoConfig(ServletConfig servletConfig) throws ServletException {

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?view=diff&rev=531379&r1=531378&r2=531379
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Mon Apr 23 01:41:47 2007
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -45,11 +46,30 @@
 
     private ServletTransportFactory transport;
     private CXFServlet cxfServlet;
+    private String lastBase = "";
  
     public ServletController(ServletTransportFactory df, CXFServlet servlet) {
         this.transport = df;
         this.cxfServlet = servlet;
     }
+    
+    private synchronized void updateDests(HttpServletRequest request) {
+        String base = getBaseURL(request);
+        
+        if (base.equals(lastBase)) {
+            return;
+        }
+        Set<String> paths = transport.getDestinationsPaths();
+        for (String path : paths) {
+            ServletDestination d2 = transport.getDestinationForPath(path);
+            String ad = d2.getEndpointInfo().getAddress();
+            if (ad.equals(path)
+                || ad.equals(lastBase + path)) {
+                d2.getEndpointInfo().setAddress(base + path);
+            }
+        }
+        lastBase = base;
+    }
 
     public void invoke(HttpServletRequest request, HttpServletResponse res) throws ServletException
{
         try {
@@ -58,6 +78,10 @@
 
             ei.setAddress(address);
             ServletDestination d = (ServletDestination)transport.getDestination(ei);
+            
+            if ("GET".equals(request.getMethod())) {
+                updateDests(request);
+            }
 
             if (d.getMessageObserver() == null) {
                 if (request.getRequestURI().endsWith("services")
@@ -109,20 +133,10 @@
         response.setContentType("text/html");        
         response.getWriter().write("<html><body>");
         
-        String reqPerfix = getBaseURL(request);
-        
         if (destinations.size() > 0) {  
             for (ServletDestination sd : destinations) {
                 if (null != sd.getEndpointInfo().getName()) {
-                    StringBuilder sb = new StringBuilder();
-                    sb.append(reqPerfix);
-                    String path = sd.getAddressPath();
-                    if (reqPerfix.endsWith("/")) {
-                        path = path.substring(1);
-                    }
-                    sb.append(path);
-                    
-                    String address = sb.toString();
+                    String address = sd.getEndpointInfo().getAddress();
                     response.getWriter().write("<p> <a href=\"" + address + "?wsdl\">");
                     response.getWriter().write(sd.getEndpointInfo().getName() + "</a>
</p>");
                 }    

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?view=diff&rev=531379&r1=531378&r2=531379
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Mon Apr 23 01:41:47 2007
@@ -84,8 +84,6 @@
         
     }
     
-    
-    
     protected void doMessage(MessageImpl inMessage) throws IOException {
         try {
             
@@ -100,19 +98,6 @@
                 LOG.info("Finished servicing http request on thread: " + Thread.currentThread());
             }
         }        
-    }
-
-    public String getAddressPath() {
-        String path = endpointInfo.getAddress();
-        String lh = "http://localhost/";
-        String lhs = "https://localhost/";
-        
-        if (path.startsWith(lh)) {
-            path = "/" + path.substring(lh.length());
-        } else if (path.startsWith(lhs)) {
-            path = "/" + path.substring(lhs.length());
-        }
-        return path;
     }
     
     public MessageObserver getMessageObserver() {

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?view=diff&rev=531379&r1=531378&r2=531379
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
Mon Apr 23 01:41:47 2007
@@ -73,13 +73,17 @@
     }
 
     private String getTrimmedPath(String path) {
-        String lh = "http://localhost/";
-        String lhs = "https://localhost/";
+        final String lh = "http://localhost/";
+        final String lhs = "https://localhost/";
         
         if (path.startsWith(lh)) {
-            path = "/" + path.substring(lh.length());
+            path = path.substring(lh.length());
         } else if (path.startsWith(lhs)) {
-            path = "/" + path.substring(lhs.length());
+            path = path.substring(lhs.length());
+        }
+        if (!path.startsWith("/")) {
+            path = "/" + path;
+            
         }
         return path;
     }



Mime
View raw message