1 21 22 package com.sun.enterprise.config.serverbeans.validation.tests; 23 24 import com.sun.enterprise.config.serverbeans.validation.GenericValidator; 25 import com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor; 26 import com.sun.enterprise.config.serverbeans.validation.ValidationContext; 27 import com.sun.enterprise.config.serverbeans.validation.AttrType; 28 import com.sun.enterprise.config.serverbeans.validation.AttrString; 29 import com.sun.enterprise.config.serverbeans.validation.Result; 30 31 import com.sun.enterprise.config.serverbeans.J2eeApplication; 32 33 import com.sun.enterprise.config.ConfigBean; 34 import com.sun.enterprise.config.ConfigContext; 35 import com.sun.enterprise.config.ConfigContextEvent; 36 import com.sun.enterprise.config.ConfigException; 37 import com.sun.enterprise.config.serverbeans.ManagementRule; 38 import com.sun.enterprise.config.serverbeans.Event; 39 import java.util.logging.Level ; 40 import java.util.Arrays ; 41 import java.util.List ; 42 43 public class ManagementRuleTest extends GenericValidator { 44 45 public ManagementRuleTest(ValidationDescriptor desc) { 46 super(desc); 47 } 48 49 final static List EVENT_TYPES= 50 Arrays.asList("log","timer","trace","monitor","cluster", "lifecycle","notification"); 51 final static List LOG_LEVELS= 52 Arrays.asList("FINEST","FINER","FINE","CONFIG","INFO","WARNING","SEVERE","OFF"); 53 54 public void validateElement(ValidationContext valCtx) 55 { 56 super.validateElement(valCtx); 57 58 if( (valCtx.isADD() || valCtx.isSET()) && 61 valCtx.value instanceof ManagementRule) 62 { 63 try { 64 Event event = ((ManagementRule)valCtx.value).getEvent(); 65 if(!EVENT_TYPES.contains(event.getType())) 67 valCtx.result.failed(smh.getLocalString(getClass().getName(), 68 valCtx.smh.getLocalString(getClass().getName() + ".wrongEventType", 69 "Value {0} is not allowed for Event type", new Object [] {event.getType()}))); 70 if(!LOG_LEVELS.contains(event.getLevel())) 72 valCtx.result.failed(smh.getLocalString(getClass().getName(), 73 valCtx.smh.getLocalString(getClass().getName() + ".wrongEventLevel", 74 "Value {0} is not allowed for Event log level", new Object [] {event.getLevel()}))); 75 } catch (Exception e) {} 76 77 } 78 } 79 80 81 } 82 | Popular Tags |