1 23 24 26 27 28 package com.sun.enterprise.management.config; 29 30 import java.util.Set ; 31 import java.util.Map ; 32 33 import javax.management.AttributeList ; 34 import javax.management.ObjectName ; 35 36 import com.sun.appserv.management.base.Util; 37 import com.sun.appserv.management.config.AMXConfig; 38 import com.sun.appserv.management.config.ServerRefConfigCR; 39 import com.sun.appserv.management.config.ClusterConfig; 40 import com.sun.appserv.management.config.LBConfig; 41 42 import com.sun.appserv.management.util.misc.MapUtil; 43 import com.sun.appserv.management.util.misc.GSetUtil; 44 45 import com.sun.enterprise.management.support.oldconfig.OldLbConfig; 46 import com.sun.enterprise.management.support.oldconfig.OldClusterMBean; 47 import com.sun.enterprise.management.support.oldconfig.OldCreateRemoveServerRef; 48 49 50 final class ServerRefConfigFactory extends ConfigFactory 51 { 52 public ServerRefConfigFactory(final ConfigFactoryCallback callbacks) 53 { 54 super( callbacks ); 55 } 56 57 protected Map <String ,String > 58 getParamNameOverrides() 59 { 60 return( MapUtil.newMap( CONFIG_NAME_KEY, "ref" ) ); 61 } 62 63 private final Set <String > LEGAL_OPTIONAL_KEYS = 64 GSetUtil.newUnmodifiableStringSet( 65 ServerRefConfigCR.DISABLE_TIMEOUT_IN_MINUTES_KEY, 66 ServerRefConfigCR.LB_ENABLED_KEY, 67 ServerRefConfigCR.ENABLED_KEY ); 68 69 protected Set <String > getLegalOptionalCreateKeys() { 70 return( LEGAL_OPTIONAL_KEYS ); 71 } 72 73 private OldCreateRemoveServerRef 74 getOldCreateRemoveServerRef() 75 { 76 final ServerRefConfigCR fc = (ServerRefConfigCR)getFactoryContainer(); 77 final String name = Util.asAMX( fc ).getName(); 78 79 OldCreateRemoveServerRef result = null; 80 if ( fc instanceof ClusterConfig ) 81 { 82 result = getOldConfigProxies().getOldClusterMBean( name ); 83 } 84 else if ( fc instanceof LBConfig ) 85 { 86 result = getOldConfigProxies().getOldLbConfig( name ); 87 } 88 89 return result; 90 } 91 92 protected ObjectName 93 createOldChildConfig( final AttributeList translatedAttrs ) 94 { 95 return getOldCreateRemoveServerRef().createServerRef(translatedAttrs); 96 } 97 98 public ObjectName 99 create( 100 final String referencedServerName, 101 final Map <String ,String > optional) 102 { 103 final String [] requiredParams = new String [] {}; 104 105 final Map <String ,String > params = 106 initParams(referencedServerName, requiredParams, optional); 107 108 final ObjectName amxName = createNamedChild(referencedServerName, params ); 109 110 return( amxName ); 111 } 112 113 public ObjectName 114 create( 115 final String referencedServerName, 116 final String disableTimeoutInMinutes, 117 final boolean lbEnabled, 118 final boolean enabled) 119 { 120 final Map <String ,String > optionalParams = new java.util.HashMap <String ,String >(); 121 optionalParams.put( ServerRefConfigCR.DISABLE_TIMEOUT_IN_MINUTES_KEY,disableTimeoutInMinutes); 122 optionalParams.put( ServerRefConfigCR.LB_ENABLED_KEY,Boolean.toString(lbEnabled)); 123 optionalParams.put( ServerRefConfigCR.ENABLED_KEY,Boolean.toString(enabled)); 124 125 return create(referencedServerName, optionalParams); 126 } 127 128 public void removeByName(final String referencedServerName) 129 { 130 getOldCreateRemoveServerRef().removeServerRefByRef(referencedServerName); 131 } 132 } 133 134 135 136 | Popular Tags |