|
|
|||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
java.lang.Objectcom.lightysoft.logmx.mgr.LogFileManager
public abstract class LogFileManager
Abstract class that each LogMX Manager must extend. A Manager is used by LogMX to get the bytes that will be read
by the log parser. For example, you can define a Manager reading log content from an Oracle DB, POP3, FTP, or anything else.
This class contains abstract methods to be implemented by Managers, and final methods to be called by Managers.
Managers should not have a Constructor. If you define a Constructor, don't allocate resources or
perform time-consuming operations in it, since LogMX can call it any time without calling releaseResources().
Here is how LogMX uses a Manager:
init(LogURL, String)getCurrentURL()setEncoding(String)prepareForReading()readLine() until it returns nullgetCurrentFileLastModifDate() periodically (through getCurrentFileInfo())getCurrentFileSize() periodically (through getCurrentFileInfo())releaseResources(boolean)true in supportHeaderReading()true in supportRandomAccess()readFileHeader(int)readLineAtOffset(long)getCurrentOffset()getCurrentFileSize()
or getCurrentFileLastModifDate(). The unimplemented method should
always return the same valuetrue in supportHeaderReading()readFileHeader(int)
ManagerSpecVersion| Field Summary | |
|---|---|
Object |
READ_MUTEX
Mutex used by LogMX and the Manager to ensure that only one thread makes this Manager read from the underlying resource, at the same time. |
| Constructor Summary | |
|---|---|
LogFileManager()
Default constructor. |
|
| Method Summary | |
|---|---|
abstract boolean |
deleteFile()
Called by LogMX to delete (i.e. remove from disk) the current file. |
abstract boolean |
flushFile()
Called by LogMX to flush (i.e. empty) the current file. |
LogFileInfo |
getCurrentFileInfo()
Called periodically by LogMX to get the current file size and date. |
abstract long |
getCurrentFileLastModifDate()
Called by LogMX to know when the opened resource was modified for the last time. |
abstract long |
getCurrentFileSize()
Called by LogMX to get the current resource size in bytes. |
abstract long |
getCurrentOffset()
Called by LogMX to know the current position in file. |
abstract String |
getCurrentURL()
Called by LogMX to get the current opened URL, matching this Manager URL template. |
String |
getEncoding()
Called by the Manager to get the Encoding to use when reading bytes. |
abstract Icon |
getFileTypeIcon()
Called by LogMX to get this Manager icon, which must be a 16x16 icon. |
static Icon |
getIconFile(String pImageFileName)
Called by the Manager to get the image contained in file named pImageFileName
in LogMX "pics/" directory. |
abstract String |
getName()
Called by LogMX to get the name of this Manager. |
String |
getOrAskUserPassword(String pLogin,
String pHost)
Called by the Manager to get a user password saved in LogMX password repository, or by asking the user his password if the password is not saved in LogMX password repository yet. |
abstract String |
getProtocolName()
Called by LogMX to get the Protocol handled by this Manager. |
abstract ManagerSpecVersion |
getSpecificationVersion()
Called by LogMX to get the Manager Specification version supported by this Manager. |
abstract LogURL |
getTemplateLogURL()
Called by LogMX to get a template of LogURL used by this Manager. |
static String |
getURLFromLogURL(LogURL pLogURL,
String pURLPattern)
Called by the Manager to construct a string URL from a LogURL and a URL pattern. |
abstract String |
getURLPattern()
Called by LogMX to know how to display a URL handled by this Manager. |
abstract void |
init(LogURL pLogURL,
String pURLString)
Called by LogMX to initialize the Manager for the specified resource. |
void |
newEncodingDetected()
Called by LogMX after prepareForReading() and
before readLine() if and only if the encoding
to use (to read bytes from the underlying resource) has changed. |
abstract LogFileInfo |
prepareForReading()
Called by LogMX to open the resource previously specified by init(LogURL, String)
to get ready to read this underlying resource, and return information on this resource (size and date). |
abstract byte[] |
readFileHeader(int pNbBytes)
Called by LogMX to read the first pNbBytes bytes from the underlying file or resource. |
abstract String |
readLine()
Called by LogMX to get the next line of text from the underlying Manager resource (file, stream, socket,...). |
abstract AutoRefreshLineInfo |
readLineAtOffset(long pOffset)
Called by LogMX to read the line of text starting at the specified offset. |
abstract void |
releaseResources(boolean pSoftRelease)
Called by LogMX when it doesn't need to use this Manager anymore. |
abstract boolean |
supportFileDelete()
Called by LogMX to know if this Manger can delete (i.e. remove from disk) the current file. |
abstract boolean |
supportFileFlush()
Called by LogMX to know if this Manger can flush (i.e. empty) the current file. |
abstract boolean |
supportHeaderReading()
Called by LogMX to know if this Manager support header reading (read a specified number of bytes from the beginning of the file). |
abstract boolean |
supportRandomAccess()
Called by LogMX to know if this Manager support random access (read bytes starting at a specified offset). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final Object READ_MUTEX
getCurrentFileLastModifDate()
or getCurrentFileSize() to be called by LogMX during a specific code execution.
| Constructor Detail |
|---|
public LogFileManager()
releaseResources().
| Method Detail |
|---|
public abstract String getName()
ManagerSpecVersion)public abstract LogURL getTemplateLogURL()
LogURL used by this Manager.LogURL can (should) be a static shared instance for better performance.
LogMX will not use it directly but will use a clone of it.
LogURL used by this ManagerManagerSpecVersion)LogURLpublic abstract String getURLPattern()
SimpleText to denote text "SimpleText"{MyParam} to denote the value of LogURLParameter named "MyParam"[SimpleOptionalPart] to denote an optional part containing free text, LogURLParameter value, or both.scp://{Login}@{Host}:[{Port}:]{File}scp://john@myhost:22:/mydir/myfile.logscp://john@myhost:/myfile.loghttp://{Host}[:{Port}][/{File}]http://www.logmx.com:80/myscript.php?p=4http://www.logmx.com:80/mypage.htmlhttp://www.logmx.com
ManagerSpecVersion)
public abstract void init(LogURL pLogURL,
String pURLString)
throws Exception
pLogURL - LogURL for the resource this Manager will have to openpURLString - String representation for this URL (may be helpful for the Manager, especially to implement
getCurrentURL()
Exception - If the Manager is not able to process this URLManagerSpecVersion)public abstract String getProtocolName()
ManagerSpecVersion)
public abstract String readLine()
throws Exception
null if there is no more byte to read.
null if there is no more byte to read.
Exception - If an error occurred while reading bytes. Managers should not handle Exceptions but should
throw them instead, so that LogMX can catch them.ManagerSpecVersion)public abstract void releaseResources(boolean pSoftRelease)
readLine() anymore if pSoftRelease
was false.
pSoftRelease - Used for Auto-Refresh feature: if true, the Manager must not release resources
needed to read next line of text.ManagerSpecVersion)
public abstract LogFileInfo prepareForReading()
throws Exception
init(LogURL, String)
to get ready to read this underlying resource, and return information on this resource (size and date).
Exception - If the resource couldn't be opened (this Exception message will be displayed in LogMX GUI)ManagerSpecVersion)public abstract String getCurrentURL()
init(LogURL, String),
or use getURLFromLogURL(LogURL, String) to construct the URL.
ManagerSpecVersion)public abstract boolean deleteFile()
supportFileDelete()
returns false), this method may only contain "return false;".
true if deletion succeeded, or false it didn't.ManagerSpecVersion)public abstract boolean flushFile()
supportFileFlush()
returns false), this method may only contain "return false;".
true if flush succeeded, or false it didn't.ManagerSpecVersion)public abstract long getCurrentFileLastModifDate()
Date.getTime().
ManagerSpecVersion)public abstract long getCurrentFileSize()
ManagerSpecVersion)public LogFileInfo getCurrentFileInfo()
abstract or final, so that most Managers may
not have to override (i.e. redefine) it, but some others can. The default implementation returns a LogFileInfo containing
the file size and date returned by getCurrentFileSize()
and getCurrentFileLastModifDate().
Manager must override this new method if getting the file size and file date are both
time-consuming and if they both need a same connection, transaction, context, ...
For example, if getting both file size/date can be performed via a single SFTP "STAT" command,
the Manager shall override getCurrentFileInfo()
so that only one "STAT" command is performed. Note: this method appeared in Manager Specification Version v1.1
is called periodically for file change detection and Auto-Refresh.
ManagerSpecVersion)
public abstract byte[] readFileHeader(int pNbBytes)
throws Exception
pNbBytes bytes from the underlying file or resource.null.
pNbBytes - Number of bytes to read. If negative, Manager must read as much bytes as possible
(for example, up to the end of file)
null if Manager doesn't support header reading
Exception - If Manager could not read bytesManagerSpecVersion)
public abstract AutoRefreshLineInfo readLineAtOffset(long pOffset)
throws Exception
null.
pOffset - Starting offset
null if Manager doesn't support header reading
Exception - If Manager could not read bytesManagerSpecVersion)public abstract long getCurrentOffset()
ManagerSpecVersion)public abstract boolean supportFileFlush()
false is returned, LogMX will not call flushFile()
true if this Manager can flush the current file, or false if it can't.ManagerSpecVersion)public abstract boolean supportFileDelete()
false is returned, LogMX will not call deleteFile()
true if this Manager can delete the current file, or false if it can't.ManagerSpecVersion)public abstract boolean supportRandomAccess()
false is returned, LogMX will not call readLineAtOffset(long)
true if this Manager support random access, or false if it doesn't.ManagerSpecVersion)public abstract boolean supportHeaderReading()
false is returned, LogMX will not call readFileHeader(int)
true if this Manager support header reading, or false if it doesn't.ManagerSpecVersion)public abstract Icon getFileTypeIcon()
getIconFile(String) to get an icon file
contained in LogMX pictures directory, in order to avoid relative file path issues.null is returned, a default icon will be used.
null to use a default icon.ManagerSpecVersion)public abstract ManagerSpecVersion getSpecificationVersion()
ManagerSpecVersion.V1_0
ManagerSpecVersion)public void newEncodingDetected()
prepareForReading() and
before readLine() if and only if the encoding
to use (to read bytes from the underlying resource) has changed.getEncoding().
prepareForReading(). If the encoding found during this auto-detection
is different from the one set while prepareForReading() was called, this method
newEncodingDetected() will be called so that the Manager can re-create its Input
Stream Reader before readLine() is called.getEncoding() in prepareForReading()
to initialize its Input Stream Reader, or if the Input Stream Reader used in readFileHeader(int)
is also used in readLine()
ManagerSpecVersion)public final String getEncoding()
new InputStreamReader(myStream, getEncoding());
ManagerSpecVersion)public static final Icon getIconFile(String pImageFileName)
pImageFileName
in LogMX "pics/" directory.
pImageFileName - File name, without path (e.g. "my_pic.png")
pImageFileNameManagerSpecVersion)
public static final String getURLFromLogURL(LogURL pLogURL,
String pURLPattern)
pLogURL - LogURL containing parameters and their valuepURLPattern - URL Pattern as described for getURLPattern()
ManagerSpecVersion)
public final String getOrAskUserPassword(String pLogin,
String pHost)
pLogin - User loginpHost - Host to access (used to save a password per host, and per protocol using getProtocolName())
ManagerSpecVersion)
|
|
|||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||