org.apache.servicemix.components.util
Class DefaultFileMarshaler

java.lang.Object
  extended by org.apache.servicemix.components.util.MarshalerSupport
      extended by org.apache.servicemix.components.util.DefaultFileMarshaler
All Implemented Interfaces:
FileMarshaler
Direct Known Subclasses:
BinaryFileMarshaler, SimpleFlatFileMarshaler

public class DefaultFileMarshaler
extends MarshalerSupport
implements FileMarshaler

A default file transformer which assumes the file is already in XML format and requires no transformation other than to be wrapped in a normalized message..

Version:
$Revision: 673769 $

Field Summary
static java.lang.String FILE_CONTENT
           
protected static PropertyExpression FILE_CONTENT_EXPRESSION
           
protected static PropertyExpression FILE_NAME_EXPRESSION
           
static java.lang.String FILE_NAME_PROPERTY
           
static java.lang.String FILE_PATH_PROPERTY
           
protected static PropertyExpression TEMP_FILE_NAME_EXPRESSION
           
static java.lang.String TEMP_FILE_NAME_PROPERTY
           
 
Constructor Summary
DefaultFileMarshaler()
           
 
Method Summary
 Expression getContent()
           
 java.lang.String getEncoding()
           
 Expression getFileName()
           
 java.lang.String getOutputName(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message)
          Creates a output file name for the given exchange when reading an inbound message.
 java.lang.String getTempOutputName(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message)
          creates a temporary file name for the given exchange when reading an inbound message.
 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 setContent(Expression content)
           
 void setEncoding(java.lang.String encoding)
           
 void setFileName(Expression fileName)
           
 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
protected  void writeMessageContent(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message, java.io.OutputStream out, java.lang.String path)
          Writes the message content to the given output stream
protected  void writeValue(java.lang.Object value, java.io.OutputStream out)
          Writes the given value to the output stream
 
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
 

Field Detail

FILE_NAME_PROPERTY

public static final java.lang.String FILE_NAME_PROPERTY
See Also:
Constant Field Values

TEMP_FILE_NAME_PROPERTY

public static final java.lang.String TEMP_FILE_NAME_PROPERTY
See Also:
Constant Field Values

FILE_PATH_PROPERTY

public static final java.lang.String FILE_PATH_PROPERTY
See Also:
Constant Field Values

FILE_CONTENT

public static final java.lang.String FILE_CONTENT
See Also:
Constant Field Values

FILE_NAME_EXPRESSION

protected static final PropertyExpression FILE_NAME_EXPRESSION

TEMP_FILE_NAME_EXPRESSION

protected static final PropertyExpression TEMP_FILE_NAME_EXPRESSION

FILE_CONTENT_EXPRESSION

protected static final PropertyExpression FILE_CONTENT_EXPRESSION
Constructor Detail

DefaultFileMarshaler

public DefaultFileMarshaler()
Method Detail

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
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

getOutputName

public java.lang.String getOutputName(javax.jbi.messaging.MessageExchange exchange,
                                      javax.jbi.messaging.NormalizedMessage message)
                               throws javax.jbi.messaging.MessagingException
Description copied from interface: FileMarshaler
Creates a output file name for the given exchange when reading an inbound message.

Specified by:
getOutputName in interface FileMarshaler
Parameters:
exchange - the inbound message exchange
message - the inbound message
Returns:
the file name or null if a file name could not be found or calculated
Throws:
javax.jbi.messaging.MessagingException

getTempOutputName

public java.lang.String getTempOutputName(javax.jbi.messaging.MessageExchange exchange,
                                          javax.jbi.messaging.NormalizedMessage message)
                                   throws javax.jbi.messaging.MessagingException
Description copied from interface: FileMarshaler
creates a temporary file name for the given exchange when reading an inbound message. This name is a (hopefully) unique name used for doing a first writing. It will be renamed to the real output name after successfully finished transmission.

Specified by:
getTempOutputName in interface FileMarshaler
Parameters:
exchange - the inbound message exchange
message - the inbound message
Returns:
the file name or null if a file name could not be found or calculated
Throws:
javax.jbi.messaging.MessagingException

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
Parameters:
exchange - the inbound message exchange
message - the inbound message
out - the output stream to write to
Throws:
java.io.IOException
javax.jbi.JBIException

getContent

public Expression getContent()

setContent

public void setContent(Expression content)

getFileName

public Expression getFileName()

setFileName

public void setFileName(Expression fileName)

setEncoding

public void setEncoding(java.lang.String encoding)

getEncoding

public java.lang.String getEncoding()

writeValue

protected void writeValue(java.lang.Object value,
                          java.io.OutputStream out)
                   throws java.io.IOException,
                          javax.jbi.messaging.MessagingException
Writes the given value to the output stream

Parameters:
value - the value to be written to the stream
out - the output stream
Throws:
java.io.IOException
javax.jbi.messaging.MessagingException

writeMessageContent

protected void writeMessageContent(javax.jbi.messaging.MessageExchange exchange,
                                   javax.jbi.messaging.NormalizedMessage message,
                                   java.io.OutputStream out,
                                   java.lang.String path)
                            throws javax.jbi.messaging.MessagingException
Writes the message content to the given output stream

Parameters:
message - the message who's content we are about to write
out - the destination of the output
path - the name of the output resource (file, uri, url)
Throws:
javax.jbi.messaging.MessagingException


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