1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 import java.util.Map ; 27 import java.io.IOException ; 28 29 import javax.management.ObjectName ; 30 import javax.management.AttributeList ; 31 32 import com.sun.appserv.management.config.JDBCResourceConfig; 33 import com.sun.appserv.management.config.JDBCConnectionPoolConfig; 34 import com.sun.appserv.management.config.ResourceRefConfig; 35 36 import com.sun.appserv.management.util.misc.MapUtil; 37 import com.sun.appserv.management.base.XTypes; 38 39 42 43 public final class JDBCResourceConfigFactory extends ResourceFactoryImplBase 44 { 46 public 47 JDBCResourceConfigFactory( final ConfigFactoryCallback callbacks ) 48 { 49 super( callbacks ); 50 } 51 52 53 56 protected ObjectName 57 createOldChildConfig( 58 final AttributeList translatedAttrs ) 59 { 60 trace( "JDBCResourceConfigFactory.createOldChildConfig: creating using: " + 61 stringify( translatedAttrs ) ); 62 63 final ObjectName objectName = 64 getOldResourcesMBean().createJdbcResource( translatedAttrs ); 65 66 return( objectName ); 67 } 68 69 protected Map <String ,String > 70 getParamNameOverrides() 71 { 72 return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) ); 73 } 74 75 76 public static final String POOL_NAME_KEY = "PoolName"; 77 78 85 public ObjectName create( 86 final String jndiName, 87 final String poolName, 88 final Map <String ,String > optional ) 89 { 90 final JDBCConnectionPoolConfig pool = (JDBCConnectionPoolConfig) 91 getCallbacks().getProxyFactory().getDomainRoot().getDomainConfig(). 92 getContainee( XTypes.JDBC_CONNECTION_POOL_CONFIG, poolName ); 93 if ( pool == null ) 94 { 95 throw new IllegalArgumentException ( "JDBCConnectionPoolConfig does not exit: " + poolName ); 96 } 97 98 final String [] requiredParams = new String [] 99 { 100 POOL_NAME_KEY, poolName, 101 }; 102 103 final Map <String ,String > params = initParams( jndiName, requiredParams, optional ); 104 105 final ObjectName amxName = createNamedChild( jndiName, params ); 106 return( amxName ); 107 } 108 109 protected void 110 removeByName( final String name ) 111 { 112 final Set <ResourceRefConfig> refs = 113 findAllRefConfigs( XTypes.JDBC_RESOURCE_CONFIG, name ); 114 115 if ( refs.size() == 0 ) 116 { 117 getOldResourcesMBean().removeJdbcResourceByJndiName( name ); 118 } 119 else 120 { 121 for( final ResourceRefConfig ref : refs ) 122 { 123 final String target = ref.getContainer().getName(); 124 getOldResourcesMBean().deleteJdbcResource( name, target ); 125 } 126 } 127 } 128 129 } 130 131 | Popular Tags |