org.apache.servicemix.components.util
Class BinaryFileMarshaler

java.lang.Object
  extended by org.apache.servicemix.components.util.MarshalerSupport
      extended by org.apache.servicemix.components.util.DefaultFileMarshaler
          extended by org.apache.servicemix.components.util.BinaryFileMarshaler
All Implemented Interfaces:
FileMarshaler

public class BinaryFileMarshaler
extends DefaultFileMarshaler

A FileMarshaler that converts the given input stream into a binary attachment.

Since:
3.0
Author:
Guillaume Nodet

Field Summary
 
Fields inherited from class org.apache.servicemix.components.util.DefaultFileMarshaler
FILE_CONTENT, FILE_CONTENT_EXPRESSION, FILE_NAME_EXPRESSION, FILE_NAME_PROPERTY, FILE_PATH_PROPERTY, TEMP_FILE_NAME_EXPRESSION, TEMP_FILE_NAME_PROPERTY
 
Constructor Summary
BinaryFileMarshaler()
           
 
Method Summary
protected static void copyInputStream(java.io.InputStream in, java.io.OutputStream out)
          Copy in stream to an out stream
 java.lang.String getAttachment()
          returns the key used to add the attachment to the message
 java.lang.String getContentType()
          returns the content type to use / expect
 void readMessage(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message, java.io.InputStream in, java.lang.String path)
          Converts the file stream to a normalized message.
 void setAttachment(java.lang.String attachment)
          sets the key of the attachment to use for adding a attachment to the normalized message
 void setContentType(java.lang.String contentType)
          sets the content type to use / expect
 void writeMessage(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message, java.io.OutputStream out, java.lang.String path)
          Writes the inbound message to the destination stream of the given name
 
Methods inherited from class org.apache.servicemix.components.util.DefaultFileMarshaler
getContent, getEncoding, getFileName, getOutputName, getTempOutputName, setContent, setEncoding, setFileName, writeMessageContent, writeValue
 
Methods inherited from class org.apache.servicemix.components.util.MarshalerSupport
asString, getTransformer, setTransformer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryFileMarshaler

public BinaryFileMarshaler()
Method Detail

getAttachment

public java.lang.String getAttachment()
returns the key used to add the attachment to the message

Returns:
the attachments name / key

setAttachment

public void setAttachment(java.lang.String attachment)
sets the key of the attachment to use for adding a attachment to the normalized message

Parameters:
attachment - the new key to use

getContentType

public java.lang.String getContentType()
returns the content type to use / expect

Returns:
the content type

setContentType

public void setContentType(java.lang.String contentType)
sets the content type to use / expect

Parameters:
contentType - the new content type

readMessage

public void readMessage(javax.jbi.messaging.MessageExchange exchange,
                        javax.jbi.messaging.NormalizedMessage message,
                        java.io.InputStream in,
                        java.lang.String path)
                 throws java.io.IOException,
                        javax.jbi.JBIException
Description copied from interface: FileMarshaler
Converts the file stream to a normalized message.

Specified by:
readMessage in interface FileMarshaler
Overrides:
readMessage in class DefaultFileMarshaler
Parameters:
exchange - the message exchange
message - the message to populate
in - the input stream
path - the name of the file, URI or URL
Throws:
java.io.IOException
javax.jbi.JBIException

writeMessage

public void writeMessage(javax.jbi.messaging.MessageExchange exchange,
                         javax.jbi.messaging.NormalizedMessage message,
                         java.io.OutputStream out,
                         java.lang.String path)
                  throws java.io.IOException,
                         javax.jbi.JBIException
Description copied from interface: FileMarshaler
Writes the inbound message to the destination stream of the given name

Specified by:
writeMessage in interface FileMarshaler
Overrides:
writeMessage in class DefaultFileMarshaler
Parameters:
exchange - the inbound message exchange
message - the inbound message
out - the output stream to write to
Throws:
java.io.IOException
javax.jbi.JBIException

copyInputStream

protected static void copyInputStream(java.io.InputStream in,
                                      java.io.OutputStream out)
                               throws java.io.IOException
Copy in stream to an out stream

Parameters:
in -
out -
Throws:
java.io.IOException


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.