org.milyn.routing.file
Class FileOutputStreamResource
java.lang.Object
org.milyn.io.AbstractOutputStreamResource
org.milyn.routing.file.FileOutputStreamResource
- All Implemented Interfaces:
- ContentHandler, DOMVisitBefore, DOMVisitor, ExecutionLifecycleCleanable, Consumer, SAXVisitBefore, SAXVisitor, VisitLifecycleCleanable, Visitor
public class FileOutputStreamResource
- extends AbstractOutputStreamResource
FileOutputStreamResouce is a AbstractOutputStreamResource implementation
that handles file output streams.
Example configuration:
<resource-config selector="order-item">
<resource>org.milyn.io.file.FileOutputStreamResource</resource>
<param name="resourceName">resourceName</param>
<param name="fileNamePattern">orderitem-${order.orderId}-${order.orderItem.itemId}.xml</param>
<param name="destinationDirectoryPattern">order-${order.orderId}</param>
<param name="listFileNamePattern">orderitems-${order.orderId}.lst</param>
</resource-config>
Optional properties (default values shown):
<param name="highWaterMark">200</param>
<param name="highWaterMarkTimeout">60000</param>
Description of configuration properties:
- resourceName: the name of this resouce. Will be used to identify this resource.
- fileNamePattern: is the pattern that will be used to generate file names. The file is
created in the destinationDirectory. Supports templating.
- listFileNamePattern: is name of the file that will contain the file names generated by this
configuration. The file is created in the destinationDirectory. Supports templating.
- destinationDirectoryPattern: is the destination directory for files created by this router. Supports templating.
- highWaterMark: max number of output files in the destination directory at any time.
- highWaterMarkTimeout: number of ms to wait for the system to process files in the destination
directory so that the number of files drops below the highWaterMark.
- highWaterMarkPollFrequency: number of ms to wait between checks on the High Water Mark, while
waiting for it to drop.
- closeOnCondition: An MVEL expression. If it returns true then the output stream is closed on the visitAfter event
else it is kept open. If the expression is not set then output stream is closed by default.
- append: Will append to the file specified with the 'fileNamePattern' property. This is useful
for example when you want to append to a single csv file.
When does a new file get created?
As soon as an object tries to retrieve the Writer or the OutputStream from this OutputStreamResource and
the Stream isn't open then a new file is created. Using the 'closeOnCondition' property you can control
when a stream get closed. As long as the stream isn't closed, the same file is used to write too. At then
end of the filter process the stream always gets closed. Nothing stays open.
- Author:
- Daniel Bevenius, maurice.zeijen@smies.com
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileOutputStreamResource
public FileOutputStreamResource()
setFileNamePattern
public FileOutputStreamResource setFileNamePattern(String fileNamePattern)
setDestinationDirectoryPattern
public FileOutputStreamResource setDestinationDirectoryPattern(String destinationDirectoryPattern)
setListFileNamePattern
public FileOutputStreamResource setListFileNamePattern(String listFileNamePattern)
setListFileNamePatternCtxKey
public FileOutputStreamResource setListFileNamePatternCtxKey(String listFileNamePatternCtxKey)
setHighWaterMark
public FileOutputStreamResource setHighWaterMark(int highWaterMark)
setHighWaterMarkTimeout
public FileOutputStreamResource setHighWaterMarkTimeout(long highWaterMarkTimeout)
setHighWaterMarkPollFrequency
public FileOutputStreamResource setHighWaterMarkPollFrequency(long highWaterMarkPollFrequency)
setCloseOnCondition
public void setCloseOnCondition(String closeOnCondition)
setAppend
public FileOutputStreamResource setAppend(boolean append)
intialize
@Initialize
public void intialize()
throws SmooksConfigurationException
- Throws:
SmooksConfigurationException
getOutputStream
public FileOutputStream getOutputStream(ExecutionContext executionContext)
throws SmooksRoutingException,
IOException
- Specified by:
getOutputStream in class AbstractOutputStreamResource
- Throws:
SmooksRoutingException
IOException
closeCondition
protected boolean closeCondition(ExecutionContext executionContext)
- Overrides:
closeCondition in class AbstractOutputStreamResource
closeResource
protected void closeResource(ExecutionContext executionContext)
- Overrides:
closeResource in class AbstractOutputStreamResource
executeExecutionLifecycleCleanup
public void executeExecutionLifecycleCleanup(ExecutionContext executionContext)
- Specified by:
executeExecutionLifecycleCleanup in interface ExecutionLifecycleCleanable- Overrides:
executeExecutionLifecycleCleanup in class AbstractOutputStreamResource
Copyright © 2014. All Rights Reserved.