org.jboss.soa.esb.actions.routing
Class ObjectToFileWriter

java.lang.Object
  extended by org.jboss.soa.esb.actions.routing.ObjectToFileWriter
All Implemented Interfaces:
ActionProcessor

public class ObjectToFileWriter
extends java.lang.Object
implements ActionProcessor

Object to file writing processor.

Writes an Object to a file based on the "file" property specified by the action configuration. This "file" property can specify a file or directory. If the file is a directory, the class generates a file name based on the return from a call to UUID.randomUUID() and the file extension value specified in the "ext" property (default of "obj").

If the message is a byte array it's writen to the file as is, otherwise the toString method is called on the message object and the resulting String bytes are writen to the file based on the "encoding" specified in the action configuration (see below).

Sample Action Configuration:

 <Action name="Write-To-X-File" processor="ObjectToFileWriter">
     <property name="file" value="file:///..." /> <!-- File/Directory name. Supports URI or non-URI based names. -->
     <property name="append" value="true/false" /> <!-- Only relevant if the file is not a directory. Default of "false". -->
     <property name="ext" value="dat" /> <!-- Only relevant if the file is a directory. Default of "obj". -->
     <property name="encoding" value="UTF-8" /> <!-- Default of "UTF-8". -->
 </Action>
 

Since:
Version 4.0
Author:
tom.fennelly@jboss.com

Field Summary
static java.lang.String FILE_APPEND
           
static java.lang.String FILE_ENC
           
static java.lang.String FILE_EXT
           
static java.lang.String FILE_NAME
           
 
Constructor Summary
ObjectToFileWriter(java.lang.String actionName, java.util.List<KeyValuePair> properties)
          Public constructor.
 
Method Summary
 java.io.Serializable getErrorNotification(Message message)
          Get the "Error" notification message for this processor.
 java.io.Serializable getOkNotification(Message message)
          Get the "OK" notification message for this processor.
 Message process(Message message)
          Perform the processing action on the message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_NAME

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

FILE_APPEND

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

FILE_EXT

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

FILE_ENC

public static final java.lang.String FILE_ENC
See Also:
Constant Field Values
Constructor Detail

ObjectToFileWriter

public ObjectToFileWriter(java.lang.String actionName,
                          java.util.List<KeyValuePair> properties)
                   throws ConfigurationException
Public constructor.

Parameters:
actionName - Action name.
properties - Action Properties.
Throws:
ConfigurationException - Action not properly configured.
Method Detail

process

public Message process(Message message)
                throws ActionProcessingException
Description copied from interface: ActionProcessor
Perform the processing action on the message

Specified by:
process in interface ActionProcessor
Parameters:
message - The message to be processed.
Returns:
Message - result of process
Throws:
ActionProcessingException - Exception during payload processing.

getOkNotification

public java.io.Serializable getOkNotification(Message message)
Description copied from interface: ActionProcessor
Get the "OK" notification message for this processor.

Specified by:
getOkNotification in interface ActionProcessor
Parameters:
message - The message Object.
Returns:
The OK message.

getErrorNotification

public java.io.Serializable getErrorNotification(Message message)
Description copied from interface: ActionProcessor
Get the "Error" notification message for this processor.

Specified by:
getErrorNotification in interface ActionProcessor
Parameters:
message - The message Object.
Returns:
The Error message.