You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/11/13 08:02:14 UTC

svn commit: r713668 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se: ./ src/main/java/org/apache/servicemix/cxfse/ src/test/java/org/apache/servicemix/cxfse/ src/test/resources/org/apache/servicemix/cxfse/

Author: ffang
Date: Wed Nov 12 23:02:14 2008
New Revision: 713668

URL: http://svn.apache.org/viewvc?rev=713668&view=rev
Log:
[SM-1591|SM-1595]support aegis databinding and simple front end in cxf se

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/pom.xml
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/pom.xml?rev=713668&r1=713667&r2=713668&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/pom.xml Wed Nov 12 23:02:14 2008
@@ -160,6 +160,11 @@
             <version>${junit-version}</version>
             <scope>test</scope>
         </dependency>
+            <dependency>
+                <groupId>org.apache.cxf</groupId>
+                <artifactId>cxf-rt-databinding-aegis</artifactId>
+                <version>${cxf-version}</version>
+            </dependency>
 
 	</dependencies>
 	<build>

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java?rev=713668&r1=713667&r2=713668&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java Wed Nov 12 23:02:14 2008
@@ -35,6 +35,9 @@
 import javax.xml.ws.WebServiceRef;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorProvider;
@@ -72,6 +75,8 @@
     private EndpointImpl endpoint;
 
     private String address;
+    
+    private ServerFactoryBean sf;
 
     private List<Interceptor> in = new CopyOnWriteArrayList<Interceptor>();
 
@@ -82,6 +87,8 @@
     private List<Interceptor> inFault = new CopyOnWriteArrayList<Interceptor>();
 
     private Map properties;
+    
+    private Server server;
 
     private boolean mtomEnabled;
 
@@ -89,6 +96,8 @@
 
     private boolean useSOAPEnvelope = true;
 
