com.cosylab.jcosyne.server
Class LogCollector

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended bycom.cosylab.jcosyne.server.RemoteTask
          extended bycom.cosylab.jcosyne.server.LogCollector
All Implemented Interfaces:
java.util.EventListener, LogCollectorMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.management.NotificationListener, RemoteTaskMBean, java.lang.Runnable

public class LogCollector
extends RemoteTask
implements LogCollectorMBean, javax.management.NotificationListener

LogCollector remote task is one of the predefined remote tasks running in each JCosyne JMX server. It registers as log listener to all other remote tasks, collects logs in a list and fires log events. Its purpose is twofold: when a client connects to the server, it can obtain and display all logs produced since the server started; and secondly, the client registers as log listener only in a single place and does not need to keep track of new remote tasks as they register or deregister. Log notifications are defined by the notification type Constants.MESSAGE_LOG.

Author:
Gasper Tkacik (gasper.tkacik@cosylab.com)
See Also:
Constants

Field Summary
 
Fields inherited from class com.cosylab.jcosyne.server.RemoteTask
log, name, running, sequence, SERVER_DELEGATE, serverRef, suspended
 
Constructor Summary
LogCollector()
           
 
Method Summary
 javax.management.Notification[] getOldLogEvents()
          Returns all logs collected up to this point by the log collector.
 void handleNotification(javax.management.Notification arg0, java.lang.Object arg1)
          Receives a log notification from some remote task and adds it to the list of notifications.
protected  void internalInitialize()
          Iterate through all existing remote tasks and register as log listener.
 boolean isReadyToRun()
          This is a framework remote task and its run method is not used.
 void postRegister(java.lang.Boolean value)
          Adds itself to the server as server listener immediatelly after it has been added into the server.
 void preDeregister()
          Remove itself as server listener from the server and call super.
 void run()
          Do NOP.
 
Methods inherited from class com.cosylab.jcosyne.server.RemoteTask
checkState, copyStateFrom, copyStateFrom, executeScript, getInputResource, getLastScriptResult, getName, getOutputResource, getPostExecutionScript, getPostInitializactionScript, getProgress, getSequence, getState, initialize, isAborting, isFinished, isInitialized, isRunning, isSuspended, loadMatrix, loadMatrix, notifyAttributeChange, notifyExecutionStarts, notifyExecutionStops, postDeregister, preRegister, saveMatrix, setFinished, setPostExecutionScript, setPostInitializationScript, setProgress, setRunning, setSuspended
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cosylab.jcosyne.server.RemoteTaskMBean
copyStateFrom, copyStateFrom, equals, executeScript, getLastScriptResult, getName, getPostExecutionScript, getPostInitializactionScript, getProgress, getState, hashCode, initialize, isFinished, isInitialized, isRunning, isSuspended, setPostExecutionScript, setPostInitializationScript, setRunning, setSuspended
 

Constructor Detail

LogCollector

public LogCollector()
Method Detail

internalInitialize

protected void internalInitialize()
Iterate through all existing remote tasks and register as log listener.

Specified by:
internalInitialize in class RemoteTask
See Also:
RemoteTask.initialize()

postRegister

public void postRegister(java.lang.Boolean value)
Adds itself to the server as server listener immediatelly after it has been added into the server.

Specified by:
postRegister in interface javax.management.MBeanRegistration
Overrides:
postRegister in class RemoteTask
Parameters:
value - passed to super()

getOldLogEvents

public javax.management.Notification[] getOldLogEvents()
Returns all logs collected up to this point by the log collector. The order is the same as the order in which the logs were received. Constants.LOG_LIMIT sets the maximum limit for the length of the log list.

Specified by:
getOldLogEvents in interface LogCollectorMBean
Returns:
the list of notifications of log type (carrying log records) collected by this remote task
See Also:
Constants

handleNotification

public void handleNotification(javax.management.Notification arg0,
                               java.lang.Object arg1)
Receives a log notification from some remote task and adds it to the list of notifications. Also forwards the notification by firing rewrapping its log record and firing it to the listeners.

Specified by:
handleNotification in interface javax.management.NotificationListener
Parameters:
arg0 - notification of log type, ignored if type is invalid
arg1 - handback is ignored

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Remove itself as server listener from the server and call super.

Specified by:
preDeregister in interface javax.management.MBeanRegistration
Overrides:
preDeregister in class RemoteTask
Throws:
java.lang.Exception

run

public void run()
Do NOP.

Specified by:
run in interface java.lang.Runnable

isReadyToRun

public boolean isReadyToRun()
This is a framework remote task and its run method is not used.

Specified by:
isReadyToRun in interface RemoteTaskMBean
Returns:
false