You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/05/23 20:43:45 UTC

svn commit: r1485819 - in /cxf/trunk: api/src/main/java/org/apache/cxf/feature/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/

Author: dkulp
Date: Thu May 23 18:43:45 2013
New Revision: 1485819

URL: http://svn.apache.org/r1485819
Log:
Make CXF AbstractFeatures also be WebServiceFeatures and get the jax-ws frontend to recognize that

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsClientEndpointImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java?rev=1485819&r1=1485818&r2=1485819&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java Thu May 23 18:43:45 2013
@@ -20,6 +20,8 @@ package org.apache.cxf.feature;
 
 import java.util.List;
 
+import javax.xml.ws.WebServiceFeature;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
@@ -34,7 +36,11 @@ import org.apache.cxf.interceptor.Interc
  * If you're simply adding interceptors to a Server, Client, or Bus, this allows you to add
  * them easily.
  */
-public abstract class AbstractFeature implements Feature {
+public abstract class AbstractFeature extends WebServiceFeature implements Feature {
+    public String getID() {
+        return getClass().getName();
+    }
+    
     public void initialize(Server server, Bus bus) {
         initializeProvider(server.getEndpoint(), bus);
     }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=1485819&r1=1485818&r2=1485819&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Thu May 23 18:43:45 2013
@@ -213,15 +213,15 @@ public class ServiceImpl extends Service
         portInfos.put(portName, portInfo);
     }
 
-    private WebServiceFeature[] getAllFeatures(WebServiceFeature features[]) {
-        if (serviceFeatures == null || serviceFeatures.length == 0) {
-            return features;
-        } else if (features == null || features.length == 0) {
-            return serviceFeatures;
-        }
-        List<WebServiceFeature> f = new ArrayList<WebServiceFeature>(Arrays.asList(features));
-        f.addAll(Arrays.asList(serviceFeatures));
-        return f.toArray(new WebServiceFeature[f.size()]);
+    private List<WebServiceFeature> getAllFeatures(WebServiceFeature features[]) {
+        List<WebServiceFeature> f = new ArrayList<WebServiceFeature>();
+        if (features != null) {
+            f.addAll(Arrays.asList(features));
+        }
+        if (serviceFeatures != null) {
+            f.addAll(Arrays.asList(serviceFeatures));
+        }
+        return f;
     }
     
     private JaxWsClientEndpointImpl getJaxwsEndpoint(QName portName, AbstractServiceFactoryBean sf, 
@@ -407,11 +407,12 @@ public class ServiceImpl extends Service
         JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
         JaxWsClientFactoryBean clientFac = (JaxWsClientFactoryBean) proxyFac.getClientFactoryBean();
         JaxWsServiceFactoryBean serviceFactory = (JaxWsServiceFactoryBean) proxyFac.getServiceFactory();
+        List<WebServiceFeature> f = getAllFeatures(features);
         proxyFac.initFeatures();
-        WebServiceFeature f[] = getAllFeatures(features);
         if (f != null) {
-            serviceFactory.setWsFeatures(Arrays.asList(f));
+            serviceFactory.setWsFeatures(f);
         }
+
         
         proxyFac.setBus(bus);
         proxyFac.setServiceClass(serviceEndpointInterface);

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsClientEndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsClientEndpointImpl.java?rev=1485819&r1=1485818&r2=1485819&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsClientEndpointImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsClientEndpointImpl.java Thu May 23 18:43:45 2013
@@ -19,7 +19,7 @@
 
 package org.apache.cxf.jaxws.support;
 
-import java.util.Arrays;
+import java.util.List;
 import java.util.concurrent.Executor;
 
 import javax.xml.ws.WebServiceFeature;
@@ -40,9 +40,9 @@ public class JaxWsClientEndpointImpl ext
     private ServiceImpl executorProvider;
     
     public JaxWsClientEndpointImpl(Bus bus, Service s, EndpointInfo ei, ServiceImpl si, 
-                                   WebServiceFeature... wf)
+                                   List<WebServiceFeature> wf)
         throws EndpointException {
-        super(bus, s, ei, Arrays.asList(wf));
+        super(bus, s, ei, wf);
         executorProvider = si;
     }
 

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=1485819&r1=1485818&r2=1485819&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java Thu May 23 18:43:45 2013
@@ -138,12 +138,21 @@ public class JaxWsEndpointImpl extends E
         throws EndpointException {
         super(bus, s, ei);
         this.implInfo = implementorInfo;
-        this.wsFeatures = wf;
+        this.wsFeatures = new ArrayList<WebServiceFeature>();
         if (af != null) {
             features = CastUtils.cast(af);
         } else {
             features = new ArrayList<Feature>();
         }
+        if (wf != null) {
+            for (WebServiceFeature f : wf) {
+                if (f instanceof Feature) {
+                    features.add((Feature)f);
+                } else {
+                    wsFeatures.add(f);
+                }
+            }
+        }
         createJaxwsBinding();
         
         List<Interceptor<? extends Message>> in = super.getInInterceptors();       

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?rev=1485819&r1=1485818&r2=1485819&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java Thu May 23 18:43:45 2013
@@ -41,9 +41,12 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxws.service.AddNumbersException;
@@ -61,6 +64,7 @@ import org.apache.cxf.jaxws.service.Quer
 import org.apache.cxf.jaxws.service.SayHi;
 import org.apache.cxf.jaxws.service.SayHiImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.BindingInfo;
@@ -195,8 +199,6 @@ public class CodeFirstTest extends Abstr
         Hello serviceImpl = new Hello();
         EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
         ep.publish("local://localhost:9090/hello");
-        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
-        ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
         QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
         QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
         
@@ -204,7 +206,15 @@ public class CodeFirstTest extends Abstr
         ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
         service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello"); 
         
-        HelloInterface proxy = service.getPort(portName, HelloInterface.class);
+        HelloInterface proxy = service.getPort(portName, HelloInterface.class, new LoggingFeature());
+        Client client = ClientProxy.getClient(proxy);
+        boolean found = false;
+        for (Interceptor<? extends Message> i : client.getOutInterceptors()) {
+            if (i instanceof LoggingOutInterceptor) {
+                found = true;
+            }
+        }
+        assertTrue(found);
         assertEquals("Get the wrong result", "hello", proxy.sayHi("hello"));
         String[] strInput = new String[2];
         strInput[0] = "Hello";