+    private boolean useAegis;
+    
     /**
      * Returns the object implementing the endpoint's functionality. It is
      * returned as a generic Java <code>Object</code> that can be cast to the
@@ -225,27 +234,59 @@
         if (getPojo() == null) {
             throw new DeploymentException("pojo must be set");
         }
-        JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
-        serviceFactory.setPopulateFromClass(true);
-        endpoint = new EndpointImpl(getBus(), getPojo(),
+        if (isUseAegis()) {
+            sf = new ServerFactoryBean();
+            sf.setServiceBean(getPojo());
+            sf.setAddress("jbi://" + ID_GENERATOR.generateSanitizedId());
+            sf.getServiceFactory().setDataBinding(new AegisDatabinding());
+            sf.getServiceFactory().setPopulateFromClass(true);
+            sf.setStart(false);
+            if (isUseJBIWrapper()) {
+                sf.setBindingId(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
+            }
+            server = sf.create();
+            server.getEndpoint().getInInterceptors().addAll(getInInterceptors());
+            server.getEndpoint().getInFaultInterceptors().addAll(getInFaultInterceptors());
+            server.getEndpoint().getOutInterceptors().addAll(getOutInterceptors());
+            server.getEndpoint().getOutFaultInterceptors().addAll(getOutFaultInterceptors());
+            if (isMtomEnabled()) {
+                server.getEndpoint().getInInterceptors().add(new AttachmentInInterceptor());
+                server.getEndpoint().getOutInterceptors().add(new AttachmentOutInterceptor());
+            }
+            if (sf.getServiceFactory().getServiceQName() != null) {
+                setService(sf.getServiceFactory().getServiceQName());
+            }
+            if (sf.getServiceFactory().getEndpointInfo().getName() != null) {
+                setEndpoint(sf.getServiceFactory().getEndpointInfo().getName().getLocalPart());
+            }
+            if (sf.getServiceFactory().getInterfaceName() != null) {
+                setInterfaceName(sf.getServiceFactory().getInterfaceName());
+            }
+        } else {
+            JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+            serviceFactory.setPopulateFromClass(true);
+            endpoint = new EndpointImpl(getBus(), getPojo(),
                 new JaxWsServerFactoryBean(serviceFactory));
-        if (isUseJBIWrapper()) {
-            endpoint
+            if (isUseJBIWrapper()) {
+                endpoint
                     .setBindingUri(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
-        }
-        endpoint.setInInterceptors(getInInterceptors());
-        endpoint.setInFaultInterceptors(getInFaultInterceptors());
-        endpoint.setOutInterceptors(getOutInterceptors());
-        endpoint.setOutFaultInterceptors(getOutFaultInterceptors());
-        if (isMtomEnabled()) {
-            endpoint.getInInterceptors().add(new AttachmentInInterceptor());
-            endpoint.getOutInterceptors().add(new AttachmentOutInterceptor());
-        }
-        JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getPojo()
+            }   
+            endpoint.setInInterceptors(getInInterceptors());
+            endpoint.setInFaultInterceptors(getInFaultInterceptors());
+            endpoint.setOutInterceptors(getOutInterceptors());
+            endpoint.setOutFaultInterceptors(getOutFaultInterceptors());
+            if (isMtomEnabled()) {
+                endpoint.getInInterceptors().add(new AttachmentInInterceptor());
+                endpoint.getOutInterceptors().add(new AttachmentOutInterceptor());
+            }
+            JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getPojo()
                 .getClass());
-        setService(implInfo.getServiceName());
-        setInterfaceName(implInfo.getInterfaceName());
-        setEndpoint(implInfo.getEndpointName().getLocalPart());
+            setService(implInfo.getServiceName());
+            
+            setInterfaceName(implInfo.getInterfaceName());
+            setEndpoint(implInfo.getEndpointName().getLocalPart());
+            
+        }
         super.validate();
     }
 
@@ -267,7 +308,8 @@
     public void process(MessageExchange exchange) throws Exception {
 
         QName opeName = exchange.getOperation();
-        EndpointInfo ei = endpoint.getServer().getEndpoint().getEndpointInfo();
+        EndpointInfo ei = server.getEndpoint().getEndpointInfo();
+               
         if (opeName == null) {
             // if interface only have one operation, may not specify the opeName
             // in MessageExchange
@@ -281,7 +323,6 @@
 
             }
         }
-
         JBITransportFactory jbiTransportFactory = (JBITransportFactory) getBus()
                 .getExtension(ConduitInitiatorManager.class)
                 .getConduitInitiator(CxfSeComponent.JBI_TRANSPORT_ID);
@@ -319,29 +360,34 @@
         super.start();
         address = "jbi://" + ID_GENERATOR.generateSanitizedId();
         try {
-            endpoint.publish(address);
+            if (isUseAegis()) {
+                server.start();
+            } else {
+                endpoint.publish(address);
+                server = endpoint.getServer();
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }
 
-        setService(endpoint.getServer().getEndpoint().getService().getName());
-        setEndpoint(endpoint.getServer().getEndpoint().getEndpointInfo()
+        setService(server.getEndpoint().getService().getName());
+        setEndpoint(server.getEndpoint().getEndpointInfo()
                 .getName().getLocalPart());
         if (!isUseJBIWrapper() && !isUseSOAPEnvelope()) {
-            removeInterceptor(endpoint.getServer().getEndpoint().getBinding()
+            removeInterceptor(server.getEndpoint().getBinding()
                     .getInInterceptors(), "ReadHeadersInterceptor");
-            removeInterceptor(endpoint.getServer().getEndpoint().getBinding()
+            removeInterceptor(server.getEndpoint().getBinding()
                     .getInFaultInterceptors(), "ReadHeadersInterceptor");
-            removeInterceptor(endpoint.getServer().getEndpoint().getBinding()
+            removeInterceptor(server.getEndpoint().getBinding()
                     .getOutInterceptors(), "SoapOutInterceptor");
-            removeInterceptor(endpoint.getServer().getEndpoint().getBinding()
+            removeInterceptor(server.getEndpoint().getBinding()
                     .getOutFaultInterceptors(), "SoapOutInterceptor");
-            removeInterceptor(endpoint.getServer().getEndpoint().getBinding()
+            removeInterceptor(server.getEndpoint().getBinding()
                     .getOutInterceptors(), "StaxOutInterceptor");
         }
 
         try {
-            definition = new ServiceWSDLBuilder(getBus(), endpoint.getServer()
+            definition = new ServiceWSDLBuilder(getBus(), server
                     .getEndpoint().getService().getServiceInfos().iterator()
                     .next()).build();
             description = WSDLFactory.newInstance().newWSDLWriter()
@@ -375,7 +421,11 @@
      */
     @Override
     public void stop() throws Exception {
-        endpoint.stop();
+        if (isUseAegis()) {
+            server.stop();
+        } else {
+            endpoint.stop();
+        }
         ReflectionUtils.callLifecycleMethod(getPojo(), PreDestroy.class);
         JBIDispatcherUtil.clean();
         JBITransportFactory jbiTransportFactory = (JBITransportFactory) getBus()
@@ -462,4 +512,19 @@
         return useSOAPEnvelope;
     }
 
