cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r531341 - in /incubator/cxf/trunk: distribution/src/main/assembly/ distribution/src/main/release/lib/ distribution/src/main/release/samples/spring_http/ distribution/src/main/release/samples/spring_http/src/demo/ distribution/src/main/relea...
Date Mon, 23 Apr 2007 05:56:45 GMT
Author: dandiep
Date: Sun Apr 22 22:56:43 2007
New Revision: 531341

URL: http://svn.apache.org/viewvc?view=rev&rev=531341
Log:
o Change the servlet transport to look up services only by their
  path. This means we don't have to put the context name in the 
  address now, which means the samples will work correctly.
o Allow CXFServlet to set the defaultbus. If you don't do this, it
  breaks some Spring use cases. I also changed it so we ALWAYS create
  a Bus (unless the bus id was specified). This should prevent
  conflicts across servlet instances, which seems to be what the 
  previous code was trying to prevent.
o Add missing build.xml for spring_http sample and rework its directory
  structure to be like the other samples.

Added:
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml   (with
props)
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/
      - copied from r531063, incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/main/java/demo/
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/webapp/
      - copied from r531063, incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/webapp/
Removed:
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/main/java/demo/
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/webapp/
Modified:
    incubator/cxf/trunk/distribution/src/main/assembly/bin.xml
    incubator/cxf/trunk/distribution/src/main/release/lib/WHICH_JARS
    incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/spring/servlet/Server.java
    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
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java

