cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject cxf git commit: CXF-5640 Checking the bus too
Date Tue, 18 Nov 2014 02:01:34 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 218594d0d -> 6499929df


CXF-5640 Checking the bus too


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

Branch: refs/heads/2.7.x-fixes
Commit: 6499929df46a16208dc571a43a74d865cdaead89
Parents: 218594d
Author: Jason Pell <jpell@apache.org>
Authored: Tue Nov 18 12:36:46 2014 +1100
Committer: Jason Pell <jpell@apache.org>
Committed: Tue Nov 18 12:36:46 2014 +1100

----------------------------------------------------------------------
 .../transport/http_jetty/JettyHTTPHandler.java  | 11 ++--
 .../http_jetty/JettyHTTPServerEngine.java       | 56 +++++++++++---------
 2 files changed, 39 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6499929d/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
index 871ff8e..7036447 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java
@@ -25,6 +25,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.transport.http.HttpUrlUtil;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.handler.AbstractHandler;
@@ -65,9 +66,13 @@ public class JettyHTTPHandler extends AbstractHandler {
                 jettyHTTPDestination.doService(servletContext, request, response);
             }
         }
-        
     }
 
-
-
+    public Bus getBus() {
+        if (jettyHTTPDestination != null) {
+            return jettyHTTPDestination.getBus();
+        } else {
+            return null;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/6499929d/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index d6c5376..77e27a9 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -30,8 +30,10 @@ import java.util.logging.Logger;
 import javax.annotation.PostConstruct;
 import javax.servlet.ServletContext;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.interceptor.Fault;
@@ -62,11 +64,9 @@ import org.eclipse.jetty.util.thread.ThreadPool;
  * work off of a designated port. The port will be enabled for 
  * "http" or "https" depending upon its successful configuration.
  */
-public class JettyHTTPServerEngine
-    implements ServerEngine {
-    
-    private static final Logger LOG =
-        LogUtils.getL7dLogger(JettyHTTPServerEngine.class);
+public class JettyHTTPServerEngine implements ServerEngine {
+    public static final String DO_NOT_CHECK_URL_PROP = "org.apache.cxf.transports.http_jetty.DontCheckUrl";
+    private static final Logger LOG = LogUtils.getL7dLogger(JettyHTTPServerEngine.class);
    
     /**
      * This is the network port for which this engine is allocated.
@@ -210,10 +210,15 @@ public class JettyHTTPServerEngine
         return !Boolean.valueOf(s);
     }
     
-    private boolean shouldCheckUrl() {
-        String s = SystemPropertyAction
-            .getPropertyOrNull("org.apache.cxf.transports.http_jetty.DontCheckUrl");
-        return !Boolean.valueOf(s);
+    private boolean shouldCheckUrl(Bus bus) {
+        Object prop = null;
+        if (bus != null) {
+            prop = bus.getProperty(DO_NOT_CHECK_URL_PROP);
+        }
+        if (prop == null) {
+            prop = SystemPropertyAction.getPropertyOrNull(DO_NOT_CHECK_URL_PROP);
+        }
+        return !PropertyUtils.isTrue(prop);
     }
     
     /**
@@ -282,22 +287,22 @@ public class JettyHTTPServerEngine
     }
     
     protected void checkRegistedContext(URL url) {
-        if (shouldCheckUrl()) {
-            String path = url.getPath();
-            for (String registedPath : registedPaths) {
-                if (path.equals(registedPath)) {
-                    throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url,
registedPath));
-                }
-                // There are some context path conflicts which could cause the JettyHTTPServerEngine

-                // doesn't route the message to the right JettyHTTPHandler
-                if (path.equals(HttpUriMapper.getContextName(registedPath))) {
-                    throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url,
registedPath));
-                }
-                if (registedPath.equals(HttpUriMapper.getContextName(path))) {
-                    throw new Fault(new Message("ADD_HANDLER_CONTEXT_CONFILICT_MSG", LOG,
url, registedPath));
-                }
+        
+        String path = url.getPath();
+        for (String registedPath : registedPaths) {
+            if (path.equals(registedPath)) {
+                throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url,
registedPath));
+            }
+            // There are some context path conflicts which could cause the JettyHTTPServerEngine

+            // doesn't route the message to the right JettyHTTPHandler
+            if (path.equals(HttpUriMapper.getContextName(registedPath))) {
+                throw new Fault(new Message("ADD_HANDLER_CONTEXT_IS_USED_MSG", LOG, url,
registedPath));
+            }
+            if (registedPath.equals(HttpUriMapper.getContextName(path))) {
+                throw new Fault(new Message("ADD_HANDLER_CONTEXT_CONFILICT_MSG", LOG, url,
registedPath));
             }
         }
+        
     }
     
     
@@ -308,8 +313,9 @@ public class JettyHTTPServerEngine
      * @param handler notified on incoming HTTP requests
      */
     public synchronized void addServant(URL url, JettyHTTPHandler handler) {
-        
-        checkRegistedContext(url);
+        if (shouldCheckUrl(handler.getBus())) {
+            checkRegistedContext(url);
+        }
         
         SecurityHandler securityHandler = null;
         if (server == null) {


Mime
View raw message