+    /**
+     * Specifies if the endpoint use aegis databinding to marshell/unmarshell message
+     * 
+     * @org.apache.xbean.Property description="Specifies if the endpoint use aegis databinding to marshell/unmarshell message. 
+     * The default is <code>false</code>.
+     */
+    public void setUseAegis(boolean useAegis) {
+        this.useAegis = useAegis;
+    }
+
+    
+    public boolean isUseAegis() {
+        return useAegis;
+    }
+
 }

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java?rev=713668&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java Wed Nov 12 23:02:14 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.servicemix.cxfse;
+
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CxfSeAegisTest extends SpringTestSupport {
+
+    private DefaultServiceMixClient client;
+    private InOut io;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        client = new DefaultServiceMixClient(jbi);
+        
+    }
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
+    public void testAegis() throws Exception {
+        io = client.createInOutExchange();
+        io.setService(new QName("http://authservice.cxf.apache.org/", "AuthServiceImpl"));
+        io.setOperation(new QName("http://authservice.cxf.apache.org/", "authenticate"));
+        io.getInMessage().setContent(new StringSource(
+                  "<message xmlns=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\">"
+                + "  <part>"
+                + "<ns1:authenticate xmlns:ns1=\"http://authservice.cxf.apache.org/\">" 
+                + "<ns1:arg0><ns2:pwd xmlns:ns2=\"http://authservice.cxf.apache.org\" " 
+                + "xmlns:ns3=\"http://www.w3.org/2001/XMLSchema-instance\" ns3:nil=\"true\" />" 
+                + "<ns2:sid xmlns:ns2=\"http://authservice.cxf.apache.org\">ffang</ns2:sid>" 
+                + "<ns2:uid xmlns:ns2=\"http://authservice.cxf.apache.org\">ffang</ns2:uid></ns1:arg0>" 
+                +  "</ns1:authenticate>"
+                + "  </part>"
+                + "</message>"));
+        client.sendSync(io);
+             
+        assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("type=\"msg:authenticateResponse\"") >= 0);
+        client.done(io);
+    }
+    
+    @Override
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/cxfse/aegis.xml");
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeAegisTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java?rev=713668&r1=713667&r2=713668&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java Wed Nov 12 23:02:14 2008
@@ -129,7 +129,7 @@
         client.sendSync(io);
         assertTrue(new SourceTransformer().contentToString(
                 io.getOutMessage()).indexOf("Hello ffang 3") > 0);
-        
+        client.done(io);
     }
     
     protected void tearDown() throws Exception {

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java?rev=713668&r1=713667&r2=713668&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java Wed Nov 12 23:02:14 2008
@@ -62,6 +62,7 @@
                 io.getOutMessage()).indexOf("type=\"msg:addResponse\"") >= 0);
         assertTrue(new SourceTransformer().contentToString(
                 io.getOutMessage()).indexOf("xmlns:msg=\"http://apache.org/cxf/calculator\"") >= 0);
+        client.done(io);
     }
 
     public void testCalculatorWithoutInterfaceName() throws Exception {
@@ -84,6 +85,7 @@
                 io.getOutMessage()).indexOf("type=\"msg:addResponse\"") >= 0);
         assertTrue(new SourceTransformer().contentToString(
                 io.getOutMessage()).indexOf("xmlns:msg=\"http://apache.org/cxf/calculator\"") >= 0);
+        client.done(io);
     }
 
     

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml?rev=713668&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml Wed Nov 12 23:02:14 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  
+  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.
+  
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+       xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
+       xmlns:test="urn:test">
+  
+  <sm:container id="jbi" embedded="true">
+    
+    <sm:endpoints>
+      <cxfse:endpoint useAegis="true">
+        <cxfse:pojo>
+          <bean class="org.apache.cxf.authservice.AuthServiceImpl">
+          </bean>
+              
+        </cxfse:pojo>
+        <cxfse:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inInterceptors>
+        <cxfse:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outInterceptors>
+        <cxfse:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inFaultInterceptors>
+        <cxfse:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outFaultInterceptors>
+      </cxfse:endpoint>
+    </sm:endpoints>
+    
+  </sm:container>
+  
+</beans>

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/aegis.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml