cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5640] Checking the bus too
Date Tue, 03 Jun 2014 12:26:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 070c8eb6a -> 4604c9fe2


[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/4604c9fe
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4604c9fe
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4604c9fe

Branch: refs/heads/master
Commit: 4604c9fe25da4be126b54c0eb458f8f32503ac71
Parents: 070c8eb
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Jun 3 13:26:05 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Jun 3 13:26:05 2014 +0100

----------------------------------------------------------------------
 .../transport/http_jetty/JettyHTTPHandler.java  | 10 +++-
 .../http_jetty/JettyHTTPServerEngine.java       | 53 ++++++++++++--------
 2 files changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4604c9fe/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 396e3b2..9904a33 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;
@@ -34,11 +35,15 @@ public class JettyHTTPHandler extends AbstractHandler {
     protected ServletContext servletContext;
     private String urlName;
     private boolean contextMatchExact;
+    private Bus bus;
 
     public JettyHTTPHandler(JettyHTTPDestination jhd, boolean cmExact) {
         contextMatchExact = cmExact;
         jettyHTTPDestination = jhd;
     }
+    public JettyHTTPHandler(Bus bus) {
+        this.bus = bus;
+    }
 
     public void setServletContext(ServletContext sc) {
         servletContext = sc;
@@ -68,6 +73,7 @@ public class JettyHTTPHandler extends AbstractHandler {
         
     }
 
-
-
+    public Bus getBus() {
+        return jettyHTTPDestination != null ? jettyHTTPDestination.getBus() : bus;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4604c9fe/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 3f824ec..c490c7c 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;
@@ -65,8 +67,8 @@ import org.eclipse.jetty.util.thread.ThreadPool;
 public class JettyHTTPServerEngine
     implements ServerEngine {
     
-    private static final Logger LOG =
-        LogUtils.getL7dLogger(JettyHTTPServerEngine.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(JettyHTTPServerEngine.class);
+    private static final String DO_NOT_CHECK_URL_PROP = "org.apache.cxf.transports.http_jetty.DontCheckUrl";
    
     /**
      * This is the network port for which this engine is allocated.
@@ -210,10 +212,16 @@ 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 +290,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 +316,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