Author: asoldano
Date: 2014-10-29 12:44:02 -0400 (Wed, 29 Oct 2014)
New Revision: 19038
Modified:
stack/cxf/branches/jbossws-cxf-4.3.x/
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
Log:
Merged revisions 19024-19025,19028,19036-19037 via svnmerge from
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk
.......
r19024 | asoldano | 2014-10-22 16:06:04 +0200 (Wed, 22 Oct 2014) | 2 lines
[JBWS-3848] Optimize HandlerChainSortInterceptor
.......
r19025 | asoldano | 2014-10-22 16:18:29 +0200 (Wed, 22 Oct 2014) | 2 lines
[JBWS-3848] Always cleanup the sorter
.......
r19028 | asoldano | 2014-10-23 19:04:54 +0200 (Thu, 23 Oct 2014) | 2 lines
[JBWS-3848] Use array lists
.......
r19036 | asoldano | 2014-10-29 15:05:50 +0100 (Wed, 29 Oct 2014) | 2 lines
[JBWS-3848] Avoid resetting the handler-chain in the Binding; instead sort the chain
copy that's used to build the handler chain invoker; this hides the process from the
user and adds no processing overhead as the chain is already copied to build an invoker;
sort the chain upfront when building the client (after pre-defined config setup), to speed
up sorting in the best and most common scenario (no manual user change to the chain).
.......
r19037 | asoldano | 2014-10-29 17:09:21 +0100 (Wed, 29 Oct 2014) | 2 lines
Multiple test invocations, to verify the config is not lost after first invocation (no
bug expected, I just used this for debugging JBWS-3848 and thought it might be usefull in
future)
.......
Property changes on: stack/cxf/branches/jbossws-cxf-4.3.x
___________________________________________________________________
Modified: svnmerge-integrated
-
/stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947
+
/stack/cxf/trunk:1-18594,18609-18612,18616-18619,18621,18625-18652,18656-18658,18661,18663,18665-18668,18671-18683,18685-18687,18689-18693,18695,18698,18701,18703-18704,18706-18710,18712-18713,18715,18717-18721,18726-18730,18732,18735-18737,18742,18745-18746,18750-18752,18755-18759,18762,18770,18777-18779,18781-18787,18796,18798,18805-18808,18811-18814,18816,18822-18824,18832-18835,18837,18839-18840,18842-18843,18845,18847-18848,18852,18856-18857,18859-18864,18866,18883-18884,18933,18947,19024-19026,19028,19034-19037
Modified: svn:mergeinfo
- /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947
+ /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/branches/jaspi:18054-18409
/stack/cxf/branches/ropalka:16301-16305,16966-17008
/stack/cxf/branches/ropalka_JBWS-3550:16747-16757
/stack/cxf/trunk:18609,18616-18619,18629,18695,18710,18715,18798,18814,18816,18847,18852,18856,18860-18864,18866,18883-18884,18933,18947,19024-19025,19028,19036-19037
Modified:
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29
16:09:21 UTC (rev 19037)
+++
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2014-10-29
16:44:02 UTC (rev 19038)
@@ -574,7 +574,6 @@
protected void setupClient(Object obj, WebServiceFeature... features) {
Binding binding = ((BindingProvider)obj).getBinding();
Client client = obj instanceof DispatchImpl<?> ?
((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
- client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
if (ClassLoaderProvider.isSet()) { //optimization for avoiding checking for a
server config when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
if (sc != null) {
@@ -586,6 +585,7 @@
}
}
}
+ client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add
this *after* the config has been set (if any)!
if (features != null) {
for (WebServiceFeature f : features) {
if (f instanceof AbstractClientFeature) {
Modified:
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29
16:09:21 UTC (rev 19037)
+++
stack/cxf/branches/jbossws-cxf-4.3.x/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/HandlerChainSortInterceptor.java 2014-10-29
16:44:02 UTC (rev 19038)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * 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.
*
@@ -29,6 +29,8 @@
import javax.xml.ws.handler.Handler;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
@@ -46,25 +48,45 @@
{
private Binding binding;
@SuppressWarnings("rawtypes")
- private static Comparator<Handler> comparator = new
ConfigDelegateHandlerComparator<Handler>();
+ private static final Comparator<Handler> comparator = new
ConfigDelegateHandlerComparator<Handler>();
public HandlerChainSortInterceptor(Binding b)
{
- super(Phase.SETUP);
+ super(Phase.PRE_PROTOCOL);
binding = b;
+ //initially sort and reset the handler chain; if the chain is not modified later,
the sort process
+ //in handleMessage() deals with an already ordered list and is very efficient (~
O(n) according to
+ //Collections.sort(..) javadoc.
+ @SuppressWarnings("rawtypes")
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one
handler only
+ Collections.sort(hc, comparator);
+ binding.setHandlerChain(hc);
+ }
}
@Override
+ @SuppressWarnings("rawtypes")
public void handleMessage(Message message) throws Fault
{
if (binding != null) {
- @SuppressWarnings("rawtypes")
- List<Handler> list = binding.getHandlerChain();
- if (list != null && !list.isEmpty()) {
- Collections.sort(list, comparator);
- binding.setHandlerChain(list);
+ Exchange ex = message.getExchange();
+ if (ex.get(HandlerChainInvoker.class) == null) {
+ List<Handler> hc = binding.getHandlerChain();
+ if (hc.size() > 1) { //no need to sort etc if the chain is empty or has
one handler only
+ Collections.sort(hc, comparator);
+ //install a new HandlerChainInvoker using the sorted handler chain;
+ //the AbstractJAXWSHandlerInterceptor will be using this invoker
+ //instead of creating a new one
+ ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc,
isOutbound(message, ex)));
+ }
}
}
}
-
+
+ private boolean isOutbound(Message message, Exchange ex) {
+ return message == ex.getOutMessage()
+ || message == ex.getOutFaultMessage();
+ }
+
}