You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/07/07 16:17:08 UTC

svn commit: r674501 - in /cxf/branches/2.0.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ systests/src/test/java/org/apache/cxf/systest/servlet/

Author: dkulp
Date: Mon Jul  7 07:17:08 2008
New Revision: 674501

URL: http://svn.apache.org/viewvc?rev=674501&view=rev
Log:
Merged revisions 674485 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r674485 | dkulp | 2008-07-07 09:35:57 -0400 (Mon, 07 Jul 2008) | 2 lines
  
  [CXF-1681] Add Endpoint.publish time, use the last base URL to expand out the publish URL to make sure it's updated in the future.
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
    cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul  7 07:17:08 2008
@@ -1 +1 @@
-/cxf/trunk:673548
+/cxf/trunk:673548,674485

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=674501&r1=674500&r2=674501&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Mon Jul  7 07:17:08 2008
@@ -242,12 +242,14 @@
             ServerImpl serv = getServer(addr);
             if (addr != null) {            
                 EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
-                endpointInfo.setAddress(addr);
+                if (!endpointInfo.getAddress().contains(addr)) {
+                    endpointInfo.setAddress(addr);
+                }
                 if (publishedEndpointUrl != null) {
                     // TODO is there a good place to put this key-string as a constant?
                     endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
                 }
-                this.address = addr;
+                this.address = endpointInfo.getAddress();
             }
             serv.start();
         } catch (WebServiceException ex) {

Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=674501&r1=674500&r2=674501&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Mon Jul  7 07:17:08 2008
@@ -57,7 +57,8 @@
  
     public ServletController(ServletTransportFactory df, AbstractCXFServlet servlet) {
         this.transport = df;
-        this.cxfServlet = servlet;       
+        this.cxfServlet = servlet;
+        df.setServletController(this);
     }
     
     public void setHideServiceList(boolean generate) {
@@ -73,6 +74,10 @@
         this.serviceListStyleSheet = serviceListStyleSheet;
     }
     
+    String getLastBaseURL() {
+        return lastBase;
+    }
+    
     private synchronized void updateDests(HttpServletRequest request) {
         if (disableAddressUpdates) {
             return;

Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?rev=674501&r1=674500&r2=674501&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java (original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java Mon Jul  7 07:17:08 2008
@@ -33,11 +33,13 @@
 import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+import org.apache.cxf.wsdl.http.AddressType;
 
 public class ServletTransportFactory extends AbstractHTTPTransportFactory
     implements DestinationFactory {
@@ -45,6 +47,8 @@
     private Map<String, ServletDestination> destinations = 
         new ConcurrentHashMap<String, ServletDestination>();
     
+    private ServletController controller;
+    
     public ServletTransportFactory(Bus b) {
         super.setBus(b);
         List<String> ids = Arrays.asList(new String[] {
@@ -61,6 +65,9 @@
     public ServletTransportFactory() {
     }
    
+    public void setServletController(ServletController c) {
+        controller = c;
+    }
 
     @Resource(name = "bus")
     public void setBus(Bus b) {
@@ -94,6 +101,19 @@
             String path = getTrimmedPath(endpointInfo.getAddress());
             d = new ServletDestination(getBus(), this, endpointInfo, this, path);
             destinations.put(path, d);
+            
+            if (controller != null
+                && !StringUtils.isEmpty(controller.getLastBaseURL())) {
+                String ad = d.getEndpointInfo().getAddress();
+                if (ad.equals(path)
+                    || ad.equals(controller.getLastBaseURL() + path)) {
+                    d.getEndpointInfo().setAddress(controller.getLastBaseURL() + path);
+                    if (d.getEndpointInfo().getExtensor(AddressType.class) != null) {
+                        d.getEndpointInfo().getExtensor(AddressType.class)
+                            .setLocation(controller.getLastBaseURL() + path);
+                    }
+                }
+            }
         }
         return d;
     }

Modified: cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java?rev=674501&r1=674500&r2=674501&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java (original)
+++ cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java Mon Jul  7 07:17:08 2008
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.systest.servlet;
 
+import javax.xml.ws.Endpoint;
+
 import org.w3c.dom.Document;
 
 import com.meterware.httpunit.PostMethodWebRequest;
@@ -124,6 +126,19 @@
         assertTrue("the soap address should be updated",
                    res.getText().contains("<soap:address location=\"http://cxf.apache.org/Greeter"));
         
+        Endpoint.publish("/services/Greeter3", new org.apache.hello_world_soap_http.GreeterImpl());
+        req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter3?wsdl");
+        res = client.getResponse(req);    
+        assertEquals(200, res.getResponseCode());
+        assertEquals("text/xml", res.getContentType());
+        
+        doc = DOMUtils.readXml(res.getInputStream());
+        assertNotNull(doc);
+        
+        assertValid("//wsdl:operation[@name='greetMe']", doc);
+        assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter3']", doc);
+
     }
     
     @Test