1 16 package org.jmanage.cmdui.commands; 17 18 import org.jmanage.cmdui.CommandHandler; 19 import org.jmanage.cmdui.HandlerContext; 20 import org.jmanage.cmdui.CommandConstants; 21 import org.jmanage.cmdui.util.Out; 22 import org.jmanage.cmdui.util.CommandUtils; 23 import org.jmanage.core.services.ServiceFactory; 24 import org.jmanage.core.services.ConfigurationService; 25 26 import java.util.List ; 27 28 33 public class MBeansHandler implements CommandHandler { 34 35 41 public boolean execute(HandlerContext context) { 42 String [] args = context.getCommand().getArgs(); 43 if(args.length != 1){ 44 usage(); 45 return false; 46 } 47 48 String appName = args[0]; 49 50 ConfigurationService configService = 51 ServiceFactory.getConfigurationService(); 52 List mbeanDataList = 53 configService.getConfiguredMBeans( 54 context.getServiceContext(appName)); 55 assert mbeanDataList != null; 56 CommandUtils.printMBeans(mbeanDataList); 57 return true; 58 } 59 60 public String getShortHelp() { 61 return "Lists configured mbeans for the given application"; 62 } 63 64 public void help() { 65 Out.println(getShortHelp()); 66 Out.println("Usage:"); 67 Out.println(CommandConstants.MBEANS + " <application name>"); 68 } 69 70 private void usage(){ 71 Out.println("Invalid arguments"); 72 help(); 73 } 74 } 75 | Popular Tags |