cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r546222 [1/3] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/phase/ api/src/test/java/org/apache/cxf/phase/ common/common/src/main/java/org/apache/cxf/common/util/ rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ r...
Date Mon, 11 Jun 2007 18:54:17 GMT
Author: dkulp
Date: Mon Jun 11 11:54:11 2007
New Revision: 546222

URL: http://svn.apache.org/viewvc?view=rev&rev=546222
Log:
Updates to PhaseInterceptorChain, interceptors
* Re-write PhaseInterceptorChain to be more of a linked list instead of list of arrays and such.  Makes the iterator MUCH faster.
* Make the phase lists in PhaseManager a SortedSet so we don't need to re-sort on chain setup.
* Make some stuff in AbstractPhaseInterceptor final so it can be optimized better.
* Make some "ending" interceptors fields to avoid creating a new one for each message.
* Add some "toString" things on phases and chains to make debugging easier


Added:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseManager.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ContentTypeOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingInSetupInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingOutSetupInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DispatchInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DocumentWriterInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/object/src/main/java/org/apache/cxf/binding/object/ObjectDispatchInInterceptor.java
    incubator/cxf/trunk/rt/bindings/object/src/main/java/org/apache/cxf/binding/object/ObjectDispatchOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/EndpointSelectionInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/TestBase.java
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLFaultInterceptorsTest.java
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/xml/src/test/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptorTest.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractEndpointSelectionInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ProviderInDatabindingInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ProviderOutDatabindingInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SoapFaultTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/configured-endpoints.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/soap/SoapBindingSelectionTest.java
    incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
    incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
    incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
    incubator/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java
    incubator/cxf/trunk/rt/ws/security/pom.xml
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/ThrowFaultInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestMultipartMessageInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPVerifier.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageLossSimulator.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/InMessageRecorder.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java Mon Jun 11 11:54:11 2007
@@ -19,23 +19,33 @@
 
 package org.apache.cxf.phase;
 
