1 23 24 29 package com.sun.enterprise.management.config; 30 31 import java.util.Map ; 32 import java.util.Set ; 33 import java.util.Collections ; 34 35 import javax.management.ObjectName ; 36 import javax.management.AttributeList ; 37 38 import com.sun.appserv.management.config.HTTPListenerConfigKeys; 39 import com.sun.appserv.management.config.HTTPServiceConfig; 40 import com.sun.appserv.management.config.VirtualServerConfig; 41 42 import com.sun.appserv.management.util.misc.MapUtil; 43 44 import com.sun.enterprise.management.support.oldconfig.OldHTTPServiceMBean; 45 46 import com.sun.appserv.management.util.misc.GSetUtil; 47 48 public final class HTTPListenerConfigFactory extends ConfigFactory 49 { 50 private final OldHTTPServiceMBean mOldHTTPServiceMBean; 51 52 public 53 HTTPListenerConfigFactory( final ConfigFactoryCallback callbacks ) 54 { 55 super( callbacks ); 56 57 mOldHTTPServiceMBean = 58 getOldConfigProxies().getOldHTTPServiceMBean( getConfigName() ); 59 } 60 61 62 private final Set <String > LEGAL_OPTIONAL_KEYS = 63 GSetUtil.newUnmodifiableStringSet( 64 HTTPListenerConfigKeys.ADDRESS_KEY, 65 HTTPListenerConfigKeys.PORT_KEY, 66 HTTPListenerConfigKeys.ENABLED_KEY, 67 HTTPListenerConfigKeys.SECURITY_ENABLED_KEY, 68 HTTPListenerConfigKeys.DEFAULT_VIRTUAL_SERVER_KEY, 69 HTTPListenerConfigKeys.ACCEPTOR_THREADS_KEY, 70 HTTPListenerConfigKeys.XPOWERED_BY_KEY, 71 HTTPListenerConfigKeys.XPOWERED_BY_KEY, 72 HTTPListenerConfigKeys.IGNORE_MISSING_REFERENCES_KEY ); 73 74 protected Set <String > 75 getLegalOptionalCreateKeys() 76 { 77 return( LEGAL_OPTIONAL_KEYS ); 78 } 79 80 protected Map <String ,String > 81 getParamNameOverrides() 82 { 83 return( MapUtil.newMap( CONFIG_NAME_KEY, "id" ) ); 84 } 85 86 protected ObjectName 87 createOldChildConfig( final AttributeList translatedAttrs ) 88 { 89 return mOldHTTPServiceMBean.createHttpListener( translatedAttrs ); 90 } 91 92 93 private void 94 checkVirtualServerExists( final String virtualServerName ) 95 { 96 final HTTPServiceConfig httpService = (HTTPServiceConfig)getFactoryContainer(); 97 98 final Map <String ,VirtualServerConfig> virtualServers = 99 httpService.getVirtualServerConfigMap(); 100 101 if( ! virtualServers.containsKey( virtualServerName ) ) 102 { 103 throw new IllegalArgumentException ( "No virtual server exists with the name: " + virtualServerName ); 104 } 105 } 106 107 108 public ObjectName 109 create( 110 final String name, 111 final String address, 112 final int port, 113 final String defaultVirtualServer, 114 final String serverName, 115 final Map <String ,String > options ) 116 { 117 final String [] requiredParams = 118 { 119 HTTPListenerConfigKeys.ADDRESS_KEY, address, 120 HTTPListenerConfigKeys.PORT_KEY, "" + port, 121 HTTPListenerConfigKeys.DEFAULT_VIRTUAL_SERVER_KEY, defaultVirtualServer, 122 HTTPListenerConfigKeys.SERVER_NAME_KEY, serverName, 123 }; 124 125 if ( requireValidReferences( options ) ) 126 { 127 checkVirtualServerExists( defaultVirtualServer ); 128 } 129 130 final Map <String ,String > params = initParams( name, requiredParams, options ); 131 132 final ObjectName amxName = createNamedChild( name, params ); 133 134 return( amxName ); 135 } 136 137 protected final void 138 removeByName( String name ) 139 { 140 mOldHTTPServiceMBean.removeHttpListenerById( name ); 141 } 142 } 143 144 145 146 147 148 149 | Popular Tags |