|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.contrib.filewriter.FileWriterCallback
public class FileWriterCallback
FileWriterCallback stores messages to the file system.
Field Summary | |
---|---|
private static int |
BUF_SIZE
|
private java.io.File |
directory
|
private java.lang.String |
dirName
|
private boolean |
keepDumpFiles
if true it cleans up the chunks after processing, otherwise it leaves them. |
private java.lang.String |
lockExtention
|
private static java.util.logging.Logger |
log
|
private boolean |
overwrite
|
private java.io.File |
tmpDirectory
|
private java.lang.String |
tmpDirName
|
Fields inherited from interface org.xmlBlaster.contrib.ContribConstants |
---|
FILE_DATE, FILENAME_ATTR, FILENAME_ATTR_OLD_FASHION, SUBDIR_ATTR, TIMESTAMP_ATTR, TOPIC_NAME |
Constructor Summary | |
---|---|
FileWriterCallback(java.lang.String dirName,
java.lang.String tmpDirName,
java.lang.String lockExtention,
boolean overwrite,
boolean keepDumpFiles)
Creates a callback |
Method Summary | |
---|---|
private static boolean |
deleteFile(java.io.File file)
Deletes the specified file from the file system. |
private long |
extractNumberPostfixFromFile(java.lang.String filename,
java.lang.String prefix)
Returns the number used as the postfix of this file. |
private java.io.File[] |
getChunkFilenames(java.lang.String fileName,
char sep)
The filename prefix for which to retrieve all chunks. |
private void |
putAllChunksTogether(java.lang.String fileName,
java.lang.String subDir,
long expectedChunks,
java.io.InputStream is,
boolean isCompleteMsg)
Puts all chunks stored in separate files together in one single one. |
private static void |
storeChunk(java.io.File tmpDir,
java.lang.String fileName,
long chunkNumber,
char sep,
boolean overwrite,
java.io.InputStream is)
|
void |
update(java.lang.String topic,
java.io.InputStream is,
java.util.Map attrMap)
The message received from the MoM or from another source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.logging.Logger log
private static final int BUF_SIZE
private java.lang.String dirName
private java.lang.String lockExtention
private java.io.File directory
private boolean overwrite
private java.lang.String tmpDirName
private java.io.File tmpDirectory
private boolean keepDumpFiles
Constructor Detail |
---|
public FileWriterCallback(java.lang.String dirName, java.lang.String tmpDirName, java.lang.String lockExtention, boolean overwrite, boolean keepDumpFiles) throws java.lang.Exception
dirName
- The name of the directory where to store the files.tmpDirName
- the name of the directory where to store the temporary files.lockExtention
- The extension to use to lock the reading of the file. This is used if the
entries have to be retrieved by the file poller. Until such a file exists, the entry is not
processed by the file poller.overwrite
- if set to true it will overwrite existing files.
java.lang.Exception
Method Detail |
---|
private static void storeChunk(java.io.File tmpDir, java.lang.String fileName, long chunkNumber, char sep, boolean overwrite, java.io.InputStream is) throws java.lang.Exception
java.lang.Exception
private long extractNumberPostfixFromFile(java.lang.String filename, java.lang.String prefix) throws java.lang.Exception
filename
- the filename to check.prefix
- the prefix of the filename (the part before the number)
java.lang.Exception
- if the content is null or empty.private java.io.File[] getChunkFilenames(java.lang.String fileName, char sep) throws java.lang.Exception
fileName
- sep
-
java.lang.Exception
private void putAllChunksTogether(java.lang.String fileName, java.lang.String subDir, long expectedChunks, java.io.InputStream is, boolean isCompleteMsg) throws java.lang.Exception
fileName
- The name of the complete (destination) file.expectedChunks
- The number of expected chunks. If the number of chunks found is
bigger, the exceeding ones are ignored and a warning is written to the logs. If the number
is too low it checks if the file already exists. If it exists a warning is written and
the method returns, otherwise an exception is thrown. Keeps also track of locking the file.lastContent
- the content of the last chunk of the message (can be null).isCompleteMsg
- is true if the content of the message is contained in one single
chunk (i.e. if the message is not chunked).
java.lang.Exception
- If an error occurs when writing / reading the files. This method tries
to clean up the destination file in case of an exception when writing.private static final boolean deleteFile(java.io.File file)
file
- the file object to be deleted.
public void update(java.lang.String topic, java.io.InputStream is, java.util.Map attrMap) throws java.lang.Exception
I_Update
update
in interface I_Update
topic
- The topic nameattrMap
- A map with attribute, can be null
java.lang.Exception
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |