1 23 24 29 30 31 package com.sun.enterprise.management.config; 32 33 import java.util.Set ; 34 import java.util.Map ; 35 import java.util.Collections ; 36 37 import javax.management.ObjectName ; 38 import javax.management.AttributeList ; 39 40 import com.sun.appserv.management.util.misc.GSetUtil; 41 42 import com.sun.appserv.management.config.JDBCConnectionPoolConfigKeys; 43 import com.sun.appserv.management.config.ResourceConfigKeys; 44 45 48 49 public final class JDBCConnectionPoolConfigFactory extends ResourceFactoryImplBase 50 { 51 public 52 JDBCConnectionPoolConfigFactory( final ConfigFactoryCallback callbacks ) 53 { 54 super( callbacks ); 55 } 56 57 private final Set <String > LEGAL_OPTIONAL_KEYS = 58 GSetUtil.newUnmodifiableStringSet( 59 JDBCConnectionPoolConfigKeys.CONNECTION_VALIDATION_METHOD_KEY, 60 JDBCConnectionPoolConfigKeys.VALIDATION_TABLE_NAME_KEY, 61 JDBCConnectionPoolConfigKeys.FAIL_ALL_CONNECTIONS_KEY, 62 JDBCConnectionPoolConfigKeys.IDLE_TIMEOUT_IN_SECONDS_KEY, 63 JDBCConnectionPoolConfigKeys.IS_CONNECTION_VALIDATION_REQUIRED_KEY, 64 JDBCConnectionPoolConfigKeys.IS_ISOLATION_LEVEL_GUARANTEED_KEY, 65 JDBCConnectionPoolConfigKeys.TRANSACTION_ISOLATION_LEVEL_KEY, 66 JDBCConnectionPoolConfigKeys.MAX_POOL_SIZE_KEY, 67 JDBCConnectionPoolConfigKeys.MAX_WAIT_TIME_MILLIS_KEY, 68 JDBCConnectionPoolConfigKeys.POOL_RESIZE_QUANTITY_KEY, 69 JDBCConnectionPoolConfigKeys.RES_TYPE_KEY, 70 JDBCConnectionPoolConfigKeys.STEADY_POOL_SIZE_KEY, 71 JDBCConnectionPoolConfigKeys.DATABASE_NAME_KEY, 72 JDBCConnectionPoolConfigKeys.DATABASE_USER_KEY, 73 JDBCConnectionPoolConfigKeys.DATABASE_PASSWORD_KEY ); 74 75 protected Set <String > 76 getLegalOptionalCreateKeys() 77 { 78 return( LEGAL_OPTIONAL_KEYS ); 79 } 80 81 82 85 protected ObjectName 86 createOldChildConfig( 87 final AttributeList translatedAttrs ) 88 { 89 trace( "JDBCConnectionPoolConfigFactory.createOldChildConfig: creating using: " + 90 stringify( translatedAttrs ) ); 91 92 final ObjectName objectName = 93 getOldResourcesMBean().createJdbcConnectionPool( translatedAttrs ); 94 95 return( objectName ); 96 } 97 98 99 108 public ObjectName 109 create( 110 final String name, 111 final String datasourceClassname, 112 final Map <String ,String > optional) 113 { 114 final String [] requiredParams = new String [] 115 { 116 JDBCConnectionPoolConfigKeys.DATASOURCE_CLASSNAME_KEY, datasourceClassname, 117 }; 118 119 final Map <String ,String > params = initParams( name, requiredParams, optional ); 120 121 final ObjectName amxName = createNamedChild( name, params ); 122 123 return( amxName ); 124 } 125 126 127 public ObjectName 128 create( 129 final String name, 130 final String connectionValidationMethod, 131 final String datasourceClassname, 132 final boolean failAllConnections, 133 final int idleTimeoutSeconds, 134 final boolean connectionValidationRequired, 135 final boolean isolationLevelGuaranteed, 136 final String transactionIsolationLevel, 137 final int maxPoolSize, 138 final int maxWaitTimeMillis, 139 final int poolResizeQuantity, 140 final String resType, 141 final int steadyPoolSize, 142 final String databaseName, 143 final String databaseUserName, 144 final String databasePassword, 145 final Map <String ,String > reserved ) 146 { 147 final Map <String ,String > optionalParams = new java.util.HashMap <String ,String >(); 148 optionalParams.put(JDBCConnectionPoolConfigKeys.CONNECTION_VALIDATION_METHOD_KEY,connectionValidationMethod); 149 optionalParams.put(JDBCConnectionPoolConfigKeys.FAIL_ALL_CONNECTIONS_KEY,Boolean.toString(failAllConnections)); 150 optionalParams.put(JDBCConnectionPoolConfigKeys.IDLE_TIMEOUT_IN_SECONDS_KEY,Integer.toString(idleTimeoutSeconds)); 151 optionalParams.put(JDBCConnectionPoolConfigKeys.IS_CONNECTION_VALIDATION_REQUIRED_KEY,Boolean.toString(connectionValidationRequired)); 152 optionalParams.put(JDBCConnectionPoolConfigKeys.IS_ISOLATION_LEVEL_GUARANTEED_KEY,Boolean.toString(isolationLevelGuaranteed)); 153 optionalParams.put(JDBCConnectionPoolConfigKeys.TRANSACTION_ISOLATION_LEVEL_KEY, transactionIsolationLevel); 154 optionalParams.put(JDBCConnectionPoolConfigKeys.MAX_POOL_SIZE_KEY,Integer.toString(maxPoolSize)); 155 optionalParams.put(JDBCConnectionPoolConfigKeys.MAX_WAIT_TIME_MILLIS_KEY,Integer.toString(maxWaitTimeMillis)); 156 optionalParams.put(JDBCConnectionPoolConfigKeys.POOL_RESIZE_QUANTITY_KEY,Integer.toString(poolResizeQuantity)); 157 optionalParams.put(JDBCConnectionPoolConfigKeys.RES_TYPE_KEY,resType); 158 optionalParams.put(JDBCConnectionPoolConfigKeys.STEADY_POOL_SIZE_KEY,Integer.toString(steadyPoolSize)); 159 optionalParams.put(JDBCConnectionPoolConfigKeys.DATABASE_NAME_KEY,databaseName); 160 optionalParams.put(JDBCConnectionPoolConfigKeys.DATABASE_USER_KEY,databaseUserName); 161 optionalParams.put(JDBCConnectionPoolConfigKeys.DATABASE_PASSWORD_KEY,databasePassword); 162 163 optionalParams.putAll( reserved ); 164 165 final ObjectName amxName = create( name, datasourceClassname, optionalParams); 166 return( amxName ); 167 } 168 169 protected void 170 removeByName( final String name ) 171 { 172 getOldResourcesMBean().removeJdbcConnectionPoolByName( name ); 173 } 174 175 } 176 177 | Popular Tags |