cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaypai...@apache.org
Subject svn commit: r571248 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ systests/src/test/java/org/apache/cxf/systest/dispatch/
Date Thu, 30 Aug 2007 17:25:59 GMT
Author: ajaypaibir
Date: Thu Aug 30 10:25:59 2007
New Revision: 571248

URL: http://svn.apache.org/viewvc?rev=571248&view=rev
Log:
CXF-937 Fix for applying Features when using the JAX-WS Dispatch api.

Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
  (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=571248&r1=571247&r2=571248&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Thu Aug 30 10:25:59 2007
@@ -56,11 +56,13 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.SoapBinding;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.UpfrontConduitSelector;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.interceptor.MessageSenderInterceptor;
 import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
 import org.apache.cxf.jaxws.handler.soap.DispatchSOAPHandlerInterceptor;
@@ -81,6 +83,7 @@
     private static final Logger LOG = LogUtils.getL7dLogger(DispatchImpl.class);
 
     private Bus bus;
+    private InterceptorProvider iProvider;
 
     private Class<T> cl;
     private Executor executor;
@@ -89,19 +92,20 @@
 
     private ConduitSelector conduitSelector;
     
-    DispatchImpl(Bus b, Service.Mode m, Class<T> clazz, Executor e, Endpoint ep) {
-        this(b, m, null, clazz, e, ep);
-    }
-
-    DispatchImpl(Bus b, Service.Mode m, JAXBContext ctx, Class<T> clazz, Executor e,
Endpoint ep) {
-        super(((JaxWsEndpointImpl)ep).getJaxwsBinding());
+    DispatchImpl(Bus b, Client client, Service.Mode m, JAXBContext ctx, Class<T> clazz,
Executor e) {
+        super(((JaxWsEndpointImpl)client.getEndpoint()).getJaxwsBinding());
         bus = b;
+        this.iProvider = client;
         executor = e;
         context = ctx;
         cl = clazz;
         mode = m;
-        getConduitSelector().setEndpoint(ep);
-        setupEndpointAddressContext(ep);
+        getConduitSelector().setEndpoint(client.getEndpoint());
+        setupEndpointAddressContext(client.getEndpoint());
+    }
+    
+    DispatchImpl(Bus b, Client cl, Service.Mode m, Class<T> clazz, Executor e) {
+        this(b, cl, m, null, clazz, e);
     }
 
     private void setupEndpointAddressContext(Endpoint endpoint) {
@@ -237,6 +241,11 @@
             LOG.fine("Interceptors contributed by bus: " + il);
         }
         chain.add(il);
+        List<Interceptor> i2 = iProvider.getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by client: " + i2);
+        }
+        chain.add(i2);
         
         if (endpoint instanceof JaxWsEndpointImpl) {
             Binding jaxwsBinding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
@@ -269,6 +278,11 @@
             LOG.fine("Interceptors contributed by bus: " + il);
         }
         chain.add(il);
+        List<Interceptor> i2 = iProvider.getInInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by client: " + i2);
+        }
+        chain.add(i2);
 
         if (endpoint instanceof JaxWsEndpointImpl) {
             Binding jaxwsBinding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
@@ -380,5 +394,4 @@
             exchange.put(Message.WSDL_DESCRIPTION, wsdlDescription);
         }      
     }
-
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=571248&r1=571247&r2=571248&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Thu Aug 30 10:25:59 2007
@@ -50,8 +50,11 @@
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
 import org.apache.cxf.jaxws.handler.HandlerResolverImpl;
@@ -182,6 +185,11 @@
     }
 
     public <T> Dispatch<T> createDispatch(QName portName, Class<T> type,
Mode mode) {
+        JaxWsClientFactoryBean clientFac = new JaxWsClientFactoryBean();
+
+        //Initialize Features.
+        configureObject(portName.toString() + ".jaxws-client.proxyFactory", clientFac);
+
         AbstractServiceFactoryBean sf = null;
         try {
             sf = createDispatchService(new SourceDataBinding());
@@ -189,14 +197,23 @@
             throw new WebServiceException(e);
         }
         Endpoint endpoint = getJaxwsEndpoint(portName, sf);
-        Dispatch<T> disp = new DispatchImpl<T>(bus, mode, type, getExecutor(),
endpoint);
-
+        Client client = new ClientImpl(getBus(), endpoint, clientFac.getConduitSelector());
+        for (AbstractFeature af : clientFac.getFeatures()) {
+            af.initialize(client, bus);
+        }
+        
+        Dispatch<T> disp = new DispatchImpl<T>(bus, client, mode, type, getExecutor());
         configureObject(disp);
 
         return disp;
     }
 
     public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode
