org.rutil.main
Class Main

java.lang.Object
  extended by javax.management.StandardMBean
      extended by org.rutil.main.Main
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, MainMBean

public class Main
extends javax.management.StandardMBean
implements MainMBean

A main class (vm startable) that provides start/stop functionality for command line applications via MBeans. Command line applications that need the ability intiate a graceful shutdown (without killing them), need to implement MainProcess and use the implemenation along with class. Configuring the start command with JMX server options at startup is a pre-requisite for Start/Stop functionality.

e.g. If you implemented a MainProcess and named it TestProcess (and have it in the classpath),
to start: java -Dcom.sun.management.jmxremote.port=8085 -D... org.rutil.main.Main TestProcess blah blah ... start
to stop: java org.rutil.main.Main stop rmi://localhost:8085

Startup command:

java -D org.rutil.main.Main start [<-mainlib> ]

jmx-options: See java.sun.com for jmx parameter/options.
MainProcess-classname (implements MainProcess): This is the class that needs to be started by this Main program.
arg (optional args): args to main process i.e. client entry point
start: start command
mainlib (optional arg): flag followed by one or more dir path and/or jar file names (comma separated). this option is a shortcut to specificy a directory location (that contain's one or more jar files) to be added to the classpath. NOTE: If -mainlib option is used, a new classloader is used to load the client and the jars/directories specified as arguments and hence these will NOT be visible to classes loaded from the classpath.

Shutdown command:

java org.rutil.main.Main stop

stop: stop command
host: the host on which the Main program was started.
rmiPort: the rmi port configured for mbean server (port used at startup).

Author:
mohan
See Also:
MainProcess

Field Summary
 
Fields inherited from interface org.rutil.main.MainMBean
MBEAN_NAME
 
Constructor Summary
Main()
           
 
Method Summary
static void main(java.lang.String[] args)
           
 void start(org.rutil.main.MainArgs mainArgs)
           
 void stop()
           
 
Methods inherited from class javax.management.StandardMBean
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Main

public Main()
     throws javax.management.NotCompliantMBeanException
Throws:
javax.management.NotCompliantMBeanException
Method Detail

start

public void start(org.rutil.main.MainArgs mainArgs)
           throws java.lang.Exception
Specified by:
start in interface MainMBean
Throws:
java.lang.Exception

stop

public void stop()
Specified by:
stop in interface MainMBean

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception