1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import javax.management.AttributeList ; 28 import javax.management.Attribute ; 29 import javax.management.MBeanServerConnection ; 30 import javax.management.ObjectName ; 31 import java.util.Properties ; 32 import java.util.Enumeration ; 33 34 public class DeleteManagementRuleCommand extends GenericCommand 35 { 36 private static final String TARGET_OPTION = "target"; 37 38 39 43 public void runCommand() throws CommandException, CommandValidationException 44 { 45 validateOptions(); 46 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 47 getUser(), getPassword()); 48 String config = resolveTargetToConfig(mbsc, getOption(TARGET_OPTION)); 49 String objectName = "com.sun.appserv:type=management-rules,config=" + 50 config + ",category=config"; 51 CLILogger.getInstance().printDebugMessage("ObjectName = " + objectName); 52 final Object [] params = getParamsInfo(); 54 final String operationName = getOperationName(); 55 final String [] types = getTypesInfo(); 56 57 try 58 { 59 if (params[0] != null) 60 { 61 Object returnValue = mbsc.invoke(new ObjectName (objectName), 62 operationName, params, types); 63 handleReturnValue(returnValue); 64 } 65 CLILogger.getInstance().printDetailMessage(getLocalizedString( 66 "CommandSuccessful", 67 new Object [] {name})); 68 } 69 catch(Exception e) 70 { 71 displayExceptionMessage(e); 72 } 73 74 } 75 76 77 81 private String resolveTargetToConfig(MBeanServerConnection mbsc, 82 String target) throws CommandException 83 { 84 String objectName = "com.sun.appserv:type=configs,category=config"; 85 final Object [] params = new Object [] {target}; 86 final String operationName = "getConfigNameForTarget"; 87 final String [] types = new String [] {"java.lang.String"}; 88 89 try 90 { 91 String returnValue = (String ) mbsc.invoke( 92 new ObjectName (objectName), 93 operationName, params, types); 94 return (returnValue); 95 } 96 catch(Exception e) 97 { 98 throw new CommandException(e.getLocalizedMessage()); 99 } 100 101 } 102 } 103 | Popular Tags |