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 2007/10/18 07:18:48 UTC
svn commit: r585869 - in /incubator/servicemix/trunk/deployables:
bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/
bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/
bindingcomponen...
Author: ffang
Date: Wed Oct 17 22:18:45 2007
New Revision: 585869
URL: http://svn.apache.org/viewvc?rev=585869&view=rev
Log:
[SM-1109] attachment should be supported in cxf se and bc
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java (with props)
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=585869&r1=585868&r2=585869&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Wed Oct 17 22:18:45 2007
@@ -16,12 +16,15 @@
*/
package org.apache.servicemix.cxfbc;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import javax.activation.DataHandler;
import javax.jbi.component.ComponentContext;
import javax.jbi.management.DeploymentException;
import javax.jbi.messaging.ExchangeStatus;
@@ -30,10 +33,12 @@
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import com.ibm.wsdl.Constants;
import org.apache.cxf.Bus;
+import org.apache.cxf.attachment.AttachmentImpl;
import org.apache.cxf.binding.AbstractBindingFactory;
import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
@@ -53,6 +58,7 @@
import org.apache.cxf.interceptor.OutgoingChainInterceptor;
import org.apache.cxf.interceptor.StaxInInterceptor;
import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageContentsList;
@@ -73,7 +79,9 @@
import org.apache.servicemix.cxfbc.interceptors.JbiInWsdl1Interceptor;
import org.apache.servicemix.cxfbc.interceptors.JbiOperationInterceptor;
import org.apache.servicemix.cxfbc.interceptors.JbiOutWsdl1Interceptor;
+import org.apache.servicemix.cxfbc.interceptors.MtomCheckInterceptor;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.messaging.NormalizedMessageImpl;
import org.apache.servicemix.soap.util.DomUtil;
import org.springframework.core.io.Resource;
@@ -112,6 +120,8 @@
private BindingFaultInfo faultWanted;
private Bus bus;
+
+ private boolean mtomEnabled;
/**
* @return the wsdl
@@ -234,6 +244,8 @@
}
ei.getBinding().setProperty(
AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
+
+
cxfService.getInInterceptors().add(
new ReadHeadersInterceptor(getBus()));
cxfService.getInInterceptors().add(new MustUnderstandInterceptor());
@@ -250,6 +262,7 @@
cxfService.getOutInterceptors().add(new JbiOutWsdl1Interceptor());
cxfService.getOutInterceptors().add(new SoapActionOutInterceptor());
cxfService.getOutInterceptors().add(new AttachmentOutInterceptor());
+ cxfService.getOutInterceptors().add(new MtomCheckInterceptor(isMtomEnabled()));
cxfService.getOutInterceptors().add(new StaxOutInterceptor());
cxfService.getOutInterceptors().add(
new SoapPreProtocolOutInterceptor());
@@ -404,6 +417,7 @@
CxfBcConsumer.this.isOneway = message.getExchange().get(
BindingOperationInfo.class).getOperationInfo().isOneWay();
message.getExchange().setOneWay(CxfBcConsumer.this.isOneway);
+
try {
if (CxfBcConsumer.this.synchronous
@@ -454,8 +468,19 @@
outMessage = endpoint.getBinding().createMessage();
ex.setOutMessage(outMessage);
}
+ NormalizedMessageImpl norMessage =
+ (NormalizedMessageImpl) exchange.getMessage("out");
+ List<Attachment> attachmentList = new ArrayList<Attachment>();
outMessage.setContent(Source.class, exchange.getMessage(
"out").getContent());
+ Iterator<String> iter = norMessage.listAttachments();
+ while (iter.hasNext()) {
+ String id = iter.next();
+ DataHandler dh = norMessage.getAttachment(id);
+ attachmentList.add(new AttachmentImpl(id, dh));
+ }
+
+ message.setAttachments(attachmentList);
}
}
@@ -505,6 +530,14 @@
public String getBusCfg() {
return busCfg;
+ }
+
+ public void setMtomEnabled(boolean mtomEnabled) {
+ this.mtomEnabled = mtomEnabled;
+ }
+
+ public boolean isMtomEnabled() {
+ return mtomEnabled;
}
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=585869&r1=585868&r2=585869&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Wed Oct 17 22:18:45 2007
@@ -104,6 +104,8 @@
private Conduit conduit;
+ private boolean mtomEnabled;
+
public void processExchange(MessageExchange exchange) {
}
@@ -240,6 +242,7 @@
}
ei.getBinding().setProperty(
AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
+
if (locationURI == null) {
// if not specify target address, get it from the wsdl
locationURI = new URI(ei.getAddress());
@@ -319,6 +322,14 @@
EndpointInfo getEndpointInfo() {
return this.ei;
+ }
+
+ public void setMtomEnabled(boolean mtomEnabled) {
+ this.mtomEnabled = mtomEnabled;
+ }
+
+ public boolean isMtomEnabled() {
+ return mtomEnabled;
}
}
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java?rev=585869&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java Wed Oct 17 22:18:45 2007
@@ -0,0 +1,40 @@
+/*
+ * 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.cxfbc.interceptors;
+
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class MtomCheckInterceptor extends AbstractPhaseInterceptor<Message> {
+
+ private boolean mtomEnabled;
+ public MtomCheckInterceptor(boolean mtom) {
+ super(Phase.PRE_STREAM);
+ addBefore(AttachmentOutInterceptor.class.getName());
+ this.mtomEnabled = mtom;
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ message.put(org.apache.cxf.message.Message.MTOM_ENABLED, mtomEnabled);
+ message.put("write.attachments", mtomEnabled);
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/MtomCheckInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java?rev=585869&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java Wed Oct 17 22:18:45 2007
@@ -0,0 +1,112 @@
+/*
+ * 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.cxfbc.mtom;
+
+
+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.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.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CxfBCMtomTest extends SpringTestSupport {
+
+ 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");
+
+ public void testMtom() 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();
+ }
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext(
+ "org/apache/servicemix/cxfbc/mtom/xbean.xml");
+ }
+
+ 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: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/CxfBCMtomTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java?rev=585869&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java Wed Oct 17 22:18:45 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.cxfbc.mtom;
+
+
+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 TestMtomImpl {
+ 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: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/mtom/TestMtomImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml?rev=585869&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml Wed Oct 17 22:18:45 2007
@@ -0,0 +1,68 @@
+<?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:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+ xmlns:mtom="http://cxf.apache.org/mime">
+
+ <sm:container id="jbi" embedded="true">
+
+ <sm:endpoints>
+ <cxfse:endpoint mtomEnabled="true">
+ <cxfse:pojo>
+ <bean class="org.apache.servicemix.cxfbc.mtom.TestMtomImpl" />
+ </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>
+ <cxfbc:consumer wsdl="/wsdl/mtom_xop.wsdl"
+ targetEndpoint="TestMtomPort"
+ targetService="mtom:TestMtomService"
+ targetInterface="mtom:TestMtom"
+ mtomEnabled="true"
+ >
+ <cxfbc:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inInterceptors>
+ <cxfbc:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outInterceptors>
+ <cxfbc:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inFaultInterceptors>
+ <cxfbc:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outFaultInterceptors>
+ </cxfbc:consumer>
+ </sm:endpoints>
+
+ </sm:container>
+
+</beans>
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom/xbean.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
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?rev=585869&r1=585868&r2=585869&view=diff
==============================================================================
--- 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 Wed Oct 17 22:18:45 2007
@@ -47,6 +47,7 @@
import org.apache.cxf.transport.jbi.JBITransportFactory;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
import org.apache.servicemix.common.endpoints.ProviderEndpoint;
+import org.apache.servicemix.cxfse.interceptors.AttachmentInInterceptor;
import org.apache.servicemix.cxfse.support.ReflectionUtils;
import org.apache.servicemix.id.IdGenerator;
import org.springframework.util.ReflectionUtils.FieldCallback;
@@ -76,7 +77,10 @@
private List<Interceptor> inFault = new CopyOnWriteArrayList<Interceptor>();
private Map properties;
-
+
+ private boolean mtomEnabled;
+
+
/**
* @return the pojo
*/
@@ -152,6 +156,9 @@
endpoint.setInFaultInterceptors(getInFaultInterceptors());
endpoint.setOutInterceptors(getOutInterceptors());
endpoint.setOutFaultInterceptors(getOutFaultInterceptors());
+ if (isMtomEnabled()) {
+ endpoint.getInInterceptors().add(new AttachmentInInterceptor());
+ }
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getPojo()
.getClass());
setService(implInfo.getServiceName());
@@ -179,6 +186,7 @@
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
jbiDestination.getJBIDispatcherUtil().dispatch(exchange);
}
+
}
/*
@@ -250,5 +258,13 @@
logger.debug("Unable to inject ComponentContext: " + e.getMessage());
}
+ }
+
+ public void setMtomEnabled(boolean mtomEnabled) {
+ this.mtomEnabled = mtomEnabled;
+ }
+
+ public boolean isMtomEnabled() {
+ return mtomEnabled;
}
}
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java?rev=585869&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java Wed Oct 17 22:18:45 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.interceptors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.activation.DataHandler;
+import javax.jbi.messaging.MessageExchange;
+
+import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.servicemix.jbi.messaging.NormalizedMessageImpl;
+
+public class AttachmentInInterceptor extends AbstractPhaseInterceptor<Message> {
+ private static final Logger LOG = LogUtils.getL7dLogger(AttachmentInInterceptor.class);
+
+
+ public AttachmentInInterceptor() {
+ super(Phase.RECEIVE);
+ }
+
+ public void handleMessage(Message message) {
+ List<Attachment> attachmentList = new ArrayList<Attachment>();
+ MessageExchange exchange = message.get(MessageExchange.class);
+ NormalizedMessageImpl norMessage =
+ (NormalizedMessageImpl) exchange.getMessage("in");
+ Iterator<String> iter = norMessage.listAttachments();
+ while (iter.hasNext()) {
+ String id = iter.next();
+ DataHandler dh = norMessage.getAttachment(id);
+ attachmentList.add(new AttachmentImpl(id, dh));
+ }
+
+ LOG.info("the attachment size is " + attachmentList.size());
+ message.setAttachments(attachmentList);
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/interceptors/AttachmentInInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date