[jbossws-commits] JBossWS SVN: r18279 - in stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf: configuration and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Jan 27 11:48:41 EST 2014


Author: asoldano
Date: 2014-01-27 11:48:40 -0500 (Mon, 27 Jan 2014)
New Revision: 18279

Added:
   stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossWSDestinationRegistryImpl.java
Modified:
   stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
   stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
Log:
[JBWS-3753] Installing a custom DestinationRegistry impl to use map lookup for matching destination on request receival


Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java	2014-01-27 15:04:27 UTC (rev 18278)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java	2014-01-27 16:48:40 UTC (rev 18279)
@@ -132,33 +132,29 @@
       {
          throw Messages.MESSAGES.cannotObtainRegistry(DestinationRegistry.class.getName());
       }
+      //first try looking up the destination in the registry map
+      final AbstractHTTPDestination dest = destRegistry.getDestinationForPath(requestURI, true);
+      if (dest != null) {
+         return dest;
+      }
+      //if there's no direct match, iterate on the destinations to see if there's valid "catch-all" destination
+      //(servlet-based endpoints, with "/*" url-pattern in web.xml)
       Collection<AbstractHTTPDestination> destinations = destRegistry.getDestinations();
       AbstractHTTPDestination returnValue = null;
       for (AbstractHTTPDestination destination : destinations)
       {
-         EndpointInfo endpointInfo = destination.getEndpointInfo();
-         String address = endpointInfo.getAddress();
-
-         String path = address;
+         String path = destination.getEndpointInfo().getAddress();
          try
          {
-            path = new URL(address).getPath();
+            path = new URL(path).getPath();
          }
          catch (MalformedURLException ex)
          {
             // ignore
          }
 
-         if (path != null)
-         {
-            if (requestURI.equals(path))
-            {
-               return destination; // exact match
-            }
-            else if (requestURI.startsWith(path))
-            {
-               returnValue = destination; // fallback
-            }
+         if (path != null && requestURI.startsWith(path)) {
+            returnValue = destination;
          }
       }
 

Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java	2014-01-27 15:04:27 UTC (rev 18278)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java	2014-01-27 16:48:40 UTC (rev 18279)
@@ -40,6 +40,7 @@
 import org.apache.cxf.resource.ResourceResolver;
 import org.apache.cxf.service.factory.FactoryBeanListener;
 import org.apache.cxf.service.factory.FactoryBeanListenerManager;
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.workqueue.AutomaticWorkQueue;
 import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
 import org.apache.cxf.workqueue.WorkQueueManager;
@@ -59,6 +60,7 @@
 import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
 import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
 import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
+import org.jboss.wsf.stack.cxf.transport.JBossWSDestinationRegistryImpl;
 
 /**
  * A wrapper of the Bus for performing most of the configurations required on it by JBossWS
@@ -114,6 +116,10 @@
       {
          bus.getExtension(PolicyEngine.class).setAlternativeSelector(getAlternativeSelector(props));
       }     
+      if (bus.getExtension(DestinationRegistry.class) == null)
+      {
+         bus.setExtension(new JBossWSDestinationRegistryImpl(), DestinationRegistry.class);
+      }
       setCXFManagement(bus, props); //*first* enabled cxf management if required, *then* add anything else which could be manageable (e.g. work queues)
       setAdditionalWorkQueues(bus, props); 
       setWSDiscovery(bus, props);

Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossWSDestinationRegistryImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossWSDestinationRegistryImpl.java	                        (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossWSDestinationRegistryImpl.java	2014-01-27 16:48:40 UTC (rev 18279)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.transport;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.cxf.transport.http.DestinationRegistryImpl;
+
+/**
+ * A JBossWS version of the CXF DestinationRegistryImpl that registers destinations
+ * with different key values.
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 23-Jan-2014
+ *
+ */
+public class JBossWSDestinationRegistryImpl extends DestinationRegistryImpl
+{
+
+   /**
+    * Return a real path value, removing the protocol, host and port
+    * if specified.
+    * 
+    * @param path 
+    * @return trimmed path
+    */
+   @Override
+   public String getTrimmedPath(String path)
+   {
+      if (path == null)
+      {
+         return "/";
+      }
+      if (!path.startsWith("/"))
+      {
+         try
+         {
+            path = new URL(path).getPath();
+         }
+         catch (MalformedURLException ex)
+         {
+            // ignore
+         }
+         if (!path.startsWith("/")) {
+            path = "/" + path;
+         }
+      }
+      return path;
+   }
+}


Property changes on: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossWSDestinationRegistryImpl.java
___________________________________________________________________
Added: svn:keywords
   + Rev Date
Added: svn:eol-style
   + native



More information about the jbossws-commits mailing list