com.isti.util
Class MsgViaFileProcessor

java.lang.Object
  extended by com.isti.util.MsgViaFileProcessor

public class MsgViaFileProcessor
extends java.lang.Object

Class MsgViaFileProcessor.java defines a message-via-file processor. An input directory is polled for new files; anytime one is found it is moved to a processing directory, read, processed by a call-back object, and then moved to a storage directory or deleted.


Nested Class Summary
protected  class MsgViaFileProcessor.MsgFileProcessingThread
          Class MsgFileProcessingThread defines the messages-via-file processsing thread.
static interface MsgViaFileProcessor.ProcMsgCallBack
          Interface ProcMsgCallBack defines a method for processing a message and returning a completion/success result.
static class MsgViaFileProcessor.ViaFileProperties
          Class ViaFileProperties manages a set of configuration property items used with the 'MsgViaFileProcessor' class.
 
Field Summary
protected static java.lang.String DEF_PROCDIR_NAME
           
protected  java.io.File inputDirFileObj
           
protected  int inputPollDelayMS
           
protected static int MAX_STORAGE_AGE_CHECK_SECS
           
protected  MsgViaFileProcessor.MsgFileProcessingThread msgFileProcessingThreadObj
           
protected  java.lang.String procCharsetNameStr
           
protected  java.io.File processDirFileObj
           
protected  MsgViaFileProcessor.ProcMsgCallBack procMsgCallBackObj
           
protected  int storageAgeSecsVal
           
protected  java.io.File storageDirFileObj
           
 
Constructor Summary
MsgViaFileProcessor(java.io.File inputDirFile, java.io.File storageDirFile, java.io.File processDirFile, int pollDelayMS, int storageAgeSecs, MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
          Creates a message-via-file processor.
MsgViaFileProcessor(MsgViaFileProcessor.ViaFileProperties viaFileProps, MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
          Creates a message-via-file processor using to given set of configuration-property objects.
MsgViaFileProcessor(java.lang.String inputDirName, java.lang.String storageDirName, java.lang.String processDirName, int pollDelayMS, int storageAgeSecs, MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
          Creates a message-via-file processor.
 
Method Summary
 java.lang.String getProcCharsetNameStr()
          Returns the charset used when reading input data bytes into strings.
 void setProcCharsetNameStr(java.lang.String nameStr)
          Sets the charset to use when reading input data bytes into strings.
 void startProcessing()
          Starts the messages-via-file processsing thread.
 void stopProcessing()
          Stops the messages-via-file processsing thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_PROCDIR_NAME

protected static final java.lang.String DEF_PROCDIR_NAME
See Also:
Constant Field Values

MAX_STORAGE_AGE_CHECK_SECS

protected static final int MAX_STORAGE_AGE_CHECK_SECS
See Also:
Constant Field Values

inputDirFileObj

protected final java.io.File inputDirFileObj

storageDirFileObj

protected final java.io.File storageDirFileObj

processDirFileObj

protected final java.io.File processDirFileObj

inputPollDelayMS

protected final int inputPollDelayMS

storageAgeSecsVal

protected final int storageAgeSecsVal

procMsgCallBackObj

protected final MsgViaFileProcessor.ProcMsgCallBack procMsgCallBackObj

msgFileProcessingThreadObj

protected MsgViaFileProcessor.MsgFileProcessingThread msgFileProcessingThreadObj

procCharsetNameStr

protected java.lang.String procCharsetNameStr
Constructor Detail

MsgViaFileProcessor

public MsgViaFileProcessor(java.io.File inputDirFile,
                           java.io.File storageDirFile,
                           java.io.File processDirFile,
                           int pollDelayMS,
                           int storageAgeSecs,
                           MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
                    throws java.io.IOException
Creates a message-via-file processor.

Parameters:
inputDirFile - the input directory to poll for message files, or null to use the current directory.
storageDirFile - the storage directory to use, or null for none.
processDirFile - the process directory to use for message files, or null to use the default directory "msgProcess".
pollDelayMS - the delay, in milliseconds, between polls of the input directory to check for new files.
storageAgeSecs - the maximum time, in seconds, to keep copies of the message files; or 0 to keep no copies.
procMsgCallBack - the call-back object to use to process the message data read from the input files.
Throws:
java.io.IOException - if the given input, process or storage directory is not found and cannot be created.
java.lang.IllegalArgumentException - if the given input and storage directories are the same.

MsgViaFileProcessor

public MsgViaFileProcessor(java.lang.String inputDirName,
                           java.lang.String storageDirName,
                           java.lang.String processDirName,
                           int pollDelayMS,
                           int storageAgeSecs,
                           MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
                    throws java.io.IOException
Creates a message-via-file processor.

Parameters:
inputDirName - the input directory to poll for message files, or null to use the current directory.
storageDirName - the storage directory to use, or null for none.
processDirName - the process directory to use for message files, or null to use the default directory "msgProcess".
pollDelayMS - the delay, in milliseconds, between polls of the input directory to check for new files.
storageAgeSecs - the maximum time, in seconds, to keep copies of the message files; or 0 to keep no copies.
procMsgCallBack - the call-back object to use to process the message data read from the input files.
Throws:
java.io.IOException - if the given input, process or storage directory is not found and cannot be created.
java.lang.IllegalArgumentException - if the given input and storage directories are the same.

MsgViaFileProcessor

public MsgViaFileProcessor(MsgViaFileProcessor.ViaFileProperties viaFileProps,
                           MsgViaFileProcessor.ProcMsgCallBack procMsgCallBack)
                    throws java.io.IOException
Creates a message-via-file processor using to given set of configuration-property objects.

Parameters:
viaFileProps - the set of configuration-property objects to use.
procMsgCallBack - the call-back object to use to process the message data read from the input files.
Throws:
java.io.IOException - if the given input, process or storage directory is not found and cannot be created.
java.lang.IllegalArgumentException - if the given input and storage directories are the same.
Method Detail

startProcessing

public void startProcessing()
Starts the messages-via-file processsing thread.


stopProcessing

public void stopProcessing()
Stops the messages-via-file processsing thread.


setProcCharsetNameStr

public void setProcCharsetNameStr(java.lang.String nameStr)
Sets the charset to use when reading input data bytes into strings.

Parameters:
nameStr - name of charset to use, or null for default.

getProcCharsetNameStr

public java.lang.String getProcCharsetNameStr()
Returns the charset used when reading input data bytes into strings.

Returns:
name of charset in use, or null if default.