com.cosylab.jcosyne.server
Class JMXServer

java.lang.Object
  extended bycom.cosylab.jcosyne.server.JMXServer
All Implemented Interfaces:
java.util.EventListener, javax.management.NotificationListener, java.lang.Runnable

public class JMXServer
extends java.lang.Object
implements javax.management.NotificationListener, java.lang.Runnable

This is executable JMX server class that serves as entry point for JMX Agent (as defined in the JMX specification). The tasks of this class are to: firstly, initialize server configuration; secondly, instantiate the JMX server and its RMI connector and RMI Naming object; do all appropriate initializations of these objects; and finally, to instantiate default remote tasks, such as the log collector, sentinel, executor and remote repository. The server initializes the configuration by resolving, case by case, the property name. The resolution first checks if the property name is set in Java system properties; if not, it tries to check if there is a server configuration file present at location specified by Constants.SEVER_CONFIG, if not, tries to look for server configuration in user's home directory, and lastly, loading defaults from the JAR resources.

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

Constructor Summary
JMXServer()
           
 
Method Summary
 void handleNotification(javax.management.Notification arg0, java.lang.Object arg1)
          Listens to shutdown notifications from the Sentinel remote task.
 void initialize()
          Starts the server.
static void main(java.lang.String[] args)
          Create a new instance of the server and start it.
 void run()
          Implements the shutdown code that is called out-of-thread by the shutdown() method.
 void shutdown()
          Start a shutdown thread that will close the connector after some period of time defined in Constants interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXServer

public JMXServer()
Method Detail

main

public static void main(java.lang.String[] args)
Create a new instance of the server and start it. Accepts no command line parameters.

Parameters:
args - parameters are ignored

initialize

public void initialize()
                throws java.lang.IllegalArgumentException
Starts the server. Parses the configuration resources first from the location specified in Constants interface, from where it reads server name, and port. Checks if RMI registry already exists on the local machine: if not, creates one; if yes, removes stale server entry and adds itself. Then, in turn, adds the predefined Jcosyne framework remote tasks. If the properties do not contain server and port name, throws exception.

Throws:
java.lang.IllegalArgumentException - if configuration does not contain all expected items

shutdown

public void shutdown()
Start a shutdown thread that will close the connector after some period of time defined in Constants interface.


handleNotification

public void handleNotification(javax.management.Notification arg0,
                               java.lang.Object arg1)
Listens to shutdown notifications from the Sentinel remote task. If received, the shutdown() method is invoked on this object.

Specified by:
handleNotification in interface javax.management.NotificationListener

run

public void run()
Implements the shutdown code that is called out-of-thread by the shutdown() method.

Specified by:
run in interface java.lang.Runnable