Package adams.core.logging
Class RemoteReceiveHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- adams.core.logging.AbstractLogHandler
-
- adams.core.logging.AbstractEnhancingSingleHandler
-
- adams.core.logging.RemoteReceiveHandler
-
- All Implemented Interfaces:
EnhancingSingleHandler,Comparable<Handler>
public class RemoteReceiveHandler extends AbstractEnhancingSingleHandler
Waits for log records from a remote sender.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRemoteReceiveHandler.AbstractRemoteListenerRunnableAncestor for remote listeners.static classRemoteReceiveHandler.RemoteListenerRunnableUsingHandlerPublishes the logging records using the supplied handler.
-
Field Summary
Fields Modifier and Type Field Description protected intm_Portthe port to listen to.protected RemoteReceiveHandler.AbstractRemoteListenerRunnablem_Runnablethe runnable in use.protected intm_TimeOutthe timeout to use (msec).-
Fields inherited from class adams.core.logging.AbstractEnhancingSingleHandler
m_Handler
-
Fields inherited from class adams.core.logging.AbstractLogHandler
m_LoggingListeners, m_LogUsed
-
-
Constructor Summary
Constructors Constructor Description RemoteReceiveHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the Handler and free all associated resources.intcompareTo(Handler o)Compares the handler with itself.protected voiddoPublish(LogRecord record)Publish a LogRecord.protected HandlergetDefaultHandler()Returns the default handler.intgetPort()Returns the port to listen for data.intgetTimeOut()Returns the timeout (in msec) for accepting connections.protected voidinitialize()Initializes the members.static voidmain(String[] args)Just for testing.voidsetPort(int value)Sets the port to listen for data.voidsetTimeOut(int value)Sets the timeout (in msec) for accepting connections.booleanstartListening()Tries to start listing to the port.voidstopListening()Stops the listening.-
Methods inherited from class adams.core.logging.AbstractEnhancingSingleHandler
getHandler, setHandler
-
Methods inherited from class adams.core.logging.AbstractLogHandler
addLoggingListener, equals, flush, isSetUp, iterator, loggingListeners, notifyLoggingListeners, postPublish, publish, removeLoggingListener, removeLoggingListeners, reset, setUp
-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Field Detail
-
m_Port
protected int m_Port
the port to listen to.
-
m_TimeOut
protected int m_TimeOut
the timeout to use (msec).
-
m_Runnable
protected RemoteReceiveHandler.AbstractRemoteListenerRunnable m_Runnable
the runnable in use.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractEnhancingSingleHandler
-
getDefaultHandler
protected Handler getDefaultHandler()
Returns the default handler.- Specified by:
getDefaultHandlerin classAbstractEnhancingSingleHandler- Returns:
- the default
-
setPort
public void setPort(int value)
Sets the port to listen for data.- Parameters:
value- the port
-
getPort
public int getPort()
Returns the port to listen for data.- Returns:
- the port
-
setTimeOut
public void setTimeOut(int value)
Sets the timeout (in msec) for accepting connections.- Parameters:
value- the timeout (in msec)
-
getTimeOut
public int getTimeOut()
Returns the timeout (in msec) for accepting connections.- Returns:
- the timeout (in msec)
-
close
public void close() throws SecurityExceptionClose the Handler and free all associated resources.The close method will perform a flush and then close the Handler. After close has been called this Handler should no longer be used. Method calls may either be silently ignored or may throw runtime exceptions.
- Overrides:
closein classAbstractLogHandler- Throws:
SecurityException- if a security manager exists and if the caller does not have LoggingPermission("control").
-
startListening
public boolean startListening()
Tries to start listing to the port.- Returns:
- true if successfully started
-
stopListening
public void stopListening()
Stops the listening.- See Also:
close()
-
doPublish
protected void doPublish(LogRecord record)
Publish a LogRecord.The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.
The Handler is responsible for formatting the message, when and if necessary. The formatting should include localization.
- Specified by:
doPublishin classAbstractLogHandler- Parameters:
record- description of the log event. A null record is silently ignored and is not published
-
compareTo
public int compareTo(Handler o)
Compares the handler with itself.- Specified by:
compareToin interfaceComparable<Handler>- Overrides:
compareToin classAbstractLogHandler- Parameters:
o- the other handler- Returns:
- less than 0, equal to 0, or greater than 0 if the handler is less, equal to, or greater than this one
-
main
public static void main(String[] args)
Just for testing.- Parameters:
args- optionally supplying port and timeout
-
-