-import java.util.HashSet;
 import java.util.Set;
 
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.cxf.common.util.SortedArraySet;
 import org.apache.cxf.message.Message;
 
 public abstract class AbstractPhaseInterceptor<T extends Message> implements PhaseInterceptor<T> {
-    private String id;
+    private final String id;
     private String phase;
-    private Set<String> before = new HashSet<String>();
-    private Set<String> after = new HashSet<String>();
+    private final Set<String> before = new SortedArraySet<String>();
+    private final Set<String> after = new SortedArraySet<String>();
 
-    
+    /**
+     * @deprecated
+     */
     public AbstractPhaseInterceptor() {
+        this(null, null);
+    }
+    
+    public AbstractPhaseInterceptor(String phase) {
+        this(null, phase);
+    }
+    public AbstractPhaseInterceptor(String i, String p) {
         super();
-        id = getClass().getName();
+        id = i == null ? getClass().getName() : i;
+        phase = p;
     }
 
     public void addBefore(String i) {
@@ -46,36 +56,20 @@
         after.add(i);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.cxf.phase.PhaseInterceptor#getAfter()
-     */
-    public Set<String> getAfter() {
-        return after;
-    }
 
-    public void setAfter(Set<String> a) {
-        this.after = a;
+    public final Set<String> getAfter() {
+        return after;
     }
 
-    public Set<String> getBefore() {
+    public final Set<String> getBefore() {
         return before;
     }
 
-    public void setBefore(Set<String> b) {
-        this.before = b;
-    }
-
-    public String getId() {
+    public final String getId() {
         return id;
     }
 
-    public void setId(String i) {
-        this.id = i;
-    }
-
-    public String getPhase() {
+    public final String getPhase() {
         return phase;
     }
 

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java Mon Jun 11 11:54:11 2007
@@ -105,4 +105,8 @@
         }
         return priority - p.priority;
     }
+    
+    public String toString() {
+        return "Phase(" + getName() + ")";
+    }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java Mon Jun 11 11:54:11 2007
@@ -19,20 +19,18 @@
 
 package org.apache.cxf.phase;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.ConcurrentModificationException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
-import java.util.TreeMap;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.SortedSet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.message.Message;
@@ -50,33 +48,50 @@
  * or after, supplying fine grained ordering.
  * <p>
  *  
- * @author Dan Diephouse
  */
 public class PhaseInterceptorChain implements InterceptorChain {
 
     private static final Logger LOG = Logger.getLogger(PhaseInterceptorChain.class.getName());
-    
-    private final Map<Phase, List<Interceptor>> interceptors = new TreeMap<Phase, List<Interceptor>>();
-    private final Map<String, List<Interceptor>> nameMap = new HashMap<String, List<Interceptor>>();
 
+    
+    private final Map<String, PhaseHolder> nameMap = new HashMap<String, PhaseHolder>();
+    private final PhaseHolder firstPhase;
+    
     private State state;
-    private PhaseInterceptorIterator iterator;
     private Message pausedMessage;
     private MessageObserver faultObserver;
+    private PhaseInterceptorIterator iterator;
     
     // currently one chain for one request/response, use below as signal to avoid duplicate fault processing
     // on nested calling of doIntercept(), which will throw same fault multi-times
     private boolean faultOccured;
     
-    public PhaseInterceptorChain(List<Phase> ps) {
+    public PhaseInterceptorChain(SortedSet<Phase> ps) {
         state = State.EXECUTING;
- 
+
+        PhaseHolder last = null;
+        PhaseHolder first = null;
         for (Phase phase : ps) {
-            List<Interceptor> ints = new ArrayList<Interceptor>();
-            interceptors.put(phase, ints);
-            nameMap.put(phase.getName(), ints);
+            PhaseHolder ph = new PhaseHolder(phase);
+            if (first == null) {
+                first = ph;
+            }
+            if (last != null) {
+                last.next = ph;
+            }
+            ph.prev = last;
+            last = ph;
+            nameMap.put(phase.getName(), ph);
+        }
+        firstPhase = first;
+    }
+    
+    private void updateIterator() {
+        if (iterator == null) {
+            iterator = new PhaseInterceptorIterator(firstPhase);
+            outputChainToLog(false);
+            //System.out.println(toString());
         }
-        iterator = new PhaseInterceptorIterator();
     }
     
     public void add(Collection<Interceptor> newhandlers) {
@@ -106,13 +121,12 @@
 
         String phaseName = pi.getPhase();
         
-        List<Interceptor> phase = nameMap.get(phaseName);
+        PhaseHolder phase = nameMap.get(phaseName);
         if (phase == null) {
             LOG.fine("Phase " + phaseName + " does not exist. Skipping handler "
                       + i.getClass().getName());
-        } else if (force 
-            | !containsType(CastUtils.cast(phase, PhaseInterceptor.class), pi.getId())) {            
-            insertInterceptor(phase, pi);
+        } else {            
+            insertInterceptor(phase, pi, force);
         }
     }
 
@@ -126,7 +140,6 @@
             doIntercept(pausedMessage);
         }
     }
-    
 
     /**
      * Intercept a message, invoking each phase's handlers in turn.
@@ -136,6 +149,8 @@
      */
     @SuppressWarnings("unchecked")
     public synchronized boolean doIntercept(Message message) {
+        updateIterator();
+        
         pausedMessage = message;
         while (state == State.EXECUTING && iterator.hasNext()) {
             try {
@@ -184,6 +199,7 @@
     @SuppressWarnings("unchecked")
     public synchronized boolean doInterceptStartingAfter(Message message,
                                                          String startingAfterInterceptorID) {
+        updateIterator();
         while (state == State.EXECUTING && iterator.hasNext()) {
             PhaseInterceptor currentInterceptor = (PhaseInterceptor)iterator.next();
             if (currentInterceptor.getId().equals(startingAfterInterceptorID)) {
@@ -204,6 +220,7 @@
     @SuppressWarnings("unchecked")
     public synchronized boolean doInterceptStartingAt(Message message,
                                                          String startingAtInterceptorID) {
+        updateIterator();
         while (state == State.EXECUTING && iterator.hasNext()) {
             PhaseInterceptor currentInterceptor = (PhaseInterceptor)iterator.next();
             if (currentInterceptor.getId().equals(startingAtInterceptorID)) {
@@ -213,10 +230,9 @@
         }
         return doIntercept(message);
     }
-    
-    
-    
+
     public synchronized void reset() {
+        updateIterator();
         if (state == State.COMPLETE) {
             state = State.EXECUTING;
             iterator.reset();
@@ -236,17 +252,16 @@
         }
     }
 
-
     public void remove(Interceptor i) {
-        // TODO
-        PhaseInterceptorIterator it = new PhaseInterceptorIterator();
+        PhaseInterceptorIterator it = new PhaseInterceptorIterator(firstPhase);
         while (it.hasNext()) {
-            if (it.next() == i) {
-                it.remove();
+            InterceptorHolder holder = it.nextInterceptorHolder();
+            if (holder.interceptor == i) {
+                remove(holder);
+                return;
             }
         }
     }
-    
 
     public synchronized void abort() {
         this.state = InterceptorChain.State.ABORTED;
@@ -256,190 +271,289 @@
         return getIterator();
     }
     public ListIterator<Interceptor<? extends Message>> getIterator() {
-        return new PhaseInterceptorIterator();
+        return new PhaseInterceptorIterator(firstPhase);
     }
 
-    protected void insertInterceptor(List<Interceptor> intercs, PhaseInterceptor interc) {
-
-        if (intercs.size() == 0) {
-            intercs.add(interc);
-            return;
+    private void remove(InterceptorHolder i) {
+        if (i.prev != null) {
+            i.prev.next = i.next;
         }
-
-        int begin = -1;
-        int end = intercs.size();
-
-        Collection before = interc.getBefore();
-        Collection after = interc.getAfter();
-
-        for (int i = 0; i < intercs.size(); i++) {
-            PhaseInterceptor cmp = (PhaseInterceptor)intercs.get(i);
+        if (i.next != null) {
+            i.next.prev = i.prev;
+        }
+        PhaseHolder ph = i.phase;
+        if (ph.head == i) {
+            if (i.next != null
+                && i.next.phase == ph) {
+                ph.head = i.next;
+            } else {
+                ph.head = null;
+                ph.tail = null;
+            }
+        }
+        if (ph.tail == i) {
+            if (i.prev != null
+                && i.prev.phase == ph) {
+                ph.tail = i.prev;
+            } else {
+                ph.head = null;
+                ph.tail = null;
+            }
+        }
+    }
+    private void insertInterceptor(PhaseHolder phase, PhaseInterceptor interc, boolean force) {
+        InterceptorHolder ih = new InterceptorHolder(interc, phase);
+        if (phase.head == null) {
+            phase.head = ih;
+            phase.tail = ih;
             
-            if (cmp.getId() == null) {
-                continue;
+            PhaseHolder prev = phase.prev;
+            while (prev != null 
+                && prev.tail == null) {
+                prev = prev.prev;
+            }
+            if (prev != null) {
+                //found something before us
+                ih.prev = prev.tail;
+                ih.next = prev.tail.next;
+                if (ih.next != null) {
+                    ih.next.prev = ih;
+                }
+                prev.tail.next = ih;
+            } else {
+                //did not find something before us, try after
+                prev = phase.next;
+                while (prev != null 
+                    && prev.head == null) {
+                    prev = prev.next;
+                }
+                if (prev != null) {
+                    //found something after us
+                    ih.next = prev.head;
+                    prev.head.prev = ih;
+                }
             }
-
-            if (before.contains(cmp.getId()) && i < end) {
-                end = i;
+            phase.hasAfters = !interc.getAfter().isEmpty();
+            if (iterator != null) {
+                outputChainToLog(true);
+            }
+            return;
+        }
+        
+        Set beforeList = interc.getBefore();
+        Set afterList = interc.getAfter();
+        InterceptorHolder before = null;
+        InterceptorHolder after = null;
+        
+        String id = interc.getId();
+        if (phase.hasAfters
+            || !beforeList.isEmpty()) {
+        
+            InterceptorHolder ih2 = phase.head;
+            while (ih2 != phase.tail.next) {
+                PhaseInterceptor cmp = ih2.interceptor;
+                String cmpId = cmp.getId();
+                if (cmpId != null
+                    && before == null
+                    && (beforeList.contains(cmpId)
+                        || cmp.getAfter().contains(id))) {
+                    //first one we need to be before
+                    before = ih2;
+                } 
+                if (cmpId != null 
+                    && afterList.contains(cmpId)) {
+                    after = ih2;
+                }
+                if (!force
+                    && cmpId.equals(id)) {
+                    return;
+                }
+                ih2 = ih2.next;
             }
-            if (cmp.getBefore().contains(interc.getId()) && i > begin) {
-                begin = i;
-                if (end < begin) {
-                    intercs.remove(cmp);
-                    intercs.add(end, cmp);
-                    i = end;
-                    begin = end;
-                    end = begin + 1;
+            if (after == null
+                && beforeList.contains("*")) {
+                before = phase.head;
+            }
+            //System.out.print("Didn't skip: " + phase.toString());
+            //System.out.println("             " + interc.getId());
+        } else if (!force) {
+            InterceptorHolder ih2 = phase.head;
+            while (ih2 != phase.tail.next) {
+                PhaseInterceptor cmp = ih2.interceptor;
+                String cmpId = cmp.getId();
+                if (!force
+                    && cmpId.equals(id)) {
+                    return;
                 }
+                ih2 = ih2.next;
             }
-
-            if (after.contains(cmp.getId()) && i > begin) {
-                begin = i;
+            
+            //System.out.print("Skipped: " + phase.toString());
+            //System.out.println("         " + interc.getId());
+        }
+        phase.hasAfters |= afterList.isEmpty();
+        
+        if (before == null) {
+            //just add at the end
+            ih.prev = phase.tail;
+            if (phase.tail != null) {
+                ih.next = phase.tail.next;
+                phase.tail.next = ih;
             }
-
-            if (cmp.getAfter().contains(interc.getId()) && i < end) {
-                end = i;
+            if (ih.next != null) {
+                ih.next.prev = ih;
+            }
+            phase.tail = ih;
+        } else {
+            ih.prev = before.prev;
+            if (ih.prev != null) {
+                ih.prev.next = ih;
+            }
+            ih.next = before;
+            before.prev = ih;
+            
+            if (phase.head == before) {
+                phase.head = ih;
             }
         }
-
-        if (end < begin + 1) {
-            throw new IllegalStateException("Invalid ordering for handler " + interc.getClass().getName());
+        if (iterator != null) {
+            outputChainToLog(true);
         }
+    }
 
-        intercs.add(begin + 1, interc);
+    public String toString() {
+        return toString(""); 
+    }
+    private String toString(String message) {
+        StringBuilder chain = new StringBuilder();
         
+        chain.append("Chain ")
+            .append(super.toString())
+            .append(message)
+            .append(". Current flow:\n");
+        
+        PhaseHolder ph = firstPhase;
+        while (ph != null) {
+            if (ph.head != null) {
+                chain.append("  ");
+                printPhase(ph, chain);
+            }
+            ph = ph.next;
+        }
+        return chain.toString();
+    }
+    private static void printPhase(PhaseHolder ph, StringBuilder chain) {
+        chain.append(ph.phase.getName())
+            .append(" [");
+        InterceptorHolder i = ph.head;
+        boolean first = true;
+        while (i != ph.tail.next) {
+            if (first) {
+                first = false;
+            } else {
+                chain.append(", ");
+            }
+            chain.append(i.interceptor.getClass().getSimpleName());
+            i = i.next;
+        }
+        chain.append("]\n");
     }
-
-    void outputChainToLog(boolean modified) {
+    
+    private void outputChainToLog(boolean modified) {
         if (LOG.isLoggable(Level.FINE)) {
-            StringBuilder chain = new StringBuilder();
-            
             if (modified) {
-                chain.append("Chain ")
-                    .append(toString())
-                    .append(" was modified. Current flow:\n");
+                LOG.fine(toString(" was modified"));
             } else {
-                chain.append("Chain ")
-                    .append(toString())
-                    .append(" was created. Current flow:\n");
+                LOG.fine(toString(" was created"));
             }
-            
-            for (Map.Entry<Phase, List<Interceptor>> entry : interceptors.entrySet()) {
-                chain.append("  ")
-                    .append(entry.getKey().getName())
-                    .append(" [");
-                
-                boolean first = true;
-                for (Interceptor i : entry.getValue()) {
-                    if (first) {
-                        first = false;
-                    } else {
-                        chain.append(", ");
-                    }
-                    chain.append(i.getClass().getSimpleName());
-                }
-                
-                chain.append("]\n");
-            }
-            LOG.fine(chain.toString());
         }
     }
     
-    boolean containsType(List<PhaseInterceptor> phase, String id) {
-        for (PhaseInterceptor pi : phase) {
-            if (id.equals(pi.getId())) {
-                return true;
-            }
-        }
-        return false;
+    public MessageObserver getFaultObserver() {
+        return faultObserver;
+    }
+    
+    public void setFaultObserver(MessageObserver faultObserver) {
+        this.faultObserver = faultObserver;
     }
     
-    class PhaseInterceptorIterator implements ListIterator<Interceptor<? extends Message>> {
-        List<Interceptor<? extends Message>> called
-            = new ArrayList<Interceptor<? extends Message>>();
+    static final class PhaseInterceptorIterator implements ListIterator<Interceptor<? extends Message>> {
+        PhaseHolder firstPhase;
+        InterceptorHolder prev;
+        InterceptorHolder first;
         
-        Iterator<List<Interceptor>> phases;
-        List<Interceptor> currentPhase;
-        ListIterator<Interceptor> currentPhaseIterator;
-        Interceptor<? extends Message> last;
-        boolean first = true;
+        public PhaseInterceptorIterator(PhaseHolder f) {
+            firstPhase = f;
+            first = findFirst();
+        }
+        
+        public void reset() {
+            prev = null;
+            first = findFirst();
+        }
         
-        PhaseInterceptorIterator() {
-            phases = interceptors.values().iterator();
-            if (phases.hasNext()) {
-                currentPhase = phases.next();
-                currentPhaseIterator = currentPhase.listIterator();
-                last = null;
+        private InterceptorHolder findFirst() {
+            PhaseHolder ph = firstPhase;
+            while (ph != null && ph.head == null) {
+                ph = ph.next;
             }
+            if (ph != null) {
+                return ph.head;
+            }
+            return null;
         }
+        
+        
         public boolean hasNext() {
-            if (currentPhaseIterator != null) {
-                try {
-                    if (currentPhaseIterator.hasNext()) {
-                        return true; 
-                    }
-                    nextPhase();
-                } catch (ConcurrentModificationException cme) {
-                    refreshIterator();
-                }
-                return hasNext();
-            } 
-            
-            if (first) {
-                outputChainToLog(false);
-                first = false;
+            if (prev == null) {
+                return first != null;
             }
-            
-            return false;
+            return prev.next != null;
         }
-        private void refreshIterator() {
-            currentPhaseIterator = currentPhase.listIterator();
-            if (last != null) {
-                while (currentPhaseIterator.hasNext()
-                    && last != currentPhaseIterator.next()) {
-                    //nothing
+
+        @SuppressWarnings("unchecked")
+        public Interceptor<? extends Message> next() {
+            if (prev == null) {
+                if (first == null) {
+                    throw new NoSuchElementException();
+                }
+                prev = first;
+            } else {
+                if (prev.next == null) {
+                    throw new NoSuchElementException();
                 }
+                prev = prev.next;
             }
+            return prev.interceptor;
         }
-        private void nextPhase() {
-            if (phases.hasNext()) {
-                currentPhase = phases.next();
-                currentPhaseIterator = currentPhase.listIterator();
-                last = null;
+        public InterceptorHolder nextInterceptorHolder() {
+            if (prev == null) {
+                if (first == null) {
+                    throw new NoSuchElementException();
+                }
+                prev = first;
             } else {
-                currentPhase = null;
-                currentPhaseIterator = null;
-                last = null;
+                if (prev.next == null) {
+                    throw new NoSuchElementException();
+                }
+                prev = prev.next;
             }
+            return prev;
         }
         
-        @SuppressWarnings("unchecked")
-        public Interceptor<? extends Message> next() {
-            if (currentPhaseIterator != null) {
-                try {
-                    last = currentPhaseIterator.next();
-                    called.add(last);
-                    return last;
-                } catch (ConcurrentModificationException cme) {
-                    refreshIterator();
-                    return next();
-                }                
-            }
-            return null;
-        }
-
         public boolean hasPrevious() {
-            return !called.isEmpty();
+            return prev != null;
         }
-        
         @SuppressWarnings("unchecked")
         public Interceptor<? extends Message> previous() {
-            if (currentPhaseIterator.hasPrevious()) {
-                currentPhaseIterator.previous();
+            if (prev == null) {
+                throw new NoSuchElementException();
             }
-            return called.remove(called.size() - 1);
+            InterceptorHolder tmp = prev;
+            prev = prev.prev;
+            return tmp.interceptor;
         }
-
+        
         public int nextIndex() {
             throw new UnsupportedOperationException();
         }
@@ -449,38 +563,51 @@
         public void add(Interceptor o) {
             throw new UnsupportedOperationException();
         }
-        public void remove() {
-            if (currentPhaseIterator != null) {
-                currentPhaseIterator.remove();
-            }
-            // throw new UnsupportedOperationException();
-        }
         public void set(Interceptor o) {
             throw new UnsupportedOperationException();
         }
-
-        protected void reset() {
-            phases = interceptors.values().iterator();
-            if (phases.hasNext()) {
-                currentPhase = phases.next();
-                currentPhaseIterator = currentPhase.listIterator();
-                last = null;
-            }
-            outputChainToLog(true);
+        public void remove() {
+            throw new UnsupportedOperationException();
         }
     }
 
 
 
-    public MessageObserver getFaultObserver() {
-        return faultObserver;
+    
+    
+    static final class InterceptorHolder {
+        PhaseInterceptor interceptor;
+        InterceptorHolder next;
+        InterceptorHolder prev;
+        PhaseHolder phase;
+        
+        InterceptorHolder(PhaseInterceptor i, PhaseHolder p) {
+            interceptor = i;
+            phase = p;
+        }
     }
     
+    static final class PhaseHolder implements Comparable {
+        Phase phase;
+        PhaseHolder next;
+        PhaseHolder prev;
+        
+        InterceptorHolder head;
+        InterceptorHolder tail;
+        boolean hasAfters;
+        
+        PhaseHolder(Phase p) {
+            phase = p;
+        }
 
-    public void setFaultObserver(MessageObserver faultObserver) {
-        this.faultObserver = faultObserver;
+        public int compareTo(Object o) {
+            return phase.compareTo(((PhaseHolder)o).phase);
+        }
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            printPhase(this, builder);
+            return builder.toString();
+        }
     }
-    
-    
 
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseManager.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseManager.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseManager.java Mon Jun 11 11:54:11 2007
@@ -19,10 +19,10 @@
 
 package org.apache.cxf.phase;
 
-import java.util.List;
+import java.util.SortedSet;
 
 public interface PhaseManager {
-    List<Phase> getInPhases();
+    SortedSet<Phase> getInPhases();
 
-    List<Phase> getOutPhases();
+    SortedSet<Phase> getOutPhases();
 }

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java Mon Jun 11 11:54:11 2007
@@ -19,12 +19,14 @@
 
 package org.apache.cxf.phase;
 
-import java.util.ArrayList;
+import java.lang.reflect.Field;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
+import org.apache.cxf.common.util.SortedArraySet;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
 import org.easymock.classextension.EasyMock;
@@ -51,7 +53,7 @@
         Phase phase1 = new Phase("phase1", 1);
         Phase phase2 = new Phase("phase2", 2);
         Phase phase3 = new Phase("phase3", 3);
-        List<Phase> phases = new ArrayList<Phase>();
+        SortedSet<Phase> phases = new TreeSet<Phase>();
         phases.add(phase1);
         phases.add(phase2);
         phases.add(phase3);
@@ -65,7 +67,7 @@
     }
 
     @Test
-    public void testAddOneInterceptor() {
+    public void testAddOneInterceptor() throws Exception {
         AbstractPhaseInterceptor p = setUpPhaseInterceptor("phase1", "p1");
         control.replay();
         chain.add(p);
@@ -75,7 +77,7 @@
     }
     
     @Test
-    public void testForceAddSameInterceptor() {
+    public void testForceAddSameInterceptor() throws Exception {
 
         AbstractPhaseInterceptor p = setUpPhaseInterceptor("phase1", "p1");
         control.replay();
@@ -92,7 +94,7 @@
     }
     
     @Test
-    public void testForceAddSameInterceptorType() {
+    public void testForceAddSameInterceptorType() throws Exception {
 
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p1");
@@ -104,18 +106,17 @@
         assertTrue(!it.hasNext());
         chain.add(p2, true);
         it = chain.iterator();
-        assertSame(p2, it.next());
         assertSame(p1, it.next());
+        assertSame(p2, it.next());
         assertTrue(!it.hasNext()); 
     }
 
     @Test
-    public void testAddTwoInterceptorsSamePhase() {
+    public void testAddTwoInterceptorsSamePhase() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         Set<String> after = new HashSet<String>();
         after.add("p1");
-        AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2",
-                after);
+        AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2", null, after);
         control.replay();
         chain.add(p1);
         chain.add(p2);
@@ -125,37 +126,22 @@
         assertSame("Unexpected interceptor at this position.", p2, it.next());
         assertTrue(!it.hasNext());
     }
-    
-    AbstractPhaseInterceptor setUpPhaseInterceptor(String phase, String id,
-                                                   Set<String> b, boolean be) {
-        AbstractPhaseInterceptor p = control
-            .createMock(AbstractPhaseInterceptor.class);
-        EasyMock.expect(p.getPhase()).andReturn(phase).anyTimes();
-        EasyMock.expect(p.getId()).andReturn(id).anyTimes();
-        Set<String> after = new HashSet<String>();
-        Set<String> before = null == b ? new HashSet<String>() : b;
-        EasyMock.expect(p.getBefore()).andReturn(before).anyTimes();
-        EasyMock.expect(p.getAfter()).andReturn(after).anyTimes();
-
-        return p;
-    }
-    
+        
     @Test
-    public void testThreeInterceptorSamePhaseWithOrder() {
+    public void testThreeInterceptorSamePhaseWithOrder() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         Set<String> before = new HashSet<String>();
         before.add("p1");
-        AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2", before, true);
+        AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2", before, null);
         Set<String> before1 = new HashSet<String>();
         before1.add("p2");
-        AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3", before1, true);
+        AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3", before1, null);
         control.replay();
         chain.add(p3);
         chain.add(p1);
         chain.add(p2);
         
         Iterator<Interceptor<? extends Message>> it = chain.iterator();
-
         assertSame("Unexpected interceptor at this position.", p3, it.next());
         assertSame("Unexpected interceptor at this position.", p2, it.next());
         assertSame("Unexpected interceptor at this position.", p1, it.next());
@@ -163,7 +149,7 @@
     }
 
     @Test
-    public void testSingleInterceptorPass() {
+    public void testSingleInterceptorPass() throws Exception {
         AbstractPhaseInterceptor p = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p, false, false);
         control.replay();
@@ -172,7 +158,7 @@
     }
 
     @Test
-    public void testSingleInterceptorFail() {
+    public void testSingleInterceptorFail() throws Exception {
         AbstractPhaseInterceptor p = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p, true, true);
         control.replay();
@@ -181,7 +167,7 @@
     }
 
     @Test
-    public void testTwoInterceptorsInSamePhasePass() {
+    public void testTwoInterceptorsInSamePhasePass() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p1, false, false);
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2");
@@ -193,33 +179,33 @@
     }
 
     @Test
-    public void testThreeInterceptorsInSamePhaseSecondFail() {
+    public void testThreeInterceptorsInSamePhaseSecondFail() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p1, false, true);
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2");
         setUpPhaseInterceptorInvocations(p2, true, true);
         AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3");
         control.replay();
-        chain.add(p3);
-        chain.add(p2);
         chain.add(p1);
+        chain.add(p2);
+        chain.add(p3);
         chain.doIntercept(message);
     }
 
     @Test
-    public void testTwoInterceptorsInSamePhaseSecondFail() {
+    public void testTwoInterceptorsInSamePhaseSecondFail() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p1, false, true);
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2");
         setUpPhaseInterceptorInvocations(p2, true, true);
         control.replay();
-        chain.add(p2);
         chain.add(p1);
+        chain.add(p2);
         chain.doIntercept(message);
     }
 
     @Test
-    public void testTwoInterceptorsInDifferentPhasesPass() {
+    public void testTwoInterceptorsInDifferentPhasesPass() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p1, false, false);
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase2", "p2");
@@ -231,7 +217,7 @@
     }
 
     @Test
-    public void testTwoInterceptorsInDifferentPhasesSecondFail() {
+    public void testTwoInterceptorsInDifferentPhasesSecondFail() throws Exception {
         AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
         setUpPhaseInterceptorInvocations(p1, false, true);
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase2", "p2");
@@ -243,7 +229,7 @@
     }
 
     @Test
-    public void testInsertionInDifferentPhasePass() {
+    public void testInsertionInDifferentPhasePass() throws Exception {
 
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase2", "p2");
         setUpPhaseInterceptorInvocations(p2, false, false);
@@ -260,14 +246,13 @@
     }
 
     @Test
-    public void testInsertionInSamePhasePass() {
+    public void testInsertionInSamePhasePass() throws Exception {
 
         AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2");
         setUpPhaseInterceptorInvocations(p2, false, false);
         Set<String> after3 = new HashSet<String>();
         after3.add("p2");
-        AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3",
-                after3);
+        AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3", null, after3);
         setUpPhaseInterceptorInvocations(p3, false, false);
         InsertingPhaseInterceptor p1 = new InsertingPhaseInterceptor(chain, p3,
                 "phase1", "p1");
@@ -324,24 +309,45 @@
         assertEquals(1, p3.invoked);
     }
     
-    AbstractPhaseInterceptor setUpPhaseInterceptor(String phase, String id) {
-        return setUpPhaseInterceptor(phase, id, null);
+    AbstractPhaseInterceptor setUpPhaseInterceptor(String phase, String id) throws Exception {
+        return setUpPhaseInterceptor(phase, id, null, null);
     }
 
-    AbstractPhaseInterceptor setUpPhaseInterceptor(String phase, String id,
-            Set<String> a) {
+    @SuppressWarnings("unchecked")
+    AbstractPhaseInterceptor setUpPhaseInterceptor(final String phase, 
+                                                   final String id,
+                                                   Set<String> b,
+                                                   Set<String> a) throws Exception {
+        
         AbstractPhaseInterceptor p = control
-                .createMock(AbstractPhaseInterceptor.class);
-        EasyMock.expect(p.getPhase()).andReturn(phase).anyTimes();
-        EasyMock.expect(p.getId()).andReturn(id).anyTimes();
-        Set<String> before = new HashSet<String>();
-        Set<String> after = null == a ? new HashSet<String>() : a;
-        EasyMock.expect(p.getBefore()).andReturn(before).anyTimes();
-        EasyMock.expect(p.getAfter()).andReturn(after).anyTimes();
+            .createMock(AbstractPhaseInterceptor.class);
+        
+        if (a == null) {
+            a = new SortedArraySet<String>();
+        }
+        if (b == null) {
+            b = new SortedArraySet<String>();
+        }
+        Field f = AbstractPhaseInterceptor.class.getDeclaredField("before");
+        f.setAccessible(true);
+        f.set(p, b);
+        
+        f = AbstractPhaseInterceptor.class.getDeclaredField("after");
+        f.setAccessible(true);
+        f.set(p, a);
+
+        f = AbstractPhaseInterceptor.class.getDeclaredField("phase");
+        f.setAccessible(true);
+        f.set(p, phase);
+
+        f = AbstractPhaseInterceptor.class.getDeclaredField("id");
+        f.setAccessible(true);
+        f.set(p, id);
 
         return p;
     }
     
+    
     @SuppressWarnings("unchecked")
     void setUpPhaseInterceptorInvocations(AbstractPhaseInterceptor p,
             boolean fail, boolean expectFault) {
@@ -372,8 +378,7 @@
 
         public InsertingPhaseInterceptor(PhaseInterceptorChain c,
                 AbstractPhaseInterceptor i, String phase, String id) {
-            setPhase(phase);
-            setId(id);
+            super(id, phase);
             insertionChain = c;
             insertionInterceptor = i;
         }
@@ -393,8 +398,7 @@
         int invoked;
 
         public CountingPhaseInterceptor(String phase, String id) {
-            setPhase(phase);
-            setId(id);
+            super(id, phase);
         }
 
         public void handleMessage(Message m) {

Added: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java?view=auto&rev=546222
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java (added)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java Mon Jun 11 11:54:11 2007
@@ -0,0 +1,259 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.common.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.SortedSet;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+/**
+ * This class implements most of the <tt>Set</tt> interface, backed by a 
+ * sorted Array.  This makes iterators very fast, lookups are log(n), but
+ * adds are fairly expensive.
+ * 
+ * This class is also threadsafe, but without synchronizations.   Lookups
+ * and iterators will iterate over the state of the Set when the iterator
+ * was created.
+ *
+ * If no data is stored in the Set, it uses very little memory.  The backing
+ * array is created on demand.
+ * 
+ * This class is primarly useful for stuff that will be setup at startup, but
+ * then iterated over MANY times during runtime.
+ *   
+ * @param <T>
+ */
+public final class SortedArraySet<T> implements SortedSet<T> {
+    final AtomicReference<T[]> data = new AtomicReference<T[]>();
+
+    public void clear() {
+        data.set(null);
+    }
+
+    public boolean isEmpty() {
+        T[] tmp = data.get();
+        return tmp == null || tmp.length == 0;
+    }
+
+    public Iterator<T> iterator() {
+        return new SASIterator<T>(data.get());
+    }
+
+    public int size() {
+        T[] tmp = data.get();
+        return tmp == null ? 0 : tmp.length;
+    }
+    
+    @SuppressWarnings("unchecked")
+    private T[] newArray(int size) {
+        return (T[])new Object[size];
+    }
+    
+    public boolean add(T o) {
+        if (!contains(o)) {
+            T[] tmp = data.get();
+            T[] tmp2;
+            if (tmp == null) {
+                tmp2 = newArray(1);
+                tmp2[0] = o;
+            } else {
+                tmp2 = newArray(tmp.length + 1);
+                System.arraycopy(tmp, 0, tmp2, 0, tmp.length);
+                tmp2[tmp2.length - 1] = o;
+                Arrays.sort(tmp2);
+            }
+            
+            if (!data.compareAndSet(tmp, tmp2)) {
+                return add(o);
+            }
+            return true;
+        }
+        return false;
+    }
+    public boolean addAll(Collection<? extends T> c) {
+        boolean val = false;
+        for (T t : c) {
+            val |= add(t);
+        }
+        return val;
+    }
+    public boolean containsAll(Collection<?> c) {
+        boolean val = false;
+        for (Object t : c) {
+            val |= contains(t);
+        }
+        return val;
+    }
+
+    public boolean contains(Object o) {
+        T[] tmp = data.get();
+        if (tmp == null) {
+            return false;
+        }
+        return Arrays.binarySearch(tmp, o) >= 0;
+    }
+
+    public boolean removeAll(Collection<?> c) {
+        boolean val = false;
+        for (Object t : c) {
+            val |= remove(t);
+        }
+        return val;
+    }
+    public boolean retainAll(Collection<?> c) {
+        boolean val = false;
+        for (T t : this) {
+            if (!c.contains(t)) {
+                val |= remove(t);
+            }
+        }
+        return val;
+    }
+
+    public boolean remove(Object o) {
+        T[] tmp = data.get();
+        
+        if (tmp == null) {
+            return false;
+        }
+        int idx = Arrays.binarySearch(tmp, o);
+        if (idx != -1) {
+            if (tmp.length == 1 
+                && !data.compareAndSet(tmp, null)) {
+                return remove(o);
+            }
+            T[] tmp2 = newArray(tmp.length - 1);
+            System.arraycopy(tmp, 0, tmp2, 0, idx);
+            System.arraycopy(tmp, idx + 1, tmp2, idx, tmp.length - 1 - idx);
+            if (!data.compareAndSet(tmp, tmp2)) {
+                return remove(o);
+            }
+            return true;
+        }
+        return false;
+    }
+
+
+    public Object[] toArray() {
+        T[] tmp = data.get();
+        if (tmp == null) {
+            return new Object[0];
+        }
+        T[] tmp2 = newArray(tmp.length);
+        System.arraycopy(tmp, 0, tmp2, 0, tmp.length);
+        return tmp2;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <X> X[] toArray(X[] a) {
+        T[] tmp = data.get();
+        if (tmp == null && a.length != 0) {
+            return (X[])java.lang.reflect.Array.
+                newInstance(a.getClass().getComponentType(), 0);
+        }
+        
+        if (a.length < tmp.length) {
+            a = (X[])java.lang.reflect.Array.
+                newInstance(a.getClass().getComponentType(), tmp.length);
+        }
+        System.arraycopy(tmp, 0, a, 0, tmp.length);
+        if (a.length > tmp.length) {
+            a[tmp.length] = null;
+        }
+        return a;
+    }
+
+    @SuppressWarnings("unchecked")
+    public boolean equals(Object o) {
+        SortedArraySet<T> as = (SortedArraySet<T>)o;
+        return Arrays.equals(data.get(), as.data.get());
+    }
+    public String toString() {
+        return Arrays.toString(data.get());
+    }
+    public int hashCode() {
+        return Arrays.hashCode(data.get()); 
+    }
+    
+
+    private class SASIterator<X> implements Iterator<X> {
+        final X[] data;
+        int idx;
+        
+        public SASIterator(X[] d) {
+            data = d;
+        }
+        
+        public boolean hasNext() {
+            return data != null && idx != data.length;
+        }
+
+        public X next() {
+            if (data == null || idx == data.length) {
+                throw new NoSuchElementException();
+            }
+            return data[idx++];
+        }
+
+        public void remove() {
+            if (idx > 0) {
+                SortedArraySet.this.remove(data[idx - 1]);
+            }
+        }
+    }
+
+
+    public Comparator<? super T> comparator() {
+        return null;
+    }
+
+    public T first() {
+        T[] tmp = data.get();
+        if (tmp == null || tmp.length == 0) {
+            return null;
+        }
+        return tmp[0];
+    }
+    
+    public T last() {
+        T[] tmp = data.get();
+        if (tmp == null || tmp.length == 0) {
+            return null;
+        }
+        return tmp[tmp.length - 1];
+    }
+
+    public SortedSet<T> headSet(T toElement) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SortedSet<T> subSet(T fromElement, T toElement) {
+        throw new UnsupportedOperationException();
+    }
+
+    public SortedSet<T> tailSet(T fromElement) {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SortedArraySet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java Mon Jun 11 11:54:11 2007
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.binding.coloc;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.InFaultChainInitiatorObserver;
@@ -30,10 +30,10 @@
 
 public class ColocInFaultObserver extends InFaultChainInitiatorObserver {
 
-    private List<Phase> list;
+    private SortedSet<Phase> list;
     public ColocInFaultObserver(Bus bus) {
         super(bus);
-        list = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
+        list = new TreeSet<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
         ColocUtil.setPhases(list, Phase.PRE_LOGICAL, Phase.PRE_INVOKE);
     }
 
@@ -42,7 +42,7 @@
         chain.add(new WebFaultInInterceptor());
     }
 
-    protected List<Phase> getPhases() {
+    protected SortedSet<Phase> getPhases() {
         return list;
     }
 }

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java Mon Jun 11 11:54:11 2007
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.binding.coloc;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 //import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -38,13 +38,13 @@
 import org.apache.cxf.service.model.MessageInfo;
 
 public class ColocInInterceptor extends AbstractPhaseInterceptor<Message> {
+    
 //    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocInInterceptor.class);
     private static final Logger LOG = Logger.getLogger(ColocInInterceptor.class.getName());
 
     
     public ColocInInterceptor() {
-        super();
-        setPhase(Phase.INVOKE);
+        super(Phase.INVOKE);
         addAfter(ServiceInvokerInterceptor.class.getName());
     }
 
@@ -55,7 +55,7 @@
         }
 
         Bus bus = ex.get(Bus.class);
-        List<Phase> phases = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
+        SortedSet<Phase> phases = new TreeSet<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
 
         //TODO Set Coloc FaultObserver chain
         ColocUtil.setPhases(phases, Phase.SETUP, Phase.USER_LOGICAL);

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java Mon Jun 11 11:54:11 2007
@@ -20,6 +20,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -80,7 +82,7 @@
         }
 
         //Add all interceptors between USER_LOGICAL and INVOKE.
-        List<Phase> phases = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
+        SortedSet<Phase> phases = new TreeSet<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
         ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.INVOKE);
         InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
         chain.add(addColocInterceptors());

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java Mon Jun 11 11:54:11 2007
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.binding.coloc;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.OutFaultChainInitiatorObserver;
@@ -28,14 +28,14 @@
 
 public class ColocOutFaultObserver extends OutFaultChainInitiatorObserver {
 
-    List<Phase> list;
+    SortedSet<Phase> list;
     public ColocOutFaultObserver(Bus bus) {
         super(bus);
-        list = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
+        list = new TreeSet<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
         ColocUtil.setPhases(list, Phase.SETUP, Phase.USER_LOGICAL);        
     }
 
-    protected List<Phase> getPhases() {
+    protected SortedSet<Phase> getPhases() {
         return list;
     }
 }

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java Mon Jun 11 11:54:11 2007
@@ -18,9 +18,10 @@
  */
 package org.apache.cxf.binding.coloc;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.ResourceBundle;
+import java.util.SortedSet;
+import java.util.TreeSet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -56,8 +57,7 @@
     private Bus bus; 
     
     public ColocOutInterceptor() {
-        super();
-        setPhase(Phase.POST_LOGICAL);
+        super(Phase.POST_LOGICAL);
     }
 
     public void setBus(Bus bus) {
@@ -155,7 +155,7 @@
             //Handle Response
             ex.setInMessage(inMsg);
             PhaseManager pm = bus.getExtension(PhaseManager.class);
-            List<Phase> phases = new ArrayList<Phase>(pm.getInPhases());
+            SortedSet<Phase> phases = new TreeSet<Phase>(pm.getInPhases());
             ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE);
             
             InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);        

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java Mon Jun 11 11:54:11 2007
@@ -21,7 +21,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
+import java.util.SortedSet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -45,10 +45,10 @@
         //Completge
     }
 
-    public static void setPhases(List<Phase> list, String start, String end) {
+    public static void setPhases(SortedSet<Phase> list, String start, String end) {
         Phase startPhase = new Phase(start, 1);
         Phase endPhase = new Phase(end, 2);
-        ListIterator<Phase> iter = list.listIterator();
+        Iterator<Phase> iter = list.iterator();
         boolean remove = true;
         while (iter.hasNext()) {
             Phase p = iter.next();
@@ -63,7 +63,7 @@
         }
     }
     
-    public static InterceptorChain getOutInterceptorChain(Exchange ex, List<Phase> phases) {
+    public static InterceptorChain getOutInterceptorChain(Exchange ex, SortedSet<Phase> phases) {
         Bus bus = ex.get(Bus.class);
         PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
         
@@ -87,7 +87,7 @@
         return chain;
     }
     
-    public static InterceptorChain getInInterceptorChain(Exchange ex, List<Phase> phases) {
+    public static InterceptorChain getInInterceptorChain(Exchange ex, SortedSet<Phase> phases) {
         Bus bus = ex.get(Bus.class);
         PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
         

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java Mon Jun 11 11:54:11 2007
@@ -34,8 +34,7 @@
 public class WebFaultInInterceptor extends AbstractPhaseInterceptor<Message> {
 
     public WebFaultInInterceptor() {
-        super();
-        setPhase(Phase.PRE_LOGICAL);
+        super(Phase.PRE_LOGICAL);
     }
 
     public void handleMessage(Message message) throws Fault {

Modified: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java (original)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java Mon Jun 11 11:54:11 2007
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.SortedSet;
 
 import javax.xml.namespace.QName;
 
@@ -70,17 +71,17 @@
     @Test
     public void testSetColocInPhases() throws Exception {
         PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
-        List<Phase> list = phaseMgr.getInPhases();
+        SortedSet<Phase> list = phaseMgr.getInPhases();
         int size1 = list.size();
         ColocUtil.setPhases(list, Phase.USER_LOGICAL, Phase.INVOKE);
 
         assertNotSame("The list size should not be same",
                       size1, list.size());
         assertEquals("Expecting Phase.USER_LOGICAL",
-                     list.get(0).getName(),
+                     list.first().getName(),
                      Phase.USER_LOGICAL);
         assertEquals("Expecting Phase.POST_INVOKE",
-                     list.get(list.size() - 1).getName(),
+                     list.last().getName(),
                      Phase.INVOKE);
     }
 
@@ -88,17 +89,17 @@
     public void testSetColocOutPhases() throws Exception {
         PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
 
-        List<Phase> list = phaseMgr.getOutPhases();
+        SortedSet<Phase> list = phaseMgr.getOutPhases();
         int size1 = list.size();
         ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
 
         assertNotSame("The list size should not be same",
                       size1, list.size());
         assertEquals("Expecting Phase.SETUP",
-                     list.get(0).getName(),
+                     list.first().getName(),
                      Phase.SETUP);
         assertEquals("Expecting Phase.POST_LOGICAL",
-                     list.get(list.size() - 1).getName(),
+                     list.last().getName(),
                      Phase.POST_LOGICAL);
 
     }
@@ -106,7 +107,7 @@
     @Test
     public void testGetOutInterceptorChain() throws Exception {
         PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
-        List<Phase> list = phaseMgr.getInPhases();
+        SortedSet<Phase> list = phaseMgr.getInPhases();
         ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
         
         Endpoint ep = control.createMock(Endpoint.class);
@@ -135,7 +136,7 @@
     @Test
     public void testGetInInterceptorChain() throws Exception {
         PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
-        List<Phase> list = phaseMgr.getInPhases();
+        SortedSet<Phase> list = phaseMgr.getInPhases();
         ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
         
         Endpoint ep = control.createMock(Endpoint.class);

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ContentTypeOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ContentTypeOutInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ContentTypeOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ContentTypeOutInterceptor.java Mon Jun 11 11:54:11 2007
@@ -27,6 +27,7 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -34,8 +35,8 @@
 public class ContentTypeOutInterceptor extends AbstractPhaseInterceptor<Message> {
 
     public ContentTypeOutInterceptor() {
-        super();
-        setPhase(Phase.PREPARE_SEND);
+        super(Phase.PREPARE_SEND);
+        addBefore(MessageSenderInterceptor.class.getName());
     }
 
     public void handleMessage(Message message) throws Fault {

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingInSetupInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingInSetupInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingInSetupInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingInSetupInterceptor.java Mon Jun 11 11:54:11 2007
@@ -29,7 +29,7 @@
 import org.apache.cxf.phase.Phase;
 
 public class DatabindingInSetupInterceptor extends AbstractPhaseInterceptor<Message> {
-
+    
     private static final WrappedInInterceptor WRAPPED_IN = new WrappedInInterceptor();
     private static final XMLMessageInInterceptor XML_IN = new XMLMessageInInterceptor();
     private static final DocLiteralInInterceptor DOCLIT_IN = new DocLiteralInInterceptor();
@@ -38,8 +38,7 @@
     private static final DispatchInterceptor DISPATCH_IN = new DispatchInterceptor();
     
     public DatabindingInSetupInterceptor() {
-        super();
-        setPhase(Phase.RECEIVE);
+        super(Phase.RECEIVE);
     }
 
     public void handleMessage(Message message) throws Fault {
@@ -47,9 +46,9 @@
         InterceptorChain chain = message.getInterceptorChain();
         
         if (client) {
-            chain.add(WRAPPED_IN);
-            chain.add(XML_IN);
             chain.add(DOCLIT_IN);
+            chain.add(XML_IN);
+            chain.add(WRAPPED_IN);
             chain.add(STAX_IN);
         } else {
             chain.add(URI_IN);

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingOutSetupInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingOutSetupInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingOutSetupInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DatabindingOutSetupInterceptor.java Mon Jun 11 11:54:11 2007
@@ -38,14 +38,12 @@
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
 public class DatabindingOutSetupInterceptor extends AbstractPhaseInterceptor<Message> {
-
     private static final WrappedOutInterceptor WRAPPED_OUT = new WrappedOutInterceptor();
     private static final XMLMessageOutInterceptor XML_OUT = new XMLMessageOutInterceptor();
     private static final StaxOutInterceptor STAX_OUT = new StaxOutInterceptor();
     
     public DatabindingOutSetupInterceptor() {
-        super();
-        setPhase(Phase.PRE_LOGICAL);
+        super(Phase.PRE_LOGICAL);
     }
 
     public void handleMessage(Message message) throws Fault {
@@ -60,13 +58,11 @@
             XMLStreamWriter writer = new W3CDOMStreamWriter(document);
             message.setContent(XMLStreamWriter.class, writer);
            
-            WrappedOutInterceptor wrappedOut = new WrappedOutInterceptor();
-            wrappedOut.setPhase(Phase.PRE_LOGICAL);
+            WrappedOutInterceptor wrappedOut = new WrappedOutInterceptor(Phase.PRE_LOGICAL);
             wrappedOut.addAfter(getId());
             chain.add(wrappedOut);
 
-            XMLMessageOutInterceptor xmlOut = new XMLMessageOutInterceptor();
-            xmlOut.setPhase(Phase.PRE_LOGICAL);
+            XMLMessageOutInterceptor xmlOut = new XMLMessageOutInterceptor(Phase.PRE_LOGICAL);
             xmlOut.addAfter(wrappedOut.getId());
             chain.add(xmlOut);
             

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DispatchInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DispatchInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DispatchInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DispatchInterceptor.java Mon Jun 11 11:54:11 2007
@@ -32,13 +32,13 @@
 import org.apache.cxf.service.model.BindingOperationInfo;
 
 public class DispatchInterceptor extends AbstractPhaseInterceptor<Message> {
+    
     public static final String RELATIVE_PATH = "relative.path";
     private static final Logger LOG = Logger.getLogger(DispatchInterceptor.class.getName());
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(DispatchInterceptor.class);
 
     public DispatchInterceptor() {
-        super();
-        setPhase(Phase.PRE_STREAM);
+        super(Phase.PRE_STREAM);
     }
 
     public void handleMessage(Message message) {

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DocumentWriterInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DocumentWriterInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DocumentWriterInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/DocumentWriterInterceptor.java Mon Jun 11 11:54:11 2007
@@ -30,10 +30,9 @@
 import org.apache.cxf.staxutils.StaxUtils;
 
 public class DocumentWriterInterceptor extends AbstractPhaseInterceptor<Message> {
-
+    
     public DocumentWriterInterceptor() {
-        super();
-        setPhase(Phase.MARSHAL);
+        super(Phase.MARSHAL);
     }
 
     public void handleMessage(Message message) throws Fault {

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java Mon Jun 11 11:54:11 2007
@@ -51,12 +51,12 @@
 
 
 public class URIParameterInInterceptor extends AbstractPhaseInterceptor<Message> {
+    
     private static final Logger LOG = Logger.getLogger(URIParameterInInterceptor.class.getName());
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(URIParameterInInterceptor.class);
 
     public URIParameterInInterceptor() {
-        super();
-        setPhase(Phase.UNMARSHAL);
+        super(Phase.UNMARSHAL);
         addBefore(XMLMessageInInterceptor.class.getName());
     }
 

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterOutInterceptor.java?view=diff&rev=546222&r1=546221&r2=546222
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterOutInterceptor.java Mon Jun 11 11:54:11 2007
@@ -27,6 +27,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -36,10 +37,10 @@
  * Sets up the destination URI for a client invocation.
  */
 public class URIParameterOutInterceptor extends AbstractPhaseInterceptor<Message> {
-
+    
     public URIParameterOutInterceptor() {
-        super();
-        setPhase(Phase.PREPARE_SEND);
+        super(Phase.PREPARE_SEND);
+        addBefore(MessageSenderInterceptor.class.getName());
     }
 
     public void handleMessage(Message message) throws Fault {



Mime
View raw message