FileDocCategorySizeDatePackage
DeleteManagementRuleCommand.javaAPI DocGlassfish v2 API4693Fri May 04 22:25:08 BST 2007com.sun.enterprise.cli.commands

DeleteManagementRuleCommand

public class DeleteManagementRuleCommand extends GenericCommand

Fields Summary
private static final String
TARGET_OPTION
Constructors Summary
Methods Summary
private java.lang.StringresolveTargetToConfig(javax.management.MBeanServerConnection mbsc, java.lang.String target)
resolves the target to config name

throws
CommandException

        String objectName = "com.sun.appserv:type=configs,category=config";
        final Object[] params = new Object[] {target};
        final String operationName = "getConfigNameForTarget";
        final String[] types = new String[] {"java.lang.String"};

        try
        { 
            String returnValue =  (String) mbsc.invoke(
                                            new ObjectName(objectName), 
                                            operationName, params, types);
            return (returnValue);
        }
        catch(Exception e)
        {
            throw new CommandException(e.getLocalizedMessage());
        }        
    
    
public voidrunCommand()
An abstract method that Executes the command

throws
CommandException


    
                    
         
    
        validateOptions();
        MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 
                                                              getUser(), getPassword());
        String config = resolveTargetToConfig(mbsc, getOption(TARGET_OPTION));
        String objectName = "com.sun.appserv:type=management-rules,config=" +
                            config + ",category=config";
        CLILogger.getInstance().printDebugMessage("ObjectName = " + objectName);
        //use http connector
        final Object[] params = getParamsInfo();
        final String operationName = getOperationName();
        final String[] types = getTypesInfo();

        try
        { 
            if (params[0] != null)
            {
                Object returnValue = mbsc.invoke(new ObjectName(objectName), 
                                                operationName, params, types);
                handleReturnValue(returnValue);
            }
	    CLILogger.getInstance().printDetailMessage(getLocalizedString(
						       "CommandSuccessful",
						       new Object[] {name}));
        }
        catch(Exception e)
        {
            displayExceptionMessage(e);
        }