servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r602000 - in /servicemix/branches/servicemix-4.0/camel/src: main/java/org/apache/servicemix/camel/ main/java/org/apache/servicemix/camel/spring/ test/java/org/apache/servicemix/camel/ test/resources/org/apache/servicemix/camel/spring/
Date Fri, 07 Dec 2007 06:08:50 GMT
Author: ffang
Date: Thu Dec  6 22:08:47 2007
New Revision: 602000

URL: http://svn.apache.org/viewvc?rev=602000&view=rev
Log:
[SM-1129] attachment support

Added:
    servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
  (with props)
    servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
  (with props)
    servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
  (with props)
Modified:
    servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
    servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixProducer.java
    servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
    servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java

Modified: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java?rev=602000&r1=601999&r2=602000&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
(original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixEndpoint.java
Thu Dec  6 22:08:47 2007
@@ -37,7 +37,7 @@
  * 
  * @org.apache.xbean.XBean element="smxEndpoint"
  */
-public class ServiceMixEndpoint extends DefaultEndpoint {
+public class ServiceMixEndpoint extends DefaultEndpoint<ServiceMixExchange> {
 
 	public static final String SPRING_CONTEXT_ENDPOINT = "bean:";
 
@@ -97,11 +97,11 @@
 		return true;
 	}
 
-	public Producer createProducer() throws Exception {
+	public Producer<ServiceMixExchange> createProducer() throws Exception {
 		return new ServiceMixProducer(this);
 	}
 
-	public Consumer createConsumer(Processor processor) throws Exception {
+	public Consumer<ServiceMixExchange> createConsumer(Processor processor) throws Exception
{
 		return new ServiceMixConsumer(this, processor);
 	}
 

Modified: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixProducer.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixProducer.java?rev=602000&r1=601999&r2=602000&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixProducer.java
(original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/ServiceMixProducer.java
Thu Dec  6 22:08:47 2007
@@ -59,8 +59,7 @@
         e.getIn().setBody(exchange.getIn().getBody());
         e.getIn().setHeader(CxfConstants.OPERATION_NAME, 
         		exchange.getIn().getHeader(CxfConstants.OPERATION_NAME));
-        
-        
+                
         client.sendSync(e);
         if (e.getPattern() != Pattern.InOnly) {
         	if (e.getFault().getBody() != null) {

Modified: servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java?rev=602000&r1=601999&r2=602000&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
(original)
+++ servicemix/branches/servicemix-4.0/camel/src/main/java/org/apache/servicemix/camel/spring/ServiceMixEndpointBean.java
Thu Dec  6 22:08:47 2007
@@ -25,19 +25,7 @@
 	private NMR nmr;
 	private Flow flow;
 	
-	public ServiceMixEndpointBean() {
-		if (getNmr() != null && getNmr().getFlowRegistry() != null) {
-			if (getFlow() != null) {
-				// set Flow we get from configuration file
-				getNmr().getFlowRegistry().register(getFlow(), 
-						ServiceHelper.createMap(Flow.ID, getFlow().getClass().getName()));
-			} else {
-				// set defaule Flow
-				getNmr().getFlowRegistry().register(
-						new StraightThroughFlow(), ServiceHelper.createMap(Flow.ID, StraightThroughFlow.class.getName()));
-			}
-		}
-	}
+
 	public void setNmr(NMR nmr) {
 		this.nmr = nmr;
 	}

Added: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java?rev=602000&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
(added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
Thu Dec  6 22:08:47 2007
@@ -0,0 +1,167 @@
+/*
+ * 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.camel;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.activation.DataHandler;
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.jaxws.JaxWsClientProxy;
+import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AttachmentTest extends ContextTestSupport {
+    
+	protected static final String SERVICE_ADDRESS = "local://smx/attachment";
+	protected static final String ROUTER_ADDRESS = "http://localhost:9036/mime-test";
+	
+	protected static final String SERVICE_CLASS = "serviceClass=org.apache.cxf.mime.TestMtom";
+     
+    
+    
+	
+	public static final QName MTOM_PORT = new QName(
+            "http://cxf.apache.org/mime", "TestMtomPort");
+
+    public static final QName MTOM_SERVICE = new QName(
+            "http://cxf.apache.org/mime", "TestMtomService");
+	
+	protected AbstractXmlApplicationContext applicationContext;
+	
+    
+           
+    
+    @Override
+    protected void setUp() throws Exception {
+        applicationContext = createApplicationContext();
+        super.setUp();        
+        assertNotNull("Should have created a valid spring context", applicationContext);
+
+        startService();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {        
+        if (applicationContext != null) {
+            applicationContext.destroy();
+        }
+        super.tearDown();
+    }
+    
+    protected void startService() {
+        //start a service
+    	Object implementor = new MtomImpl();
+        
+    	javax.xml.ws.Endpoint.publish(SERVICE_ADDRESS, implementor);
+    }
+    
+   
+  
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+            	from("cxf:bean:routerEndpoint").to("smx:bean:testEndpoint");
+            	from("smx:bean:testEndpoint").to("cxf:bean:serviceEndpoint");
+            }
+        };
+    }
+    
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        return SpringCamelContext.springCamelContext(applicationContext);
+    }
+    
+    
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/mtom.xml");
+    }
+
+    
+    public void testAttachment() throws Exception {  
+    	TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class,
+                true);
+        try {
+            
+            Holder<DataHandler> param = new Holder<DataHandler>();
+            
+            param.value = new DataHandler(new ByteArrayDataSource("foobar".getBytes(), 
+                "application/octet-stream"));
+            
+            Holder<String> name = new Holder<String>("call detail");
+            mtomPort.testXop(name, param);
+            assertEquals("call detailfoobar",
+                    name.value);
+            assertNotNull(param.value);
+            InputStream bis = param.value.getDataSource().getInputStream();
+            byte b[] = new byte[10];
+            bis.read(b, 0, 10);
+            String attachContent = new String(b);
+            assertEquals(attachContent, "testfoobar");
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception) ex.getCause();
+        }        
+                
+    }
+    
+    private <T> T createPort(QName serviceName, QName portName,
+            Class<T> serviceEndpointInterface, boolean enableMTOM)
+        throws Exception {
+        Bus bus = BusFactory.getDefaultBus();
+        ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+        serviceFactory.setBus(bus);
+        serviceFactory.setServiceName(serviceName);
+        serviceFactory.setServiceClass(serviceEndpointInterface);
+        serviceFactory.setWsdlURL(getClass().getResource("/wsdl/mtom_xop.wsdl"));
+        Service service = serviceFactory.create();
+        EndpointInfo ei = service.getEndpointInfo(portName);
+        JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service,
+                ei);
+        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
+        jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
+
+        Client client = new ClientImpl(bus, jaxwsEndpoint);
+        InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint
+                .getJaxwsBinding());
+        Object obj = Proxy.newProxyInstance(serviceEndpointInterface
+                .getClassLoader(), new Class[] {serviceEndpointInterface,
+                    BindingProvider.class}, ih);
+        return serviceEndpointInterface.cast(obj);
+    }
+}

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/AttachmentTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java?rev=602000&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
(added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
Thu Dec  6 22:08:47 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.camel;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.ws.Holder;
+
+@WebService(serviceName = "TestMtomService", 
+        portName = "TestMtomPort", 
+        targetNamespace = "http://cxf.apache.org/mime", 
+        endpointInterface = "org.apache.cxf.mime.TestMtom",
+            wsdlLocation = "testutils/mtom_xop.wsdl")
+public class MtomImpl {
+    public void testXop(Holder<String> name, Holder<DataHandler> attachinfo)
{
+        
+        try {
+            InputStream bis = attachinfo.value.getDataSource().getInputStream();
+            byte b[] = new byte[6];
+            bis.read(b, 0, 6);
+            String attachContent = new String(b);
+            name.value = name.value + attachContent;
+            
+            ByteArrayDataSource source = 
+                new ByteArrayDataSource(("test" + attachContent).getBytes(), "application/octet-stream");
+            attachinfo.value = new DataHandler(source);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        
+    }
+
+
+}
+

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/MtomImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java?rev=602000&r1=601999&r2=602000&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java
(original)
+++ servicemix/branches/servicemix-4.0/camel/src/test/java/org/apache/servicemix/camel/SmxToCxfTest.java
Thu Dec  6 22:08:47 2007
@@ -18,8 +18,6 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.cxf.Bus;
@@ -107,10 +105,5 @@
     }
     
         
-    class PojoInvokeDispatchProcessor implements Processor {
-        public void process(Exchange exchange) throws Exception {
-            System.out.println("PojoInvokeDispatchProcessor " + exchange.getIn().getBody());
-            
-        }
-    }
+    
 }

Added: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml?rev=602000&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
(added)
+++ servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
Thu Dec  6 22:08:47 2007
@@ -0,0 +1,51 @@
+<?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="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"      
+       xmlns:smx="http://servicemix.apache.org/camelEndpoint/"
+       xmlns:mtom="http://cxf.apache.org/mime"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
+       http://servicemix.apache.org/camelEndpoint/ http://servicemix.apache.org/camelEndpoint/.xsd
+    ">
+
+  
+  <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9036/mime-test" 
+    serviceClass="org.apache.cxf.mime.TestMtom" wsdlURL="/wsdl/mtom_xop.wsdl" serviceName="mtom:TestMtomService"/>
+  
+    
+  <cxf:cxfEndpoint id="serviceEndpoint" address="local://smx/attachment" 
+    serviceClass="org.apache.cxf.mime.TestMtom" wsdlURL="/wsdl/mtom_xop.wsdl" serviceName="mtom:TestMtomService"
+    transportId="http://cxf.apache.org/transports/local"/>
+
+  <smx:smxEndpoint id="testEndpoint" nmr="#servicemix" flow="#staightThroughFlow"/>
+  
+  <bean id="servicemix" class="org.apache.servicemix.nmr.core.ServiceMix">
+        <property name="endpointRegistry" ref="endpointRegistry" />
+        <property name="listenerRegistry" ref="listenerRegistry" />
+        <property name="flowRegistry" ref="flowRegistry" />
+  </bean>
+  <bean id="endpointRegistry" class="org.apache.servicemix.nmr.core.EndpointRegistryImpl">
+        <property name="nmr" ref="servicemix" />
+  </bean>  
+  <bean id="listenerRegistry" class="org.apache.servicemix.nmr.core.ListenerRegistryImpl"
/>
+  <bean id="flowRegistry" class="org.apache.servicemix.nmr.core.FlowRegistryImpl" />
+  <bean id="staightThroughFlow" class="org.apache.servicemix.nmr.core.StraightThroughFlow"
/>
+</beans>

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/branches/servicemix-4.0/camel/src/test/resources/org/apache/servicemix/camel/spring/mtom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message