1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import com.sun.enterprise.config.serverbeans.ServerTags; 28 29 import javax.management.MBeanServerConnection ; 30 import javax.management.ObjectName ; 31 import java.util.List ; 32 33 public class ListMBeansCommand extends GenericCommand 34 { 35 private final static String ENABLED_OPERATION = "isMBeanEnabled"; 36 40 public void runCommand() throws CommandException, CommandValidationException 41 { 42 if (!validateOptions()) 43 throw new CommandValidationException("Validation is false"); 44 45 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 47 getUser(), getPassword()); 48 final String objectName = getObjectName(); 49 final Object [] params = getParamsInfo(); 50 final String operationName = getOperationName(); 51 final String [] types = getTypesInfo(); 52 53 try 54 { 55 List returnValue = (List ) mbsc.invoke(new ObjectName (objectName), 57 operationName, params, types); 58 if (returnValue.size() == 0) 59 { 60 CLILogger.getInstance().printDetailMessage( 61 getLocalizedString("NoElementsToList")); 62 } 63 ObjectName objName; 64 String target = getOperands().size() > 0 ? 65 (String ) getOperands().get(0):null; 66 CLILogger.getInstance().printDebugMessage("target = " + target); 67 CLILogger.getInstance().printDebugMessage("list size = " + returnValue.size()); 68 69 for (int ii=0; ii<returnValue.size(); ii++) 70 { 71 objName = (ObjectName ) returnValue.get(ii); 72 CLILogger.getInstance().printDebugMessage("objName = " + objName.toString()); 73 String mbeanName = (String ) mbsc.getAttribute(objName, ServerTags.NAME); 74 String mbeanObjName = (String ) mbsc.getAttribute(objName, 75 ServerTags.OBJECT_NAME); 76 final String boolVal = (String ) mbsc.getAttribute(objName, ServerTags.ENABLED); 77 boolean enabled = Boolean.valueOf(boolVal); 78 79 String printString = mbeanName + " " + mbeanObjName + " " + 81 (enabled ? getLocalizedString("Enabled") 82 : getLocalizedString("Disabled")); 83 CLILogger.getInstance().printMessage(printString); 84 } 85 86 CLILogger.getInstance().printDetailMessage(getLocalizedString( 87 "CommandSuccessful", 88 new Object [] {name})); 89 } 90 catch(Exception e) 91 { 92 displayExceptionMessage(e); 93 } 94 } 95 } 96 | Popular Tags |