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

CreateManagementRuleCommand

public class CreateManagementRuleCommand extends GenericCommand

Fields Summary
private static final String
RULE_DESCRIPTION_OPTION
private static final String
RULE_ENABLED_OPTION
private static final String
EVENT_TYPE_OPTION
private static final String
EVENT_LEVEL_OPTION
private static final String
EVENT_DESCRIPTION_OPTION
private static final String
EVENT_PROPERTIES_OPTION
private static final String
RECORD_EVENT_OPTION
private static final String
ACTION_OPTION
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);
        }