cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject cxf git commit: Misc minor enhancements to HandlerChain builders and resolver
Date Tue, 27 Oct 2015 17:17:21 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 6fd3ada7a -> 0985e79ab


Misc minor enhancements to HandlerChain builders and resolver


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

Branch: refs/heads/master
Commit: 0985e79ab47124fbe0a08b9653ae7d4d1c2b5b97
Parents: 6fd3ada
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Tue Oct 27 18:04:18 2015 +0100
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Tue Oct 27 18:16:12 2015 +0100

----------------------------------------------------------------------
 .../handler/AnnotationHandlerChainBuilder.java  |  7 +++---
 .../cxf/jaxws/handler/HandlerChainBuilder.java  | 24 ++++++++++++--------
 .../cxf/jaxws/handler/HandlerResolverImpl.java  |  5 ----
 3 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0985e79a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
index d8d62f4..b72a721 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
@@ -211,14 +211,15 @@ public class AnnotationHandlerChainBuilder extends HandlerChainBuilder
{
         if ("*".equals(namePattern)) {
             return true;
         }
-        if (!namePattern.contains(":")) {
+        final int idx = namePattern.indexOf(':');
+        if (idx < 0) {
             String xml = StaxUtils.toString(el);
             throw new WebServiceException(
                 BundleUtils.getFormattedString(BUNDLE,
                                                "NOT_A_QNAME_PATTER",
                                                namePattern, xml));                    
         }
-        String pfx = namePattern.substring(0, namePattern.indexOf(':'));
+        String pfx = namePattern.substring(0, idx);
         String ns = el.lookupNamespaceURI(pfx);
         if (ns == null) {
             ns = pfx;
@@ -226,7 +227,7 @@ public class AnnotationHandlerChainBuilder extends HandlerChainBuilder
{
         if (!ns.equals(comp.getNamespaceURI())) {
             return false;
         }
-        String localPart = namePattern.substring(namePattern.indexOf(':') + 1,
+        String localPart = namePattern.substring(idx + 1,
                                                  namePattern.length());
         if (localPart.contains("*")) {
             //wildcard pattern matching

http://git-wip-us.apache.org/repos/asf/cxf/blob/0985e79a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
index c8ba542..7e733b8 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBuilder.java
@@ -93,21 +93,22 @@ public class HandlerChainBuilder {
      */
     public List<Handler> sortHandlers(List<Handler> handlers) {
 
-        List<LogicalHandler<?>> logicalHandlers = new ArrayList<LogicalHandler<?>>();
-        List<Handler<?>> protocolHandlers = new ArrayList<Handler<?>>();
+        final int size = handlers.size();
+        List<Handler> logicalHandlers = new ArrayList<Handler>(size);
+        List<Handler> protocolHandlers = new ArrayList<Handler>(Math.min(10,
size));
 
         for (Handler<?> handler : handlers) {
             if (handler instanceof LogicalHandler) {
-                logicalHandlers.add((LogicalHandler<?>)handler);
+                logicalHandlers.add(handler);
             } else {
                 protocolHandlers.add(handler);
             }
         }
 
-        List<Handler> sortedHandlers = new ArrayList<Handler>();
-        sortedHandlers.addAll(logicalHandlers);
-        sortedHandlers.addAll(protocolHandlers);
-        return sortedHandlers;
+        if (!protocolHandlers.isEmpty()) {
+            logicalHandlers.addAll(protocolHandlers);
+        }
+        return logicalHandlers;
     }
 
     protected ClassLoader getHandlerClassLoader() {
@@ -117,7 +118,10 @@ public class HandlerChainBuilder {
     protected List<Handler> buildHandlerChain(PortComponentHandlerType ht, ClassLoader
classLoader) {
         List<Handler> handlerChain = new ArrayList<Handler>();
         try {
-            LOG.log(Level.FINE, "loading handler", trimString(ht.getHandlerName().getValue()));
+            final boolean fineLog = LOG.isLoggable(Level.FINE);
+            if (fineLog) {
+                LOG.log(Level.FINE, "loading handler", trimString(ht.getHandlerName().getValue()));
+            }
 
             Class<? extends Handler> handlerClass = Class.forName(
                                                                   trimString(ht.getHandlerClass()
@@ -125,7 +129,9 @@ public class HandlerChainBuilder {
                 .asSubclass(Handler.class);
 
             Handler<?> handler = handlerClass.newInstance();
-            LOG.fine("adding handler to chain: " + handler);
+            if (fineLog) {
+                LOG.fine("adding handler to chain: " + handler);
+            }
             configureHandler(handler, ht);
             handlerChain.add(handler);
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/0985e79a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
index 1c5e3b2..2c2dd01 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerResolverImpl.java
@@ -31,9 +31,7 @@ import javax.xml.ws.handler.PortInfo;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.ResourceInjector;
-import org.apache.cxf.resource.DefaultResourceManager;
 import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.resource.ResourceResolver;
 
 @SuppressWarnings("rawtypes")
 public class HandlerResolverImpl implements HandlerResolver {
@@ -104,9 +102,6 @@ public class HandlerResolverImpl implements HandlerResolver {
     private void configHandler(Handler<?> handler) {
         if (handler != null) {
             ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
-            List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
-            resourceManager = new DefaultResourceManager(resolvers);
-//            resourceManager.addResourceResolver(new WebContextEntriesResourceResolver());
             ResourceInjector injector = new ResourceInjector(resourceManager);
             injector.inject(handler);
             injector.construct(handler);


Mime
View raw message