1 23 24 29 package com.sun.enterprise.management.config; 30 31 import java.util.Set ; 32 import java.util.HashSet ; 33 import java.util.Iterator ; 34 import java.util.Map ; 35 import java.util.HashMap ; 36 import java.util.Properties ; 37 import java.util.Collections ; 38 39 import static com.sun.appserv.management.base.XTypes.SERVER_REF_CONFIG; 40 import static com.sun.appserv.management.base.XTypes.CLUSTER_REF_CONFIG; 41 import javax.management.Attribute ; 42 import javax.management.AttributeList ; 43 import javax.management.ObjectName ; 44 45 import com.sun.appserv.management.util.misc.GSetUtil; 46 import static com.sun.appserv.management.config.HealthCheckerConfigKeys.*; 47 48 final class HealthCheckerConfigFactory extends ConfigFactory { 49 50 public HealthCheckerConfigFactory(final ConfigFactoryCallback callbacks) { 51 super( callbacks ); 52 } 53 54 private final Set <String > LEGAL_OPTIONAL_KEYS = 55 GSetUtil.newUnmodifiableStringSet( 56 URL_KEY, 57 INTERVAL_IN_SECONDS_KEY, 58 TIMEOUT_IN_SECONDS_KEY); 59 60 protected Set <String > getLegalOptionalCreateKeys() { 61 return(LEGAL_OPTIONAL_KEYS); 62 } 63 64 protected ObjectName createOldChildConfig(final AttributeList translatedAttrs) { 65 final String containerName = getFactoryContainer().getName(); 66 if (getFactoryContainer().getJ2EEType().equals(CLUSTER_REF_CONFIG)) { 67 return getOldConfigProxies().getOldClusterRefMBean( 68 containerName).createHealthChecker(translatedAttrs); 69 } else if (getFactoryContainer().getJ2EEType().equals(SERVER_REF_CONFIG)) { 70 return getOldConfigProxies().getOldServerRefMBean( 71 containerName).createHealthChecker(translatedAttrs); 72 } 73 return null; 74 } 75 76 public ObjectName create(String url, String intervalInSeconds, String timeoutInSeconds) 77 { 78 Map <String ,String > optional = new HashMap <String ,String >(); 79 optional.put(URL_KEY, url); 80 optional.put(INTERVAL_IN_SECONDS_KEY, intervalInSeconds); 81 optional.put(TIMEOUT_IN_SECONDS_KEY, timeoutInSeconds); 82 83 final Map <String ,String > params = initParams(optional); 84 final ObjectName amxName = createChild(params); 85 return amxName; 86 } 87 88 public void remove(String name) { 89 final String containerName = getFactoryContainer().getName(); 90 if (getFactoryContainer().getJ2EEType().equals(CLUSTER_REF_CONFIG)) { 91 getOldConfigProxies().getOldClusterRefMBean(containerName).removeHealthChecker(); 92 } else if (getFactoryContainer().getJ2EEType().equals(SERVER_REF_CONFIG)) { 93 getOldConfigProxies().getOldServerRefMBean(containerName).removeHealthChecker(); 94 } 95 } 96 } | Popular Tags |