mode) {
+        JaxWsClientFactoryBean clientFac = new JaxWsClientFactoryBean();
+        
+        //Initialize Features.
+        configureObject(portName.toString() + ".jaxws-client.proxyFactory", clientFac);
+
         AbstractServiceFactoryBean sf = null;
         try {
             sf = createDispatchService(new JAXBDataBinding(context));
@@ -204,9 +221,12 @@
             throw new WebServiceException(e);
         }
         Endpoint endpoint = getJaxwsEndpoint(portName, sf);
-        Dispatch<Object> disp = new DispatchImpl<Object>(bus, mode, context,
Object.class, getExecutor(),
-                                                         endpoint);
-
+        Client client = new ClientImpl(getBus(), endpoint, clientFac.getConduitSelector());
+        for (AbstractFeature af : clientFac.getFeatures()) {
+            af.initialize(client, bus);
+        }
+        Dispatch<Object> disp = new DispatchImpl<Object>(bus, client, mode, 
+                                                         context, Object.class, getExecutor());
         configureObject(disp);
 
         return disp;

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=571248&r1=571247&r2=571248&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Thu Aug 30 10:25:59 2007
@@ -142,7 +142,6 @@
 
     }
     
-  
     @Test
     public void testDOMSourceMESSAGE() throws Exception {
         /*URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
@@ -206,7 +205,7 @@
         assertEquals("Response should be : Hello TestSOAPInputMessage3", expected3, 
                      tdsh.getReplyBuffer().trim());
     }
-
+    
     @Test
     public void testDOMSourcePAYLOAD() throws Exception {
         /*URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
@@ -310,6 +309,43 @@
         assertTrue("Expected string, " + expected, expected.equals(responseValue3));
     }
 
+    @Test
+    public void testJAXBObjectPAYLOADWithFeature() throws Exception {
+        createBus("org/apache/cxf/systest/dispatch/client-config.xml");
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        assertNotNull(wsdl);
+
+        String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
+        String endpointUrl = "http://localhost:9006/SOAPDispatchService/SoapDispatchPort";
+        
+        Service service = Service.create(wsdl, serviceName);
+        service.addPort(portName, bindingId, endpointUrl);
+        assertNotNull(service);
+        
+        JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
+        Dispatch<Object> disp = service.createDispatch(portName, jc, Service.Mode.PAYLOAD);
+
+        String expected = "Hello Jeeves";
+        GreetMe greetMe = new GreetMe();
+        greetMe.setRequestType("Jeeves");
+
+        Object response = disp.invoke(greetMe);
+        assertNotNull(response);
+        String responseValue = ((GreetMeResponse)response).getResponseType();
+        assertTrue("Expected string, " + expected, expected.equals(responseValue));
+        
+        assertEquals("Feature should be applied", 1, TestDispatchFeature.getCount());
+        assertEquals("Feature based interceptors should be added", 
+                     1, TestDispatchFeature.getCount());
+        
+        assertEquals("Feature based In interceptors has be added to in chain.", 
+                     1, TestDispatchFeature.getInInterceptorCount());
+
+        assertEquals("Feature based interceptors has to be added to out chain.", 
+                     1, TestDispatchFeature.getOutInterceptorCount());
+
+    }
+    
     @Test
     public void testSAXSourceMESSAGE() throws Exception {
 

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java?rev=571248&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
Thu Aug 30 10:25:59 2007
@@ -0,0 +1,78 @@
+/**
+ * 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.systest.dispatch;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+
+public class TestDispatchFeature extends AbstractFeature {
+    private static final TestInInterceptor IN = new TestInInterceptor();
+    private static final TestOutInterceptor OUT = new TestOutInterceptor();
+    private static int count;
+    
+    TestDispatchFeature() {
+        ++count;
+    }
+    
+    public static int getCount() {
+        return count;
+    }
+
+    public static int getInInterceptorCount() {
+        return TestInInterceptor.count;
+    }
+
+    public static int getOutInterceptorCount() {
+        return TestOutInterceptor.count;
+    }
+
+    @Override
+    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
+        provider.getInInterceptors().add(IN);
+        provider.getOutInterceptors().add(OUT);
+    }
+
+    static class TestInInterceptor extends AbstractPhaseInterceptor<Message> {
+        private static int count;
+        public TestInInterceptor() {
+            super(Phase.RECEIVE);
+        }
+        public void handleMessage(Message message) throws Fault {
+            ++count;
+        }
+    }
+
+    static class TestOutInterceptor extends AbstractPhaseInterceptor<Message> {
+        private static int count;
+        public TestOutInterceptor() {
+            super(Phase.SEND);
+        }
+        public void handleMessage(Message message) throws Fault {
+            ++count;            
+        }
+    }
+}
+

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/TestDispatchFeature.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml?rev=571248&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
Thu Aug 30 10:25:59 2007
@@ -0,0 +1,13 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:jaxws="http://cxf.apache.org/jaxws"
+       xsi:schemaLocation="
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+     <jaxws:client name="{http://apache.org/hello_world_soap_http}SoapDispatchPort" createdFromAPI="true">
+         <jaxws:features>
+             <bean class="org.apache.cxf.systest.dispatch.TestDispatchFeature"/>
+         </jaxws:features>
+    </jaxws:client>
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/client-config.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message