cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r530612 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/ht...
Date Fri, 20 Apr 2007 02:21:03 GMT
Author: dkulp
Date: Thu Apr 19 19:21:02 2007
New Revision: 530612

URL: http://svn.apache.org/viewvc?view=rev&rev=530612
Log:
More ?wsdl and ?xsd updates


Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.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/spring.xml

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
Thu Apr 19 19:21:02 2007
@@ -185,10 +185,15 @@
             Object extensor = itr.next();
 
             if (SOAPBindingUtil.isSOAPAddress(extensor)) {
-                SoapAddress sa = SOAPBindingUtil.getSoapAddress(extensor);
+                final SoapAddress sa = SOAPBindingUtil.getSoapAddress(extensor);
 
                 SoapBindingInfo sbi = (SoapBindingInfo)b;
-                EndpointInfo info = new EndpointInfo(serviceInfo, sbi.getTransportURI());
+                EndpointInfo info = new EndpointInfo(serviceInfo, sbi.getTransportURI())
{
+                    public void setAddress(String s) {
+                        super.setAddress(s);
+                        sa.setLocationURI(s);
+                    }
+                };
                 info.setAddress(sa.getLocationURI());
                 return info;
             }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
Thu Apr 19 19:21:02 2007
@@ -154,7 +154,7 @@
                 Element el = (Element)nl.item(x);
                 String sl = el.getAttribute("schemaLocation");
                 if (smp.containsKey(sl)) {
-                    el.setAttribute("schemaLocation", smp.get(sl).getSchemaLocationURI());
+                    el.setAttribute("schemaLocation", base + "?xsd=" + sl);
                 }
             }
             nl = doc.getDocumentElement()
@@ -164,7 +164,17 @@
                 Element el = (Element)nl.item(x);
                 String sl = el.getAttribute("schemaLocation");
                 if (smp.containsKey(sl)) {
-                    el.setAttribute("schemaLocation", smp.get(sl).getSchemaLocationURI());
+                    el.setAttribute("schemaLocation", base + "?xsd=" + sl);
+                }
+            }
+            nl = doc.getDocumentElement()
+                .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/",
+                                    "import");
+            for (int x = 0; x < nl.getLength(); x++) {
+                Element el = (Element)nl.item(x);
+                String sl = el.getAttribute("location");
+                if (mp.containsKey(sl)) {
+                    el.setAttribute("location", base + "?wsdl=" + sl);
                 }
             }
             
@@ -201,11 +211,6 @@
                     //check to see if it's aleady in a URL format.  If so, leave it.
                     new URL(start);
                 } catch (MalformedURLException e) {
-                    String uri = start;
-                    if (!uri.startsWith(base)) {
-                        uri = base + "?wsdl=" + uri;
-                    }
-                    imp.setLocationURI(uri);
                     done.put(start, imp.getDefinition());
                     updateDefinition(imp.getDefinition(), done, doneSchemas, base, ei);
                 }
@@ -241,12 +246,6 @@
                         //check to see if it's aleady in a URL format.  If so, leave it.
                         new URL(start);
                     } catch (MalformedURLException e) {
-                    
-                        String uri = start;
-                        if (!uri.startsWith(base)) {
-                            uri = base + "?xsd=" + uri;
-                        }
-                        imp.setSchemaLocationURI(uri);
                         doneSchemas.put(start, imp);
                         updateSchemaImports(imp.getReferencedSchema(), doneSchemas, base);
                     }
@@ -261,11 +260,6 @@
                     //check to see if it's aleady in a URL format.  If so, leave it.
                     new URL(start);
                 } catch (MalformedURLException e) {
-                    String uri = start;
-                    if (!uri.startsWith(base)) {
-                        uri = base + "?xsd=" + uri;
-                    }
-                    included.setSchemaLocationURI(uri);
                     doneSchemas.put(start, included);
                     updateSchemaImports(included.getReferencedSchema(), doneSchemas, base);
                 }

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Thu Apr 19 19:21:02 2007
@@ -48,6 +48,7 @@
     protected ServerEngine engine;
     protected ServerEngine alternateEngine;
     protected JettyHTTPTransportFactory transportFactory;
