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

svn commit: r563073 - in /incubator/servicemix/trunk/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: gnodet
Date: Mon Aug  6 02:00:13 2007
New Revision: 563073

URL: http://svn.apache.org/viewvc?view=rev&rev=563073
Log:
Apply patch from Freeman

Modified:
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/pom.xml
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/spring.xml

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/pom.xml?view=diff&rev=563073&r1=563072&r2=563073
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/pom.xml (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/pom.xml Mon Aug  6 02:00:13 2007
@@ -30,8 +30,12 @@
 	<groupId>org.apache.servicemix</groupId>
 	<artifactId>servicemix-cxf-se</artifactId>
 	<packaging>jbi-component</packaging>
-
-	<name>ServiceMix :: CXF Service Engine</name>
+  	<name>ServiceMix :: CXF Service Engine</name>
+    <description>A CXF Service Engine</description>     
+ 
+    <properties>
+	    <cxf-version>2.1-incubator-SNAPSHOT</cxf-version>
+    </properties>
 
 	<dependencies>
 
@@ -64,6 +68,11 @@
 			<artifactId>spring-aop</artifactId>
 			<version>${spring-version}</version>
 		</dependency>
+                <dependency>
+                        <groupId>org.springframework</groupId>
+                        <artifactId>spring-jmx</artifactId>
+                        <version>${spring-version}</version>
+                </dependency>
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-context</artifactId>
@@ -96,7 +105,6 @@
 			<groupId>org.apache.cxf</groupId>
 			<artifactId>cxf-testutils</artifactId>
 			<version>${cxf-version}</version>
-			<scope>test</scope>
 		</dependency>
 	</dependencies>
 	<build>

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java?view=diff&rev=563073&r1=563072&r2=563073
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java Mon Aug  6 02:00:13 2007
@@ -29,6 +29,8 @@
  */
 public class CxfSeComponent extends DefaultComponent {
 
+    public static final String JBI_TRANSPORT_ID = "http://cxf.apache.org/transports/jbi";
+    
     private CxfSeEndpoint[] endpoints;
     private Bus bus;
     

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java?view=diff&rev=563073&r1=563072&r2=563073
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java Mon Aug  6 02:00:13 2007
@@ -36,7 +36,9 @@
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.jbi.JBIDestination;
 import org.apache.cxf.transport.jbi.JBITransportFactory;
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
@@ -50,19 +52,26 @@
  * @author gnodet
  * @org.apache.xbean.XBean element="endpoint"
  */
-public class CxfSeEndpoint extends ProviderEndpoint implements InterceptorProvider {
+public class CxfSeEndpoint extends ProviderEndpoint implements
+        InterceptorProvider {
 
     private static final IdGenerator ID_GENERATOR = new IdGenerator();
-    
+
     private Object pojo;
+
     private EndpointImpl endpoint;
+
     private String address;
-    
+
+
     private List<Interceptor> in = new CopyOnWriteArrayList<Interceptor>();
+
     private List<Interceptor> out = new CopyOnWriteArrayList<Interceptor>();
-    private List<Interceptor> outFault  = new CopyOnWriteArrayList<Interceptor>();
-    private List<Interceptor> inFault  = new CopyOnWriteArrayList<Interceptor>();
-    
+
+    private List<Interceptor> outFault = new CopyOnWriteArrayList<Interceptor>();
+
+    private List<Interceptor> inFault = new CopyOnWriteArrayList<Interceptor>();
+
     /**
      * @return the pojo
      */
@@ -71,7 +80,8 @@
     }
 
     /**
-     * @param pojo the pojo to set
+     * @param pojo
+     *            the pojo to set
      */
     public void setPojo(Object pojo) {
         this.pojo = pojo;
@@ -108,8 +118,10 @@
     public void setOutFaultInterceptors(List<Interceptor> interceptors) {
         outFault = interceptors;
     }
-    
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.servicemix.common.Endpoint#validate()
      */
     @Override
@@ -119,53 +131,77 @@
         }
         JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
         serviceFactory.setPopulateFromClass(true);
-        endpoint = new EndpointImpl(getBus(), getPojo(), new JaxWsServerFactoryBean(serviceFactory));
-        endpoint.setBindingUri(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
+        endpoint = new EndpointImpl(getBus(), getPojo(),
+                new JaxWsServerFactoryBean(serviceFactory));
+        endpoint
+                .setBindingUri(org.apache.cxf.binding.jbi.JBIConstants.NS_JBI_BINDING);
         endpoint.setInInterceptors(getInInterceptors());
         endpoint.setInFaultInterceptors(getInFaultInterceptors());
         endpoint.setOutInterceptors(getOutInterceptors());
         endpoint.setOutFaultInterceptors(getOutFaultInterceptors());
-        address = "jbi://" + ID_GENERATOR.generateSanitizedId();
-        endpoint.publish(address);
-        setService(endpoint.getServer().getEndpoint().getService().getName());
-        setEndpoint(endpoint.getServer().getEndpoint().getEndpointInfo().getName().getLocalPart());
-        try {
-            definition = new ServiceWSDLBuilder(getBus(), endpoint.getServer().getEndpoint().getService()
-                        .getServiceInfos().iterator().next()).build();
-        } catch (WSDLException e) {
-            throw new DeploymentException(e);
-        }
+        JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getPojo()
+                .getClass());
+        setService(implInfo.getServiceName());
+        setInterfaceName(implInfo.getInterfaceName());
+        setEndpoint(implInfo.getEndpointName().getLocalPart());
         super.validate();
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#process(javax.jbi.messaging.MessageExchange)
      */
     @Override
     public void process(MessageExchange exchange) throws Exception {
-        DeliveryChannel oldDc = JBITransportFactory.getDeliveryChannel();
+        JBITransportFactory jbiTransportFactory =
+            (JBITransportFactory)getBus().getExtension(ConduitInitiatorManager.class).
+                    getConduitInitiator(CxfSeComponent.JBI_TRANSPORT_ID);
+        JBIDestination jbiDestination = jbiTransportFactory.getDestination(exchange.getService().toString()
+                           + exchange.getInterfaceName().toString());
+        DeliveryChannel oldDc = jbiDestination.getDeliveryChannel();
         try {
-            JBITransportFactory.setDeliveryChannel(getContext().getDeliveryChannel());
+            jbiDestination.setDeliveryChannel(getContext()
+                    .getDeliveryChannel());
+         
             if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
-                ((JBIDestination) endpoint.getServer().getDestination()).dispatch(exchange);
+                jbiDestination.getJBIDispatcherUtil().dispatch(exchange);
             }
         } finally {
-            JBITransportFactory.setDeliveryChannel(oldDc);
+            jbiDestination.setDeliveryChannel(oldDc);
         }
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#start()
      */
     @Override
     public void start() throws Exception {
         super.start();
+        address = "jbi://" + ID_GENERATOR.generateSanitizedId();
+        endpoint.publish(address);
+        setService(endpoint.getServer().getEndpoint().getService()
+                .getName());
+        setEndpoint(endpoint.getServer().getEndpoint()
+                .getEndpointInfo().getName().getLocalPart());
+        try {
+            definition = new ServiceWSDLBuilder(getBus(), endpoint
+                    .getServer().getEndpoint().getService()
+                    .getServiceInfos().iterator().next()).build();
+        } catch (WSDLException e) {
+            throw new DeploymentException(e);
+        }
         ReflectionUtils.doWithFields(getPojo().getClass(), new FieldCallback() {
-            public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
+            public void doWith(Field field) throws IllegalArgumentException,
+                    IllegalAccessException {
                 if (field.getAnnotation(WebServiceRef.class) != null) {
-                    ServiceImpl s = new ServiceImpl(getBus(), null, null, field.getType());
-                    s.addPort(new QName("port"), JBITransportFactory.TRANSPORT_ID, 
-                              "jbi://" + ID_GENERATOR.generateSanitizedId());
+                    ServiceImpl s = new ServiceImpl(getBus(), null, null, field
+                            .getType());
+                    s.addPort(new QName("port"),
+                            JBITransportFactory.TRANSPORT_ID, "jbi://"
+                                    + ID_GENERATOR.generateSanitizedId());
                     Object o = s.getPort(new QName("port"), field.getType());
                     field.setAccessible(true);
                     field.set(getPojo(), o);
@@ -175,7 +211,9 @@
         ReflectionUtils.callLifecycleMethod(getPojo(), PostConstruct.class);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.servicemix.common.endpoints.ProviderEndpoint#stop()
      */
     @Override
@@ -185,7 +223,7 @@
     }
 
     protected Bus getBus() {
-        return ((CxfSeComponent) getServiceUnit().getComponent()).getBus(); 
+        return ((CxfSeComponent) getServiceUnit().getComponent()).getBus();
     }
-    
+
 }

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java?view=diff&rev=563073&r1=563072&r2=563073
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeSpringTest.java Mon Aug  6 02:00:13 2007
@@ -28,11 +28,23 @@
 
 public class CxfSeSpringTest extends SpringTestSupport {
 
-    public void testCalculator() throws Exception {
-        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
-        InOut io = client.createInOutExchange();
+    private DefaultServiceMixClient client;
+    private InOut io;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
         io.setService(new QName("http://apache.org/cxf/calculator", "CalculatorService"));
+        io.setInterfaceName(new QName("http://apache.org/cxf/calculator", "CalculatorPortType"));
         io.setOperation(new QName("http://apache.org/cxf/calculator", "add"));
+    }
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
+    public void testCalculator() throws Exception {
         io.getInMessage().setContent(new StringSource(
                   "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
                 + "  <part>"
@@ -46,23 +58,7 @@
         System.err.println(new SourceTransformer().contentToString(io.getOutMessage()));
     }
     
-    public void testCalculatorWithFault() throws Exception {
-        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
-        InOut io = client.createInOutExchange();
-        io.setService(new QName("http://apache.org/cxf/calculator", "CalculatorService"));
-        io.setOperation(new QName("http://apache.org/cxf/calculator", "add"));
-        io.getInMessage().setContent(new StringSource(
-                  "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
-                + "  <part>"
-                + "    <add xmlns='http://apache.org/cxf/calculator/types'>"
-                + "      <arg0>-1</arg0>"
-                + "      <arg1>2</arg1>"
-                + "    </add>"
-                + "  </part>"
-                + "</message>"));
-        client.sendSync(io);
-        System.err.println(new SourceTransformer().contentToString(io.getFault()));
-    }
+    
     
     @Override
     protected AbstractXmlApplicationContext createBeanFactory() {

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/spring.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/spring.xml?view=diff&rev=563073&r1=563072&r2=563073
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/spring.xml (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/resources/org/apache/servicemix/cxfse/spring.xml Mon Aug  6 02:00:13 2007
@@ -28,6 +28,18 @@
         <cxfse:pojo>
           <bean class="org.apache.cxf.calculator.CalculatorImpl" />
         </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>