Hi,

I have just checked an extension for the attachment handling into the master 
(2.18) branch. As long as you don't use attachments you will very likely not 
notice any difference.

If you have created an implementation of the Message interface that does not 
extend DefaultMessage, you will need to provide additional methods (there is no 
such message implementation in the standard camel source tree).

Implementation Details:

A new org.apache.camel.Attachment interface and 
org.apache.camel.impl.DefaultAttachment implementation were added that can 
store headers for the attachment (in addition to the DataHandler).

The org.apache.camel.Message interface and org.apache.camel.impl.DefaultMessage 
were extended by four new methods (getAttachmentObject(), 
setAttachmentObject(), getAttachmentObjects(), and setAttachmentObjects()). 
These complenent the still existing getAttachment(), setAttachment(), 
getAttachments() and setAttachments() objects but operate on the new Attachment 
instead of the DataHandler entities.

The camel-cxf, camel-jetty9, and camel-mail components were extended to support 
attachment headers, camel-scala (and the camel-core) have methods to access 
them. I did not add the support for attachment headers to camel-spring-ws 
because that implementation does not support headers in attachments.

The change is supposed to be compatible and not to break any old scenarios (so 
please inform me, if you find something it breaks).

Note: a commonly used construct 
out.getAttachments().putAll(exchange.getIn().getAttachments()); will continue 
to work, but drop all attachment headers, so it is better to use 
out.getAttachmentObjects().putAll(exchange.getIn().getAttachmentObjects()); 
instead.
out.setAttachments(in.getAttachments()) will work as well as 
out.setAttachmentObjects(in.getAttachmentObjects()) on DefaultMessage objects.

The getAttachments() method will now return a special HashMap<String, 
DataHandler> that is backed by the HashMap<String, Attachment> that is returned 
by the getAttachmentObjects() method. As a consequence you can transparently 
add and remove objects in either of these maps (and the change is reflected in 
the other one).

If you have further questions, please address to me.

Best regards
Stephan


Reply via email to