Package com.sun.appserv.management.config

Examples of com.sun.appserv.management.config.ManagementRuleConfig


        public static void saveMonitorEventValues(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName");
            String ruleName = (String) handlerCtx.getInputValue("RuleName");
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
           
            mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
            mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
            mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
            mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
            mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
           
           
            String obsMbean = (String)handlerCtx.getInputValue("ObservedMbean");
            String obsAttr = (String)handlerCtx.getInputValue("ObservedAttr");
            String granularity = (String)handlerCtx.getInputValue("Granularity");
            String monitorType = mgRuleConfig.getEventConfig().getProperties().get("monitortype");
            if(obsMbean != null){
                mgRuleConfig.getEventConfig().setPropertyValue("observedobject", obsMbean);
            }
            if(obsAttr != null){
                mgRuleConfig.getEventConfig().setPropertyValue("observedattribute", obsAttr);
            }   
            if(granularity != null){
                mgRuleConfig.getEventConfig().setPropertyValue("granularityperiod", granularity);
            }   
            if(monitorType.equals("countermonitor") || monitorType.equals("gaugemonitor")){
                Boolean diffMode = (Boolean)handlerCtx.getInputValue("DiffMode");
                if(diffMode != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("differencemode", diffMode.toString());
                }
                String numType = (String)handlerCtx.getInputValue("NumType");
                if(numType != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("numbertype", numType);
                }
                if(monitorType.equals("countermonitor")){
                    String initThresh = (String)handlerCtx.getInputValue("InitThreshold");
                    String offset = (String)handlerCtx.getInputValue("Offset");
                    String modulus = (String)handlerCtx.getInputValue("Modulus");
                    if(initThresh != null){
                        mgRuleConfig.getEventConfig().setPropertyValue("initthreshold", initThresh);
                    }
                    if(offset != null){
                        mgRuleConfig.getEventConfig().setPropertyValue("offset", offset);
                    }
                    if(modulus != null){
                        mgRuleConfig.getEventConfig().setPropertyValue("modulus", modulus);
                    }
                }
                if(monitorType.equals("gaugemonitor")){
                    String lowThresh = (String)handlerCtx.getInputValue("LowThresh");
                    String highThresh = (String)handlerCtx.getInputValue("HighThresh");
                    if(lowThresh != null){
                        mgRuleConfig.getEventConfig().setPropertyValue("lowthreshold", lowThresh);
                    }
                    if(highThresh != null){
                        mgRuleConfig.getEventConfig().setPropertyValue("highthreshold", highThresh);
                    }
                }
            }
            if(monitorType.equals("stringmonitor")){
                String trigger = (String)handlerCtx.getInputValue("Trigger");
                String valueProp = (String)handlerCtx.getInputValue("ValueProp");
                if(trigger != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("stringnotify", trigger);
                }
                if(valueProp != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("stringtocompare", valueProp);
                }
            }
            saveActionProperty(mgRuleConfig, handlerCtx);               
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
View Full Code Here


        public static void saveNotifEventValues(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName"); //NOI18N
            String ruleName = (String) handlerCtx.getInputValue("RuleName"); //NOI18N
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
           
            String srcGroup = (String)handlerCtx.getInputValue("SrcGroup"); //NOI18N
            String notifType = (String)handlerCtx.getInputValue("NotifType"); //NOI18N
            String mbeanProp = null;
            if(srcGroup.equals("1")){ //NOI18N
                mbeanProp = (String)handlerCtx.getInputValue("CustomMbeanName"); //NOI18N
            }else if(srcGroup.equals("2")){ //NOI18N
                mbeanProp = (String)handlerCtx.getInputValue("ObjName"); //NOI18N
            }

            mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
            mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
            mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
            mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
            mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
            if(mbeanProp != null){
                mgRuleConfig.getEventConfig().setPropertyValue("sourceobjectname", mbeanProp);
            }
            if(notifType != null){
                mgRuleConfig.getEventConfig().setPropertyValue("type", notifType);
            }   
            saveActionProperty(mgRuleConfig, handlerCtx);
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
        }
View Full Code Here

        public static void saveTimerEventValues(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName"); //NOI18N
            String ruleName = (String) handlerCtx.getInputValue("RuleName"); //NOI18N
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
           
            String dtString = (String)handlerCtx.getInputValue("DateString"); //NOI18N
            String pattern = (String)handlerCtx.getInputValue("Pattern"); //NOI18N
            String period = (String)handlerCtx.getInputValue("Period"); //NOI18N
            String numOccurences = (String)handlerCtx.getInputValue("NoOccurences"); //NOI18N
            String msg = (String)handlerCtx.getInputValue("Message"); //NOI18N
            mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
            mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
            mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
            mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
            mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
           
            if(dtString != null){
                mgRuleConfig.getEventConfig().setPropertyValue("datestring", dtString);
            }
            if(pattern != null){
                mgRuleConfig.getEventConfig().setPropertyValue("pattern", pattern);
            }
            if(period != null){
                mgRuleConfig.getEventConfig().setPropertyValue("period", period);
            }
            if(numOccurences != null){
                mgRuleConfig.getEventConfig().setPropertyValue("numberofoccurrences", numOccurences);
            }
            if(msg != null){
                mgRuleConfig.getEventConfig().setPropertyValue("message", msg);
            }
            saveActionProperty(mgRuleConfig, handlerCtx);
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
        }
View Full Code Here

        public static void saveClusterEventValues(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName"); //NOI18N
            String ruleName = (String) handlerCtx.getInputValue("RuleName"); //NOI18N
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
            Map<String,String> propMap = mgRuleConfig.getEventConfig().getProperties();
            mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
            mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
            mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
            mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
            mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
            String event = (String)handlerCtx.getInputValue("Event"); //NOI18N
            if(event != null){
                mgRuleConfig.getEventConfig().setPropertyValue("name", event);
            }
            String serverName = (String)handlerCtx.getInputValue("ServerName"); //NOI18N
            if(serverName != null){
                mgRuleConfig.getEventConfig().setPropertyValue("servername", serverName);
            }
            saveActionProperty(mgRuleConfig, handlerCtx);
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
        }
View Full Code Here

        public static void saveLogEventValues(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName"); //NOI18N
            String ruleName = (String) handlerCtx.getInputValue("RuleName"); //NOI18N
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
            Map<String,String> propMap = mgRuleConfig.getEventConfig().getProperties();
            mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
            mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
            mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
            mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
            mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
            Object logList = handlerCtx.getInputValue("Logger"); //NOI18N
            if(logList instanceof String){
                String loggers = (String)logList;
                if(loggers != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("loggernames", loggers);
                }
            }else if(logList instanceof String[]){
                String[] lisVal = (String[])logList;
                String loggers = lisVal[0];
                if(loggers != null){
                    mgRuleConfig.getEventConfig().setPropertyValue("loggernames", loggers);
                }
            }
            String level = (String)handlerCtx.getInputValue("Level"); //NOI18N
            if(level != null){
                mgRuleConfig.getEventConfig().setPropertyValue("level", level);
            }
            saveActionProperty(mgRuleConfig, handlerCtx);
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
        }
View Full Code Here

        public static void getRuleType(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName"); //NOI18N
            String ruleName = (String) handlerCtx.getInputValue("RuleName"); //NOI18N
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
            handlerCtx.setOutputValue("Type", mgRuleConfig.getEventConfig().getType()); //NOI18N
        }catch (Exception ex){
            GuiUtil.handleException(handlerCtx, ex);
        }
    }
