1 23 24 29 package com.sun.enterprise.management.config; 30 31 import java.util.Map ; 32 import java.util.Properties ; 33 import java.util.Set ; 34 import java.util.Collections ; 35 36 import javax.management.ObjectName ; 37 import javax.management.AttributeList ; 38 39 import com.sun.enterprise.management.support.oldconfig.OldConfigProxies; 40 import com.sun.enterprise.management.support.oldconfig.OldHTTPServiceMBean; 41 import com.sun.enterprise.management.support.oldconfig.OldConfigsMBean; 42 43 import com.sun.appserv.management.base.XTypes; 44 import com.sun.appserv.management.base.Util; 45 46 import com.sun.appserv.management.config.VirtualServerConfigKeys; 47 48 import com.sun.appserv.management.util.misc.MapUtil; 49 import com.sun.appserv.management.util.misc.GSetUtil; 50 51 import com.sun.enterprise.management.support.WebModuleSupport; 52 53 54 55 57 public final class VirtualServerConfigFactory extends ConfigFactory 58 { 59 62 public 63 VirtualServerConfigFactory( final ConfigFactoryCallback callbacks ) 64 { 65 super( callbacks ); 66 } 67 68 private final Set <String > LEGAL_OPTIONAL_KEYS = 69 GSetUtil.newUnmodifiableStringSet( 70 VirtualServerConfigKeys.HTTP_LISTENERS_KEY, 71 VirtualServerConfigKeys.STATE_KEY, 72 VirtualServerConfigKeys.DOC_ROOT_PROPERTY_KEY, 73 VirtualServerConfigKeys.ACCESS_LOG_PROPERTY_KEY 74 ); 75 76 protected Set <String > 77 getLegalOptionalCreateKeys() 78 { 79 return( LEGAL_OPTIONAL_KEYS ); 80 } 81 82 83 protected Map <String ,String > 84 getParamNameOverrides() 85 { 86 return( MapUtil.newMap( CONFIG_NAME_KEY, "id" ) ); 87 } 88 89 92 protected ObjectName 93 createOldChildConfig( 94 final AttributeList translatedAttrs, final Properties props ) 95 { 96 final String target = getConfigName(); 97 98 final OldConfigsMBean oldConfigsMBean = 99 getOldConfigProxies().getOldConfigsMBean(); 100 101 trace( "VirtualServerConfigFactory.createOldChildConfig: creating using: " + 102 stringify( translatedAttrs ) ); 103 104 final ObjectName objectName = 105 oldConfigsMBean.createVirtualServer( translatedAttrs, props, target ); 106 107 return( objectName ); 108 } 109 110 public final static String HOSTS_KEY = "Hosts"; 111 112 126 public ObjectName 127 create( 128 final String name, 129 final String hosts, 130 final Map <String ,String > optional ) 131 { 132 final String [] requiredParams = new String [] 133 { 134 HOSTS_KEY, hosts, 135 }; 136 137 if ( ! WebModuleSupport.isLegalVirtualServerName( name ) ) 139 { 140 throw new IllegalArgumentException ( name ); 141 } 142 143 final Map <String ,String > params = initParams( name, requiredParams, optional ); 144 145 final ObjectName amxName = createNamedChild( name, params ); 146 147 return( amxName ); 148 } 149 150 public void 151 internalRemove( final ObjectName objectName ) 152 { 153 final OldHTTPServiceMBean oldHTTPServer = 155 getOldConfigProxies().getOldHTTPServiceMBean( getConfigName() ); 156 157 final String name = Util.getName( objectName ); 159 oldHTTPServer.removeVirtualServerById( name ); 160 } 161 } 162 163 164 165 166 | Popular Tags |