Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.ManagementRule


            String  eventDescription,  
            Properties eventProperties,
            String  actionMbeanName
        throws Exception
{
    ManagementRule  newRule = new ManagementRule();
    //Rule attrs
    newRule.setName(ruleName);
    if(ruleDescription!=null)
       newRule.setDescription(ruleDescription);
    if(bRuleEnabled!=null)
       newRule.setEnabled(bRuleEnabled.booleanValue());
    //Event
    Event event = new Event();
    event.setType(eventType);
    if(eventRecordEvent!=null)
       event.setRecordEvent(eventRecordEvent.booleanValue());
    if(eventLevel!=null)
       event.setLevel(eventLevel);
    if(eventDescription!=null)
       event.setDescription(eventDescription);
    //Event properties
    if (null != eventProperties)
        {
            Enumeration keys = eventProperties.keys();
            while (keys.hasMoreElements())
            {
                final String key = (String)keys.nextElement();
                ElementProperty prop = new ElementProperty();
                prop.setName(key);
                prop.setValue((String)eventProperties.get(key));
                event.addElementProperty(prop);
            }
        }
    newRule.setEvent(event);
   
    //Action
    if(actionMbeanName!=null)
    {
        Action action = new Action();
        action.setActionMbeanName(actionMbeanName);
        newRule.setAction(action);
       
    }
    // insert new rule to config tree
    ManagementRules rules = (ManagementRules)getBaseConfigBean();
    rules.addManagementRule(newRule);
View Full Code Here


public void addActionToManagementRule(
            String  ruleName,           //required
            String  actionMbeanNamethrows ConfigException
{
    ManagementRules rules = (ManagementRules)getBaseConfigBean();
    ManagementRule  rule = rules.getManagementRuleByName(ruleName);
    Action action = new Action();
    action.setActionMbeanName(actionMbeanName);
    rule.setAction(action);
}
View Full Code Here

            ConfigContext configContext = event.getConfigContext();
            Config config = ServerBeansFactory.getConfigBean(configContext);
            ConfigAdd configAdd = null;
            ConfigChange configChange = null;
            ArrayList<ConfigChange> configChangeList = event.getConfigChangeList();
            ManagementRule rule = null;
            String xpath = null;
            String pXPath = null;
            Object object;
            String ruleName = null;
            for (int i=0; i < configChangeList.size(); i++){
                configChange = configChangeList.get(i);
                if (configChange instanceof ConfigAdd) {
                    _logger.log(Level.INFO,"sgmt.reconfig_handlecreaterulereceived");
                    xpath = configChange.getXPath();
                    if (xpath != null) {
                        _logger.log(Level.INFO, "sgmt.reconfig_handlexpath",xpath);
                        rule = (ManagementRule)configContext.exactLookup(xpath);
                        if (rule.isEnabled())
                            service.addRule(rule, configContext);
                        else
                            service.addDisabledRule(rule);
                      
                    }
View Full Code Here

                    object = configContext.exactLookup(xPath);
                    if (object instanceof ManagementRules) {
                        ManagementRules rules = (ManagementRules)object;
                        service.handleRulesUpdate(configContext,configUp);
                    } else if(object instanceof ManagementRule) {
                        ManagementRule rule = (ManagementRule)configContext.exactLookup(xPath);
                        service.handleRuleUpdate(rule,configUp,configContext);
                    } else {
                        String pXPath = null;
                        if(object instanceof ElementProperty ||
         xPath.lastIndexOf("element-property") >= ) {
                            pXPath = xPath.substring(0,xPath.lastIndexOf("/"));
                            if(pXPath != null) {
                                pXPath = pXPath.substring(0,pXPath.lastIndexOf("/"));
                            }
                        } else {
                            pXPath = xPath.substring(0,xPath.lastIndexOf("/"));
                        }
                        if(pXPath != null) {
                            ManagementRule rule = (ManagementRule)configContext.exactLookup(pXPath);
                            if(rule != null) {
                                String ruleName = rule.getName();

                                //Delete the rule (will delete the rule runtime)
                                service.deleteRule(ruleName);

                                //Recreate the rule
                                if (rule.isEnabled()) {
                                    service.addRule(rule, adminConfigCtx);
                                } else {
                                    service.addDisabledRule(rule);
                                }
                            }
View Full Code Here

                 AdminService.getAdminService().
                 getAdminContext().getAdminConfigContext();
            Config config = ServerBeansFactory.getConfigBean(adminConfigCtx);
            ConfigDelete configDel = null;
            ArrayList<ConfigDelete> configChangeList = event.getConfigChangeList();
            ManagementRule rule = null;
            String xpath = null;
            Object object;

            for (int i=0; i < configChangeList.size(); i++){
                configDel = configChangeList.get(i);

                xpath = configDel.getXPath();
                if (xpath != null){
                    _logger.log(Level.INFO, "sgmt.reconfig_handledelxpath",xpath);
        object = oldConfigContext.exactLookup(xpath);
                    if (object instanceof Action) {
                        //handle action removal - noaction
                        String realXPath = xpath.substring(0,xpath.lastIndexOf("/"));
                        rule = (ManagementRule) adminConfigCtx.exactLookup(realXPath);
                        String ruleName = rule.getName();
                        service.deleteAction(ruleName);
                    } else if (object instanceof ManagementRule) {
                        rule = (ManagementRule)object;
                        String ruleName = rule.getName();
                        service.deleteRule(ruleName);
                    } else {
                        String realXPath = xpath.substring(0,xpath.lastIndexOf("/"));
                        rule = (ManagementRule) adminConfigCtx.exactLookup(realXPath);
                        String ruleName = rule.getName();
                        service.deleteAction(ruleName);
        }
                }
            }
        }  catch( Exception ex){
View Full Code Here

                    isServiceEnabled = true;
                   
                    ManagementRule[] rules = selfManagementRules.getManagementRule();
                    if (rules != null) {
                        for (int i = 0; i < rules.length; i++) {
                            ManagementRule rule = rules[i];             
                            String ruleName = rule.getName();
                            String ruleDescription = rule.getDescription();
                       
                            //check if rule is enabled then obtain event else skip
                           if (rule.isEnabled()) {
                               // statically read ctx is used
                               addRule(rule,null);
                           } else {
                               _logger.log(Level.FINE, "smgt.service_rule_disabled",
                                       new Object[]{ruleName, ruleDescription});      
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.ManagementRule

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.