1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 28 import com.sun.enterprise.config.serverbeans.ServerTags; 29 import java.util.Map ; 30 import java.util.HashMap ; 31 32 public class CreateMBeanCommand extends GenericCommand 33 { 34 35 public final static String TARGET_OPTION = "target"; 36 public final static String NAME_OPTION = "name"; 37 public final static String OBJECT_NAME_OPTION = "objectname"; 38 public final static String ATTRIBUTES_OPTION = "attributes"; 39 public final static String ATTRIBUTE_DELIMITER = ":"; 40 public final static String ATTRIBUTE_VALUE_DELIMITER = "="; 41 42 46 protected Object [] getParamsInfo()throws CommandException, CommandValidationException 47 { 48 Object [] paramsInfo = new Object [3]; 49 paramsInfo[0] = getOption(TARGET_OPTION); 50 Map mbeanParams = new HashMap (); 51 if (getOption(NAME_OPTION) != null) 52 mbeanParams.put(ServerTags.NAME, getOption(NAME_OPTION)); 53 if (getOption(OBJECT_NAME_OPTION) != null) 54 mbeanParams.put(ServerTags.OBJECT_NAME, getOption(OBJECT_NAME_OPTION)); 55 mbeanParams.put(ServerTags.IMPL_CLASS_NAME, getOperands().get(0)); 56 paramsInfo[1] = mbeanParams; 57 paramsInfo[2] = getAttributesList(getOption(ATTRIBUTES_OPTION)); 58 return paramsInfo; 59 } 60 61 62 66 private Map getAttributesList(String attributesStr) 67 throws CommandException, CommandValidationException 68 { 69 Map attributes = new HashMap (); 70 if (attributesStr == null) return attributes; 71 final CLITokenizer attrTok = new CLITokenizer(attributesStr, ATTRIBUTE_DELIMITER); 72 while (attrTok.hasMoreTokens()) { 73 final String nameAndvalue = attrTok.nextToken(); 74 final CLITokenizer nameTok = new CLITokenizer(nameAndvalue, ATTRIBUTE_VALUE_DELIMITER); 75 if (nameTok.countTokens() == 2) 76 { 77 attributes.put(nameTok.nextTokenWithoutEscapeAndQuoteChars(), 78 nameTok.nextTokenWithoutEscapeAndQuoteChars()); 79 } 80 else 81 { 82 throw new CommandValidationException(getLocalizedString("InvalidAttributeSyntax")); 83 } 84 } 85 CLILogger.getInstance().printDebugMessage("Got the Attributes List : " + attributes.toString()); 86 return attributes; 87 } 88 } 89 | Popular Tags |