cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6337] Redirection via the injected servlet context
Date Thu, 09 Apr 2015 09:25:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 901ea552d -> 53c0d3500


[CXF-6337] Redirection via the injected servlet context


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/53c0d350
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/53c0d350
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/53c0d350

Branch: refs/heads/2.7.x-fixes
Commit: 53c0d3500cce48ca44925cd65d20c7111151a57f
Parents: 901ea55
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Apr 8 17:53:29 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Apr 9 10:23:31 2015 +0100

----------------------------------------------------------------------
 .../jaxrs/impl/tl/RequestDispatcherImpl.java    | 49 ++++++++++++++++++++
 .../impl/tl/ThreadLocalServletContext.java      |  8 +++-
 .../jaxrs/interceptor/JAXRSOutInterceptor.java  |  4 +-
 .../transport/http/AbstractHTTPDestination.java |  2 +-
 4 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/53c0d350/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
new file mode 100644
index 0000000..fd6000e
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.jaxrs.impl.tl;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
+class RequestDispatcherImpl implements RequestDispatcher {
+    private RequestDispatcher rd;
+
+    RequestDispatcherImpl(RequestDispatcher rd) {
+        this.rd = rd;
+    }
+
+    @Override
+    public void forward(ServletRequest request, ServletResponse response) throws ServletException,
+        IOException {
+        rd.forward(request, response);
+        JAXRSUtils.getCurrentMessage().getExchange().put("http.request.redirected", Boolean.TRUE);
+    }
+
+    @Override
+    public void include(ServletRequest request, ServletResponse response) throws ServletException,
+        IOException {
+        rd.include(request, response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/53c0d350/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
index 54734c3..b1c6eaf 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
@@ -79,7 +79,11 @@ public class ThreadLocalServletContext extends AbstractThreadLocalProxy<ServletC
     }
 
     public RequestDispatcher getNamedDispatcher(String name) {
-        return get().getNamedDispatcher(name);
+        return getDispatcher(get().getNamedDispatcher(name));
+    }
+
+    private RequestDispatcher getDispatcher(RequestDispatcher rd) {
+        return rd == null ? null : new RequestDispatcherImpl(rd);
     }
 
     public String getRealPath(String path) {
@@ -87,7 +91,7 @@ public class ThreadLocalServletContext extends AbstractThreadLocalProxy<ServletC
     }
 
     public RequestDispatcher getRequestDispatcher(String path) {
-        return get().getRequestDispatcher(path);
+        return getDispatcher(get().getRequestDispatcher(path));
     }
 
     public URL getResource(String path) throws MalformedURLException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/53c0d350/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
index 92767a1..0a9968c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
@@ -455,8 +455,8 @@ public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor
{
         return Boolean.TRUE.equals(m.getExchange().get(AbstractHTTPDestination.RESPONSE_COMMITED));
     }
 
-    private boolean isResponseRedirected(Message outMessage) {
-        return Boolean.TRUE.equals(outMessage.get(AbstractHTTPDestination.REQUEST_REDIRECTED));
+    private boolean isResponseRedirected(Message m) {
+        return Boolean.TRUE.equals(m.getExchange().get(AbstractHTTPDestination.REQUEST_REDIRECTED));
     }
     
     private void writeResponseToStream(OutputStream os, Object responseObj) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/53c0d350/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
index f49477d..ea35362 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
@@ -655,7 +655,7 @@ public abstract class AbstractHTTPDestination
     }
 
     private boolean isResponseRedirected(Message outMessage) {
-        return Boolean.TRUE.equals(outMessage.get(REQUEST_REDIRECTED));
+        return Boolean.TRUE.equals(outMessage.getExchange().get(REQUEST_REDIRECTED));
     }
 
     /**


Mime
View raw message