1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 28 32 public class GenerateJVMReportCommand extends GenericCommand 33 { 34 35 private static final String SUMMARY_OPERATION = "getSummary"; 36 private static final String CLASS_OPERATION = "getClassInformation"; 37 private static final String MEMORY_OPERATION = "getMemoryInformation"; 38 private static final String THREADDUMP_OPERATION = "getThreadDump"; 39 private static final String TYPE_OPTION = "type"; 40 private String typeOption; 41 42 49 public boolean validateOptions() throws CommandValidationException 50 { 51 if (!super.validateOptions()) 52 return false; 53 54 typeOption = getOption(TYPE_OPTION); 55 if (typeOption.matches("summary|memory|class|thread")) 56 { 57 return true; 58 } 59 else 60 { 61 throw new CommandValidationException(getLocalizedString( 62 "InvalidTypeOption")); 63 } 64 } 65 66 67 71 protected String getOperationName() throws CommandException 72 { 73 String operationName = SUMMARY_OPERATION; 74 if (typeOption.equals("memory")) 75 operationName = MEMORY_OPERATION; 76 else if (typeOption.equals("class")) 77 operationName = CLASS_OPERATION; 78 else if (typeOption.equals("thread")) 79 operationName = THREADDUMP_OPERATION; 80 return operationName; 81 } 82 83 protected void handleReturnValue(Object returnval) 84 { 85 final Class cl = returnval.getClass(); 86 if (cl.getName().equals(String .class.getName())) 87 { 88 final String returnString = (String )returnval; 89 CLILogger.getInstance().printMessage(returnString); 90 } 91 } 92 93 } 94 | Popular Tags |