cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r897818 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ rt/frontend...
Date Mon, 11 Jan 2010 09:40:45 GMT
Author: sergeyb
Date: Mon Jan 11 09:40:44 2010
New Revision: 897818

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

........
  r897812 | sergeyb | 2010-01-11 09:31:09 +0000 (Mon, 11 Jan 2010) | 1 line
  
  JAXRS support for reading Document and fixes to do with updating destinations when request
URIs are equal to endpoint addresses 
........

Added:
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoTest.java
      - copied unchanged from r897812, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_uriinfo/
      - copied from r897812, cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_uriinfo/
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/
      - copied from r897812, cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/beans.xml
      - copied unchanged from r897812, cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/beans.xml
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/web.xml
      - copied unchanged from r897812, cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_uriinfo/WEB-INF/web.xml
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/SourceProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:897812

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
Mon Jan 11 09:40:44 2010
@@ -58,13 +58,18 @@
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
-        return Source.class.isAssignableFrom(type) || XMLSource.class.isAssignableFrom(type);
+        return Source.class.isAssignableFrom(type) 
+               || XMLSource.class.isAssignableFrom(type)
+               || Document.class.isAssignableFrom(type);
     }
     
     public Object readFrom(Class<Object> source, Type genericType, Annotation[] annotations,
MediaType m,  
         MultivaluedMap<String, String> headers, InputStream is) 
         throws IOException {
-        if (DOMSource.class.isAssignableFrom(source)) {
+        if (DOMSource.class.isAssignableFrom(source) || Document.class.isAssignableFrom(source))
{
+            
+            boolean docRequired = Document.class.isAssignableFrom(source);
+            
             Document doc = null;
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder;
@@ -77,7 +82,7 @@
                 throw ioex;
             }
     
-            return new DOMSource(doc);
+            return docRequired ? doc : new DOMSource(doc);
         } else if (StreamSource.class.isAssignableFrom(source)
                    || Source.class.isAssignableFrom(source)) {
             return new StreamSource(is);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
Mon Jan 11 09:40:44 2010
@@ -193,6 +193,10 @@
     public static String getPathToMatch(String path, String address, boolean addSlash) {
         
         int ind = path.indexOf(address);
+        if (ind == -1 && address.equals(path + "/")) {
+            path += "/";
+            ind = 0;
+        }
         if (ind == 0) {
             path = path.substring(ind + address.length());
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/SourceProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/SourceProviderTest.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/SourceProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/SourceProviderTest.java
Mon Jan 11 09:40:44 2010
@@ -29,6 +29,8 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamSource;
 
+import org.w3c.dom.Document;
+
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -57,6 +59,7 @@
         assertSame(StreamSource.class, verifyRead(p, StreamSource.class).getClass());
         assertSame(StreamSource.class, verifyRead(p, Source.class).getClass());
         assertSame(DOMSource.class, verifyRead(p, DOMSource.class).getClass());
+        assertTrue(Document.class.isAssignableFrom(verifyRead(p, Document.class).getClass()));
     }
     
     @Test

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
Mon Jan 11 09:40:44 2010
@@ -76,6 +76,7 @@
     public void testPathToMatch() {
         assertEquals("/", HttpUtils.getPathToMatch("/", "/", true));
         assertEquals("/", HttpUtils.getPathToMatch("/", "/bar", true));
+        assertEquals("/", HttpUtils.getPathToMatch("/bar", "/bar/", true));
         assertEquals("/bar", HttpUtils.getPathToMatch("/bar", "/", true));
         
         assertEquals("/", HttpUtils.getPathToMatch("/bar", "/bar", true));

Modified: cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
Mon Jan 11 09:40:44 2010
@@ -54,7 +54,7 @@
 public class OsgiServletController extends AbstractServletController {
     private static final Logger LOG = LogUtils.getL7dLogger(OsgiServlet.class);
     
-    private String lastBase = "";
+    private volatile String lastBase = "";
     private OsgiServlet servlet;
     public OsgiServletController(OsgiServlet servlet) {
         super(servlet.getServletConfig());
@@ -67,9 +67,10 @@
         }
         String base = forcedBaseAddress == null ? getBaseURL(request) : forcedBaseAddress;
 
-        //if (base.equals(lastBase)) {
-        //    return;
-        //}
+        if (base.equals(lastBase)) {
+            return;
+        }
+        
         Set<String> paths = servlet.getTransport().getDestinationsPaths();
         for (String path : paths) {
             OsgiDestination d2 = servlet.getTransport().getDestinationForPath(path);
@@ -144,7 +145,9 @@
                             }
                         }
                     }
-                } 
+                } else if ("/".equals(address) || address.length() == 0) {
+                    updateDests(request);
+                }
                 invokeDestination(request, res, d);
                 
             }

Modified: cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Mon Jan 11 09:40:44 2010
@@ -55,7 +55,7 @@
     private ServletContext servletContext;
     private ServletConfig servletConfig;
     private Bus bus;
-    private String lastBase = "";
+    private volatile String lastBase = "";
     
     public ServletController(ServletTransportFactory df,
                              ServletConfig config,
@@ -141,7 +141,9 @@
                 }
             } else {
                 ei = d.getEndpointInfo();
-                if (null != request.getQueryString() 
+                
+                if ("GET".equals(request.getMethod())
+                    && null != request.getQueryString() 
                     && request.getQueryString().length() > 0
                     && bus.getExtension(QueryHandlerRegistry.class) != null) {  
                 
                     
@@ -149,10 +151,8 @@
                     String baseUri = request.getRequestURL().toString() 
                         + "?" + request.getQueryString();
                     // update the EndPoint Address with request url
-                    if ("GET".equals(request.getMethod())) {
-                        updateDests(request);
-                    }
-
+                    updateDests(request);
+                    
                     for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
                         if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
                             
@@ -171,6 +171,8 @@
                             return;
                         }   
                     }
+                } else if ("/".equals(address) || address.length() == 0) {
+                    updateDests(request);
                 }
                 
                 invokeDestination(request, res, d);

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java?rev=897818&r1=897817&r2=897818&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java
Mon Jan 11 09:40:44 2010
@@ -47,7 +47,7 @@
     
     protected AbstractSpringServer(String path, String cPath, int portNumber) {
         resourcePath = path;
-        contextPath = "/";
+        contextPath = cPath;
         port = portNumber;
     }
     



Mime
View raw message