Methods Summary |
---|
private java.lang.Object[] | getParams(java.lang.String appname)Returns the paramters to use to pass into GET_MODULE_COMPONENTS method
if (appname == null)
{
return new Object[] {(String)getOperands().get(0)};
}
else
{
return new Object[] {appname, (String)getOperands().get(0)};
}
|
private java.lang.String[] | getTypes(java.lang.String appname)Returns the types to use for GET_MODULE_COMPONENTS method
if (appname == null)
{
return new String[] {String.class.getName()};
}
else
{
return new String[] {String.class.getName(), String.class.getName()};
}
|
private void | printDebug(javax.management.MBeanServerConnection mbsc, java.lang.String objectName)This method prints the objecName info for debugging purpose
CLILogger.getInstance().printDebugMessage("********** getMBeanInfo **********");
final javax.management.MBeanInfo mbinfo = mbsc.getMBeanInfo(new ObjectName(objectName));
CLILogger.getInstance().printDebugMessage("Description = " + mbinfo.getDescription());
CLILogger.getInstance().printDebugMessage("Classname = " + mbinfo.getClassName());
final javax.management.MBeanOperationInfo[] mboinfo = mbinfo.getOperations();
for (int ii=0; ii<mboinfo.length; ii++)
{
CLILogger.getInstance().printDebugMessage("("+ii+") Description = " +
mboinfo[ii].getDescription());
CLILogger.getInstance().printDebugMessage("("+ii+") Name = " +
mboinfo[ii].getName());
CLILogger.getInstance().printDebugMessage("****** TYPE *****");
final javax.management.MBeanParameterInfo[] mbpi = mboinfo[ii].getSignature();
for (int kk=0; kk<mbpi.length; kk++)
{
CLILogger.getInstance().printDebugMessage("type = " + mbpi[kk].getType());
}
CLILogger.getInstance().printDebugMessage("returnType = " + mboinfo[ii].getReturnType());
}
|
private void | printObjectName(java.lang.Object returnValue, java.lang.String typeOption)This method prints the object name.
if (returnValue == null)
{
CLILogger.getInstance().printDetailMessage(
getLocalizedString("NoElementsToList"));
}
try
{
if (returnValue.getClass().getName().equals(STRING_ARRAY))
{
final String[] objs = (String[])returnValue;
boolean nothingToList = true;
for (int ii=0; ii<objs.length; ii++)
{
CLILogger.getInstance().printDebugMessage("***** " + objs[ii]);
final ObjectName on = new ObjectName(objs[ii]);
if (typeOption != null)
{
if ((typeOption.equals(EJBS) &&
on.getKeyProperty("j2eeType").matches(EJB_SUB_MODULE)) ||
(typeOption.equals(SERVLETS) &&
on.getKeyProperty("j2eeType").matches(SERVLET_SUB_MODULE)))
{
printSubComponent(on);
nothingToList=false;
}
}
else
{
printSubComponent(on);
nothingToList=false;
}
}
if (nothingToList)
{
CLILogger.getInstance().printDetailMessage(
getLocalizedString("NoElementsToList"));
}
}
}
catch (Exception e)
{
throw new CommandException(e);
}
|
private void | printSubComponent(javax.management.ObjectName on)This method prints the sub component name
CLILogger.getInstance().printMessage(on.getKeyProperty("name") + " <"+
on.getKeyProperty("j2eeType") + ">");
|
public void | runCommand()An abstract method that Executes the command
validateOptions();
final String objectName = getObjectName();
final String appname = getOption(APPNAME_OPTION);
final String typeOption = getOption(TYPE_OPTION);
final Object[] params = getParams(appname);
final String[] types = getTypes(appname);
//use http connector
final MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(),
getUser(), getPassword());
try
{
// if (System.getProperty("Debug") != null) printDebug(mbsc, objectName);
Object returnValue = mbsc.invoke(new ObjectName(objectName),
GET_MODULE_COMPONENTS, params, types);
printObjectName(returnValue, typeOption);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"CommandSuccessful",
new Object[] {name}));
}
catch(Exception e)
{
if (e.getLocalizedMessage() != null)
CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
throw new CommandException(getLocalizedString("CommandUnSuccessful",
new Object[] {name} ), e);
}
|
public boolean | validateOptions()An abstract method that validates the options
on the specification in the xml properties file
This method verifies for the correctness of number of
operands and if all the required options are supplied by the client.
//Check if the type option arguments are valid ejbs|servlets
final String typeOption = getOption(TYPE_OPTION);
if ((typeOption != null) && !typeOption.matches(TYPE_OPTION_VALUES))
throw new CommandValidationException(getLocalizedString(
"InvalidTypeOption"));
return super.validateOptions();
|