Modified: incubator/cxf/trunk/distribution/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/assembly/bin.xml?view=diff&rev=531341&r1=531340&r2=531341
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/assembly/bin.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/assembly/bin.xml Sun Apr 22 22:56:43 2007
@@ -35,6 +35,7 @@
 				<include>LICENSE</include>
 				<include>licenses/*.*</include>
 				<include>modules/*</include>
+				<include>lib/*</include>
 				<include>README</include>
 			</includes>
 		</fileSet>

Modified: incubator/cxf/trunk/distribution/src/main/release/lib/WHICH_JARS
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/lib/WHICH_JARS?view=diff&rev=531341&r1=531340&r2=531341
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/lib/WHICH_JARS (original)
+++ incubator/cxf/trunk/distribution/src/main/release/lib/WHICH_JARS Sun Apr 22 22:56:43 2007
@@ -47,6 +47,11 @@
 - stax-utils.jar
 
 For WS-Security support:
+- bcprov-jdk14.jar
 - wss4j.jar
 - xalan.jar
-- xmlsec.jar
\ No newline at end of file
+- xmlsec.jar
+
+For HTTP Binding support:
+- jra.jar
+- jettison.jar (Needed for JSON services only)

Added: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml?view=auto&rev=531341
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml Sun Apr
22 22:56:43 2007
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project name="Spring HTTP Servlet demo" default="build" basedir=".">
+
+
+	<import file="../common_build.xml"/>        
+
+    <target name="client" description="run demo client" depends="build">
+        <property name="param" value=""/>
+        <cxfrun classname="demo.spring.client.Client" />
+    </target> 
+        
+    <target name="server" description="run demo server" depends="build">
+        <cxfrun classname="demo.spring.servlet.Server"/>
+    </target>
+
+    <property name="cxf.war.file.name" value="spring_http"/>
+      <target name="war" depends="build">
+	  <cxfwar filename="${cxf.war.file.name}.war"/>
+    </target>
+</project>

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/build.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/spring/servlet/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/spring/servlet/Server.java?view=diff&rev=531341&r1=531063&r2=531341
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/spring/servlet/Server.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/src/demo/spring/servlet/Server.java
Sun Apr 22 22:56:43 2007
@@ -46,7 +46,7 @@
         WebAppContext webappcontext = new WebAppContext();
         webappcontext.setContextPath("/");
 
-        webappcontext.setWar("src/webapp");
+        webappcontext.setWar("webapp");
 
         HandlerCollection handlers = new HandlerCollection();
         handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});

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=531341&r1=531340&r2=531341
==============================================================================
--- 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
Sun Apr 22 22:56:43 2007
@@ -78,9 +78,6 @@
     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);
@@ -101,13 +98,11 @@
         if (null != busid) {
             BUS_MAP.put(busid, new WeakReference<Bus>(bus));
         }
-        BusFactory.setDefaultBus(null);
-        BusFactory.setThreadDefaultBus(null);
     }
     
     private void loadBusNoConfig(ServletConfig servletConfig) throws ServletException {
         if (bus == null) {
-            bus = BusFactory.getDefaultBus();
+            bus = BusFactory.newInstance().createBus();
         }
         ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
         resourceManager.addResourceResolver(new ServletContextResourceResolver(

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=531341&r1=531340&r2=531341
==============================================================================
--- 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
Sun Apr 22 22:56:43 2007
@@ -22,7 +22,6 @@
 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;
 
@@ -46,32 +45,11 @@
 
     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 pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
-        String base = request.getRequestURL().toString();
-        base = base.substring(0, base.length() - pathInfo.length());
-        
-        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 {
@@ -82,7 +60,6 @@
             ServletDestination d = (ServletDestination)transport.getDestination(ei);
 
             if (d.getMessageObserver() == null) {
-                updateDests(request);
                 if (request.getRequestURI().endsWith("services")
                     || request.getRequestURI().endsWith("services/")
                     || StringUtils.isEmpty(request.getPathInfo())
@@ -93,7 +70,6 @@
                     generateNotFound(request, res);
                 }
             } else {
-                updateDests(request);
                 ei = d.getEndpointInfo();
                 Bus bus = cxfServlet.getBus();
                 if (null != request.getQueryString() 
@@ -133,14 +109,20 @@
         response.setContentType("text/html");        
         response.getWriter().write("<html><body>");
         
-        String reqPerfix = request.getRequestURL().toString();
-        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
-        reqPerfix = reqPerfix.substring(0, reqPerfix.length() - pathInfo.length());
+        String reqPerfix = getBaseURL(request);
         
         if (destinations.size() > 0) {  
             for (ServletDestination sd : destinations) {
                 if (null != sd.getEndpointInfo().getName()) {
-                    String address = sd.getEndpointInfo().getAddress();
+                    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();
                     response.getWriter().write("<p> <a href=\"" + address + "?wsdl\">");
                     response.getWriter().write(sd.getEndpointInfo().getName() + "</a>
</p>");
                 }    
@@ -149,6 +131,13 @@
             response.getWriter().write("No service was found.");
         }
         response.getWriter().write("</body></html>");
+    }
+
+    private String getBaseURL(HttpServletRequest request) {
+        String reqPerfix = request.getRequestURL().toString();
+        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
+        reqPerfix = reqPerfix.substring(0, reqPerfix.length() - pathInfo.length());
+        return reqPerfix;
     }
 
     protected void generateNotFound(HttpServletRequest request, HttpServletResponse res)
throws IOException {

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=531341&r1=531340&r2=531341
==============================================================================
--- 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
Sun Apr 22 22:56:43 2007
@@ -101,7 +101,20 @@
             }
         }        
     }
-   
+
+    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() {
         return this.incomingObserver;
     }

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=531341&r1=531340&r2=531341
==============================================================================
--- 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
Sun Apr 22 22:56:43 2007
@@ -60,16 +60,28 @@
     
     public Destination getDestination(EndpointInfo endpointInfo)
         throws IOException {
-        ServletDestination d = destinations.get(endpointInfo.getAddress());
+        ServletDestination d = getDestinationForPath(endpointInfo.getAddress());
         if (d == null) { 
             d = new ServletDestination(bus, null, endpointInfo);
-            destinations.put(endpointInfo.getAddress(), d);
+            destinations.put(getTrimmedPath(endpointInfo.getAddress()), d);
         }
         return d;
     }
     
     public ServletDestination getDestinationForPath(String path) {
-        return destinations.get(path);
+        return destinations.get(getTrimmedPath(path));
+    }
+
+    private String getTrimmedPath(String path) {
+        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 Collection<ServletDestination> getDestinations() {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java?view=diff&rev=531341&r1=531340&r2=531341
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java
Sun Apr 22 22:56:43 2007
@@ -19,10 +19,7 @@
 package org.apache.cxf.systest.servlet;
 
 import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
 import java.net.MalformedURLException;
-import java.util.Map;
 
 import org.xml.sax.SAXException;
 
@@ -33,10 +30,7 @@
 import com.meterware.servletunit.ServletRunner;
 import com.meterware.servletunit.ServletUnitClient;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.test.AbstractCXFTest;
-import org.apache.cxf.transport.servlet.CXFServlet;
 import org.junit.Before;
 
 public abstract class AbstractServletTest extends AbstractCXFTest {
@@ -52,13 +46,6 @@
         } catch (HttpNotFoundException e) {
             // ignore, we just want to boot up the servlet
         }   
-        
-        Field f = CXFServlet.class.getDeclaredField("BUS_MAP");
-        f.setAccessible(true);
-        Map<String, WeakReference<Bus>> obj = CastUtils.cast((Map<?, ?>)f.get(null));
-        if (obj.containsKey("servlet.systest.bus.id")) {
-            bus = obj.get("servlet.systest.bus.id").get();
-        }
         
         HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);        
     } 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java?view=diff&rev=531341&r1=531340&r2=531341
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
Sun Apr 22 22:56:43 2007
@@ -29,6 +29,8 @@
 import com.meterware.httpunit.WebResponse;
 import com.meterware.servletunit.ServletUnitClient;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.invoker.BeanInvoker;
@@ -38,13 +40,18 @@
 
 public class CXFServletTest extends AbstractServletTest {
     
+    @Override
+    protected Bus createBus() throws BusException {
+        return null;
+    }
+
     // Create the JaxWsService with the JaxWsServerFactoryBean
     protected void setupJaxwsService() {
         JaxWsServerFactoryBean svr = new JaxWsServerFactoryBean();
         URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
         assertNotNull(resource);
         svr.getServiceFactory().setWsdlURL(resource.toString());
-        svr.setBus(getBus());
+//        svr.setBus(getBus());
         svr.setServiceClass(GreeterImpl.class);
         svr.setAddress("http://localhost/services/Greeter");
         GreeterImpl greeter = new GreeterImpl();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java?view=diff&rev=531341&r1=531340&r2=531341
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/ExternalServicesServletTest.java
Sun Apr 22 22:56:43 2007
@@ -24,11 +24,18 @@
 import com.meterware.httpunit.WebRequest;
 import com.meterware.httpunit.WebResponse;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
 import org.apache.cxf.helpers.DOMUtils;
 import org.junit.Test;
 
 public class ExternalServicesServletTest extends AbstractServletTest {
     
+    @Override
+    protected Bus createBus() throws BusException {
+        return null;
+    }
+
     @Override
     protected String getConfiguration() {
         return "/org/apache/cxf/systest/servlet/web-external.xml";



Mime
View raw message