View Full Code Here

        public static void getCommonLists(HandlerContext handlerCtx) {
        try{
            String configName = (String) handlerCtx.getInputValue("ConfigName");
            String ruleName = (String) handlerCtx.getInputValue("RuleName");
            ConfigConfig config = AMXUtil.getConfig(configName);
            ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
            Map<String,String> propMap = mgRuleConfig.getEventConfig().getProperties();
            SelectItem[] levels = ConfigurationHandlers.getOptions(logLevels);
            SelectItem[] events = null;
            String type = mgRuleConfig.getEventConfig().getType();
            if(type.equals("lifecycle")){
                events = ConfigurationHandlers.getOptions(lifeCycleEvents);
            }else if(type.equals("trace")){
                events = ConfigurationHandlers.getOptions(traceEvents);
            }else if(type.equals("cluster")) { //NOI18N
View Full Code Here

           
            //TODO Bug in AMX -- Classcast Exception on util.Properties because the optMap is defined
            // as <String, String> in ConfigFactory though the create code expects Properties
            //optMap.put(ManagementRulesConfig.EVENT_PROPERTIES_KEY, getProperties(eventType, ruleTypes));
            ManagementRulesConfig mgRulesConfig = getManagementRulesConfig(mgmtRule);
            ManagementRuleConfig ruleConfig = mgRulesConfig.createManagementRuleConfig(ruleName,
                    eventType, null, optMap);
            setEventConfigProperties(ruleConfig, eventType, ruleTypes);
            String action = (String)ruleTypes.get("action");
            if((action != null) && (! action.equals(""))){
                ruleConfig.createActionConfig(action);
            }
        }catch (Exception ex){
            throw new Exception(ex);
        }
    }
View Full Code Here

        if ( mbeanName == null )
        {
            throw new IllegalArgumentException();
        }
           
      final ManagementRuleConfig  ruleConfig  =
          (ManagementRuleConfig)getFactoryContainer();
       
        ActionConfig actionConfig = ruleConfig.getActionConfig();
        if ( actionConfig != null )
        {
            throw new IllegalStateException( "action already exists as " +
                        actionConfig.getName() + ", " + actionConfig.getActionMBeanName());
        }
       
      final String ruleName   = ruleConfig.getName();
        getOldManagementRules().addActionToManagementRule( ruleName, mbeanName );
     
      // wait till AMX version makes its appearance
        // This is clumsy, but unfortunately the MBean name is not returned by addActionToManagementRule()
      while ( (actionConfig = ruleConfig.getActionConfig()) == null )
      {
          sleepMillis( 10 );
      }
     
      final ObjectName    amxObjectName   = Util.getObjectName( actionConfig );
View Full Code Here

        List obj = (List) handlerCtx.getInputValue("selectedRows");
        List<Map> selectedRows = (List) obj;
        try{
            for(Map oneRow : selectedRows){
                String name = (String)oneRow.get("name");
                ManagementRuleConfig ruleConfig = mgRulesConfig.getManagementRuleConfigMap().get(name);
                ruleConfig.setEnabled(enable);
            }
        }catch(Exception ex){
           GuiUtil.handleException(handlerCtx, ex);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.appserv.management.config.ManagementRuleConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.