public class FileMonPollingThread extends IstiNotifyThread
Modifier and Type | Class and Description |
---|---|
static interface |
FileMonPollingThread.FileDataCallBack
Interface FileDataCallBack defines a call-back method to be invoked
when new file data is available.
|
Modifier and Type | Field and Description |
---|---|
static byte[] |
ERROR_ARRAY
Empty array used to indicate error.
|
protected int |
fileAccessTimeOutMs |
protected FileMonPollingThread.FileDataCallBack |
fileDataCallBackObj |
protected FileDataMonitor |
fileDataMonitorObj |
protected boolean |
forceFileReadFlag |
protected boolean |
indRecoveryFlag |
protected long |
maxReadBytesLimit |
protected int |
pollingIntervalMs |
DEFAULT_TERMINATE_WAIT_TIME, terminateFlag
Constructor and Description |
---|
FileMonPollingThread(java.lang.String fNameStr,
int pollingIntervalMs,
int fileAccessTimeOutMs,
long maxReadBytesLimit,
boolean indRecoveryFlag,
FileMonPollingThread.FileDataCallBack fileDataCallBackObj)
Creates a thread for monitoring a file via a 'FileDataMonitor' object.
|
FileMonPollingThread(java.lang.String fNameStr,
int pollingIntervalMs,
int fileAccessTimeOutMs,
long maxReadBytesLimit,
FileMonPollingThread.FileDataCallBack fileDataCallBackObj)
Creates a thread for monitoring a file via a 'FileDataMonitor' object.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
checkReadFileData()
Checks if the file has been modified and returns its contents if
so.
|
byte[] |
checkReadFileData(boolean forceFileReadFlag)
Checks if the file has been modified and returns its contents if
so.
|
void |
fireForceFileRead()
Fires a forced read of the file by the monitoring thread, as if
the file's last-modified time had changed.
|
boolean |
getErrorMessageFlag()
Returns the status of the error message.
|
java.lang.String |
getErrorMessageString()
Returns the current error message (if any).
|
FileDataMonitor |
getFileDataMonitorObj()
Returns the 'FileDataMonitor' object used by this object.
|
void |
run()
Executing method for file-monitoring thread.
|
sleep, terminate
clearThreadWaitNotifyFlag, isTerminated, nextThreadNum, notifyThread, start, terminate, waitForNotify, waitForNotify, waitForTerminate, waitForTerminate, wasStarted
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, stop, stop, suspend, toString, yield
public static final byte[] ERROR_ARRAY
protected final FileDataMonitor fileDataMonitorObj
protected final int pollingIntervalMs
protected final int fileAccessTimeOutMs
protected final long maxReadBytesLimit
protected final boolean indRecoveryFlag
protected final FileMonPollingThread.FileDataCallBack fileDataCallBackObj
protected boolean forceFileReadFlag
public FileMonPollingThread(java.lang.String fNameStr, int pollingIntervalMs, int fileAccessTimeOutMs, long maxReadBytesLimit, boolean indRecoveryFlag, FileMonPollingThread.FileDataCallBack fileDataCallBackObj)
fNameStr
- name of input file to be read and monitored.pollingIntervalMs
- number of milliseconds to wait between
polls of the input file.fileAccessTimeOutMs
- timeout value for file access, or 0 for
infinite.maxReadBytesLimit
- maximum number of bytes to read from file,
or 0 for no limit.indRecoveryFlag
- if true then the call-back method will be
invoked with (true,null) if the previous file-access attempt failed
and the current attempt succeeded and no change in the file
last-modified time was detected.fileDataCallBackObj
- call-back object to be invoked when changes
in the file data are detected.public FileMonPollingThread(java.lang.String fNameStr, int pollingIntervalMs, int fileAccessTimeOutMs, long maxReadBytesLimit, FileMonPollingThread.FileDataCallBack fileDataCallBackObj)
fNameStr
- name of input file to be read and monitored.pollingIntervalMs
- number of milliseconds to wait between
polls of the input file.fileAccessTimeOutMs
- timeout value for file access, or 0 for
infinite.maxReadBytesLimit
- maximum number of bytes to read from file,
or 0 for no limit.fileDataCallBackObj
- call-back object to be invoked when changes
in the file data are detected.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void fireForceFileRead()
public byte[] checkReadFileData(boolean forceFileReadFlag)
forceFileReadFlag
- true to force reading of file data; false
to only read file data if file-modified time changed.public byte[] checkReadFileData()
public FileDataMonitor getFileDataMonitorObj()
public boolean getErrorMessageFlag()
public java.lang.String getErrorMessageString()