+    protected URL nurl;
     
     /**
      * Constructor, using Jetty server engine.
@@ -60,7 +61,6 @@
     public JettyHTTPDestination(Bus b, JettyHTTPTransportFactory ci, 
                                 EndpointInfo endpointInfo) throws IOException {
         this(b, ci, endpointInfo, null);
-        this.transportFactory = ci;
     }
 
     /**
@@ -79,6 +79,7 @@
         super(b, ci, endpointInfo, true);
         alternateEngine = eng;
         this.transportFactory = ci;
+        nurl = new URL(endpointInfo.getAddress());
     }
 
     protected Logger getLogger() {

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Thu Apr 19 19:21:02 2007
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
@@ -75,8 +74,6 @@
 
     protected final Bus bus;
     protected final ConduitInitiator conduitInitiator;
-    protected String name;
-    protected URL nurl;
 
     // Configuration values
     protected HTTPServerPolicy server;
@@ -104,9 +101,6 @@
         conduitInitiator = ci;
         
         initConfig();
- 
-        nurl = new URL(ei.getAddress());
-        name = nurl.getPath();
     }
     
     

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
Thu Apr 19 19:21:02 2007
@@ -180,19 +180,29 @@
             Object extensor = itr.next();
 
             if (extensor instanceof HTTPAddress) {
-                HTTPAddress httpAdd = (HTTPAddress)extensor;
+                final HTTPAddress httpAdd = (HTTPAddress)extensor;
 
                 EndpointInfo info = 
                     new EndpointInfo(serviceInfo, 
-                            "http://schemas.xmlsoap.org/wsdl/http/");
+                            "http://schemas.xmlsoap.org/wsdl/http/") {
+                        public void setAddress(String a) {
+                            super.setAddress(a);
+                            httpAdd.setLocationURI(a);
+                        }
+                    };
                 info.setAddress(httpAdd.getLocationURI());
                 return info;
             } else if (extensor instanceof AddressType) {
-                AddressType httpAdd = (AddressType)extensor;
+                final AddressType httpAdd = (AddressType)extensor;
 
                 EndpointInfo info = 
                     new EndpointInfo(serviceInfo, 
-                            "http://schemas.xmlsoap.org/wsdl/http/");
+                            "http://schemas.xmlsoap.org/wsdl/http/") {
+                        public void setAddress(String a) {
+                            super.setAddress(a);
+                            httpAdd.setLocation(a);
+                        }
+                    };
                 info.setAddress(httpAdd.getLocation());
                 return info;
             }

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=530612&r1=530611&r2=530612
==============================================================================
--- 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
Thu Apr 19 19:21:02 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,52 +46,75 @@
 
     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 {
             EndpointInfo ei = new EndpointInfo();
-            String address = "http://localhost" 
-                + (request.getPathInfo() == null ? "" : request.getPathInfo());
+            String address = request.getPathInfo() == null ? "" : request.getPathInfo();
 
             ei.setAddress(address);
             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())) {
+                    || StringUtils.isEmpty(request.getPathInfo())
+                    || "/".equals(request.getPathInfo())) {
                     generateServiceList(request, res);
                 } else {
-                    LOG.warning("Can't find the the request for " + request.getRequestURI()
+ "'s Observer ");
+                    LOG.warning("Can't find the the request for " + request.getRequestURL()
+ "'s Observer ");
                     generateNotFound(request, res);
                 }
             } else {
+                updateDests(request);
                 ei = d.getEndpointInfo();
                 Bus bus = cxfServlet.getBus();
-                if (bus.getExtension(QueryHandlerRegistry.class) != null) { 
+                if (null != request.getQueryString() 
+                    && request.getQueryString().length() > 0
+                    && bus.getExtension(QueryHandlerRegistry.class) != null) {
+                    
+                    String ctxUri = request.getPathInfo();
+                    String baseUri = request.getRequestURL().toString() 
+                        + "?" + request.getQueryString();
+
                     for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
-                        if (null != request.getQueryString() && request.getQueryString().length()
> 0) {
-                            String ctxUri = request.getPathInfo();
-                            String baseUri = request.getRequestURL().toString() 
-                                + "?" + request.getQueryString();
+                        if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
                             
-                            if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
-                                
-                                res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
-                                OutputStream out = res.getOutputStream();
-                                try {
-                                    qh.writeResponse(baseUri, ctxUri, ei, out);
-                                    out.flush();
-                                    return;
-                                } catch (Exception e) {
-                                    throw new ServletException(e);
-                                }
-                                
+                            res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
+                            OutputStream out = res.getOutputStream();
+                            try {
+                                qh.writeResponse(baseUri, ctxUri, ei, out);
+                                out.flush();
+                                return;
+                            } catch (Exception e) {
+                                throw new ServletException(e);
                             }
                         }   
                     }
@@ -109,20 +133,14 @@
         response.setContentType("text/html");        
         response.getWriter().write("<html><body>");
         
-        String reqPerfix = request.getScheme() + "://" + request.getServerName();
-        if (request.getServerPort() != 80 && request.getServerPort() != 0) {
-            reqPerfix += ":" + request.getServerPort();
-        }
-        reqPerfix += request.getContextPath() + request.getServletPath() + "/";
+        String reqPerfix = request.getRequestURL().toString();
+        String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
+        reqPerfix = reqPerfix.substring(0, reqPerfix.length() - pathInfo.length());
         
         if (destinations.size() > 0) {  
             for (ServletDestination sd : destinations) {
                 if (null != sd.getEndpointInfo().getName()) {
-                    String address = sd.getAddress().getAddress().getValue();
-                    
-                    address = reqPerfix
-                        + address.substring("http://localhost/".length());
-                    
+                    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=530612&r1=530611&r2=530612
==============================================================================
--- 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
Thu Apr 19 19:21:02 2007
@@ -40,8 +40,6 @@
         
     private static final long serialVersionUID = 1L;        
     
-    protected String name;
-    
     
     /**
      * Constructor, allowing subsititution of configuration.
@@ -57,21 +55,9 @@
                               EndpointInfo ei)
         throws IOException {
         // would add the default port to the address
-        super(b, ci, updateEndpointAddress(ei), false);
+        super(b, ci, ei, false);
     }
     
-    private static EndpointInfo updateEndpointAddress(EndpointInfo ei) {
-        String ad = ei.getAddress();
-        if (ad != null && ad.indexOf("://") == -1) {
-            if (ad.startsWith("/")) {
-                ad = "http://localhost" + ad;
-            } else {
-                ad = "http://localhost/" + ad;
-            }
-            ei.setAddress(ad);
-        }
-        return ei;
-    }
     
     protected Logger getLogger() {
         return LOG;

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=530612&r1=530611&r2=530612
==============================================================================
--- 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
Thu Apr 19 19:21:02 2007
@@ -38,7 +38,7 @@
 public class ServletTransportFactory extends AbstractTransportFactory
     implements DestinationFactory {
 
-    private Bus bus;    
+    private Bus bus;
     private Map<String, ServletDestination> destinations = 
         new ConcurrentHashMap<String, ServletDestination>();
     
@@ -48,7 +48,7 @@
 
     public ServletTransportFactory() {
     }
-    
+
     public Bus getBus() {
         return bus;
     }
@@ -60,14 +60,16 @@
     
     public Destination getDestination(EndpointInfo endpointInfo)
         throws IOException {
-        //String origAddress = endpointInfo.getAddress();
         ServletDestination d = destinations.get(endpointInfo.getAddress());
         if (d == null) { 
             d = new ServletDestination(bus, null, endpointInfo);
-            //destinations.put(origAddress, d);
             destinations.put(endpointInfo.getAddress(), d);
         }
         return d;
+    }
+    
+    public ServletDestination getDestinationForPath(String path) {
+        return destinations.get(path);
     }
     
     public Collection<ServletDestination> getDestinations() {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml?view=diff&rev=530612&r1=530611&r2=530612
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml Thu
Apr 19 19:21:02 2007
@@ -34,19 +34,19 @@
     <property name="serviceBean">
       <bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
     </property>
-    <property name="address" value="http://localhost/services/Greeter"/>
+    <property name="address" value="/services/Greeter"/>
     <property name="bus" ref="cxf"/>
   </bean>
   
    <jaxws:endpoint id="endpoint1" 
               implementor="org.apache.hello_world_soap_http.GreeterImpl"
-              address="http://localhost/services/Greeter1"
+              address="/services/Greeter1"
               wsdlLocation="/wsdl/hello_world.wsdl"
               />
    
     <jaxws:endpoint id="endpoint2" 
               implementor="org.apache.hello_world_soap_http.GreeterImpl"
-              address="http://localhost/services/Greeter2"
+              address="/services/Greeter2"
               />     
   
 </beans>



Mime
View raw message