org.ow2.jasmine.monitoring.mbeancmd
Class CommandDispatcher

java.lang.Object
  extended by org.ow2.jasmine.monitoring.mbeancmd.CommandDispatcher

public class CommandDispatcher
extends java.lang.Object

This is the main class of the archive. It dispatches the processing of the command to the right class. The available commands in the current archive are retrieved by introspection of the archive.


Constructor Summary
protected CommandDispatcher()
          Dummy constructor to avoid the class from being used in any other way than calling the CommandDispatcher.main method.
 
Method Summary
 java.lang.String[] getAvailableCommands()
          Returns the names of the available commands in the archive.
 Command getCommand(java.lang.String name)
          Returns an instance of Command.
protected  java.io.InputStreamReader getInputStreamReader(java.lang.String name)
          Return an inputStreamReader for the specified resource, by using the context class loader.
 int init(java.lang.String[] args)
           
 boolean isEmbedded()
          Get the state of MBeanCmd.
protected static boolean isOSGiEnabled()
           
protected  java.lang.Class<?> loadClass(java.lang.String cname)
          Load and return a class for a given class name, by using the defining class loader of the current class.
static void main(java.lang.String[] args)
          Main method.
 void setEmbedded(boolean isEmbedded)
          Set the sate of MBeanCmd
protected static void setOSGiEnabled(boolean osgiEnabled)
          Set if MBeanCmd is embedded in OSGi or not.
static int start(java.lang.String[] args)
          The class is selected from the first argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandDispatcher

protected CommandDispatcher()
Dummy constructor to avoid the class from being used in any other way than calling the CommandDispatcher.main method.

Method Detail

main

public static void main(java.lang.String[] args)
Main method. Calls start(String[])(args) followed by System.exit of the returned value. IMPORTANT: This method calls System.exit !

Parameters:
args - See start(String[]).

start

public static int start(java.lang.String[] args)
The class is selected from the first argument. If no class is available to process the command, it dispatches it to the built-in help class.

Parameters:
args - Arguments of the command, including the command itself at the first position.
Returns:
0 if succeeded, an error code otherwise.

init

public int init(java.lang.String[] args)

getCommand

public Command getCommand(java.lang.String name)
Returns an instance of Command.

Parameters:
name - the name of the command.
Returns:
Command instance corresponding to that name.

getAvailableCommands

public java.lang.String[] getAvailableCommands()
Returns the names of the available commands in the archive.

Returns:
Names of the available commands in the archive, null if no command has been set yet.

getInputStreamReader

protected java.io.InputStreamReader getInputStreamReader(java.lang.String name)
                                                  throws java.io.IOException
Return an inputStreamReader for the specified resource, by using the context class loader.

Parameters:
name - the resource name
Returns:
an inputStreamReader for the specified resource
Throws:
java.io.IOException - if an I/O exception occurs

loadClass

protected java.lang.Class<?> loadClass(java.lang.String cname)
                                throws java.lang.ClassNotFoundException
Load and return a class for a given class name, by using the defining class loader of the current class.

Parameters:
cname - a class name
Returns:
a loaded class for a given class name
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

isEmbedded

public boolean isEmbedded()
Get the state of MBeanCmd.

Returns:
True if MBeanCmd is embedded in the EventSwitch, false otherwise.

setEmbedded

public void setEmbedded(boolean isEmbedded)
Set the sate of MBeanCmd

Parameters:
isEmbedded - The state to set.

isOSGiEnabled

protected static boolean isOSGiEnabled()
Returns:
true if MBeanCmd is embedded in OSGi or not

setOSGiEnabled

protected static void setOSGiEnabled(boolean osgiEnabled)
Set if MBeanCmd is embedded in OSGi or not.

Parameters:
osgiEnabled - true if MBeanCmd is embedded in OSGi or not


Copyright © 2009 OW2 Consortium. All Rights Reserved.