cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r507904 - in /incubator/cxf/trunk/rt/core/src: main/java/org/apache/cxf/phase/PhaseManagerImpl.java main/resources/META-INF/cxf/cxf.xml test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Date Thu, 15 Feb 2007 11:45:43 GMT
Author: andreasmyth
Date: Thu Feb 15 03:45:43 2007
New Revision: 507904

URL: http://svn.apache.org/viewvc?view=rev&rev=507904
Log:
Made phases configurable.

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java?view=diff&rev=507904&r1=507903&r2=507904
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java Thu
Feb 15 03:45:43 2007
@@ -22,32 +22,25 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
+import org.apache.cxf.extension.BusExtension;
 
-import org.apache.cxf.Bus;
-
-public class PhaseManagerImpl implements PhaseManager {
+public class PhaseManagerImpl implements PhaseManager, BusExtension {
  
-    private Bus bus;
     private  List<Phase> inPhases;
     private  List<Phase> outPhases;
-    
+   
     public PhaseManagerImpl() {
         createInPhases();
         createOutPhases();
-    } 
-    
-    @Resource
-    public void setBus(Bus b) {
-        bus = b;
     }
-    
-    @PostConstruct
-    public void register() {
-        if (null != bus) {
-            bus.setExtension(this, PhaseManager.class);
-        }
+
+    public PhaseManagerImpl(List<Phase> in, List<Phase> out) {
+        inPhases = in;
+        outPhases = out;
+    }
+
+    public Class getRegistrationType() {
+        return PhaseManager.class;
     }
 
     public List<Phase> getInPhases() {
@@ -59,11 +52,8 @@
     }
 
     final void createInPhases() {
+
         inPhases = new ArrayList<Phase>(); 
-        
-        // TODO: get from configuration instead
-        // bus.getConfiguration();
-        
         int i = 0;
         
         inPhases = new ArrayList<Phase>();
@@ -82,13 +72,9 @@
         inPhases.add(new Phase(Phase.PRE_INVOKE, ++i * 1000));
         inPhases.add(new Phase(Phase.INVOKE, ++i * 1000));
         inPhases.add(new Phase(Phase.POST_INVOKE, ++i * 1000));
-        // Collections.sort(inPhases);
     }
     
     final void createOutPhases() {
-        outPhases = new ArrayList<Phase>();
-        
-        // TODO: get from configuration instead
         
         outPhases = new ArrayList<Phase>();
         int i = 0;
@@ -115,7 +101,6 @@
         
         outPhases.add(new Phase(Phase.SEND, ++i * 1000));
         
-        // Collections.sort(outPhases);
     }
 
 }

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?view=diff&rev=507904&r1=507903&r2=507904
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Thu Feb 15 03:45:43
2007
@@ -73,7 +73,130 @@
     </bean>
     
     <bean id="org.apache.cxf.phase.PhaseManager" class="org.apache.cxf.phase.PhaseManagerImpl">
-        <property name="bus" ref="cxf"/>
+        <constructor-arg>
+            <list>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="receive"/>
+                    <property name="priority" value="1000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-stream"/>
+                    <property name="priority" value="2000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-stream"/>
+                    <property name="priority" value="3000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-stream"/>
+                    <property name="priority" value="4000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="read"/>
+                    <property name="priority" value="5000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-protocol"/>
+                    <property name="priority" value="6000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-protocol"/>
+                    <property name="priority" value="7000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-protocol"/>
+                    <property name="priority" value="8000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="unmarshal"/>
+                    <property name="priority" value="9000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-logical"/>
+                    <property name="priority" value="10000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-logical"/>
+                    <property name="priority" value="11000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-logical"/>
+                    <property name="priority" value="12000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-invoke"/>
+                    <property name="priority" value="13000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="invoke"/>
+                    <property name="priority" value="14000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-invoke"/>
+                    <property name="priority" value="15000"/>
+                </bean>
+            </list>
+        </constructor-arg>
+        <constructor-arg>
+            <list>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="setup"/>
+                    <property name="priority" value="1000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-logical"/>
+                    <property name="priority" value="2000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-logical"/>
+                    <property name="priority" value="3000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-logical"/>
+                    <property name="priority" value="4000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="prepare-send"/>
+                    <property name="priority" value="5000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-stream"/>
+                    <property name="priority" value="6000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="pre-protocol"/>
+                    <property name="priority" value="7000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-protocol"/>
+                    <property name="priority" value="8000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-protocol"/>
+                    <property name="priority" value="9000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="write"/>
+                    <property name="priority" value="10000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="marshal"/>
+                    <property name="priority" value="11000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="user-stream"/>
+                    <property name="priority" value="12000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="post-stream"/>
+                    <property name="priority" value="13000"/>
+                </bean>
+                <bean class="org.apache.cxf.phase.Phase">
+                    <property name="name" value="send"/>
+                    <property name="priority" value="14000"/>
+                </bean>
+            </list>
+        </constructor-arg>
     </bean>
     
     <bean id="org.apache.cxf.workqueue.WorkQueueManager" class="org.apache.cxf.workqueue.WorkQueueManagerImpl">

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?view=diff&rev=507904&r1=507903&r2=507904
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Thu Feb 15 03:45:43 2007
@@ -34,7 +34,9 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.phase.PhaseManagerImpl;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.DestinationFactoryManager;
@@ -70,7 +72,7 @@
         assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
         assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
         assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
-        
+
     }
     
     public void testCustomFileName() {
@@ -124,6 +126,24 @@
         bus.shutdown(true);
         EasyMock.verify(bl);
         
+    }
+
+    public void testPhases() {
+        Bus bus = new SpringBusFactory().createBus();
+        PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
+        PhaseManager defaultPM = new PhaseManagerImpl();
+        List<Phase> cxfPhases = cxfPM.getInPhases();
+        List<Phase> defaultPhases = defaultPM.getInPhases();
+        assertEquals(defaultPhases.size(), cxfPhases.size());
+        for (int i = 0; i < cxfPhases.size(); i++) {
+            assertEquals(0, cxfPhases.get(i).compareTo(defaultPhases.get(i)));
+        }
+        cxfPhases = cxfPM.getOutPhases();
+        defaultPhases = defaultPM.getOutPhases();
+        assertEquals(defaultPhases.size(), cxfPhases.size());
+        for (int i = 0; i < cxfPhases.size(); i++) {
+            assertEquals(0, cxfPhases.get(i).compareTo(defaultPhases.get(i)));
+        }
     }
     
     static class TestInterceptor implements Interceptor {



Mime
View raw message