1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 import java.util.Map ; 27 import java.util.Collections ; 28 29 import javax.management.ObjectName ; 30 import javax.management.AttributeList ; 31 32 33 import com.sun.appserv.management.base.XTypes; 34 35 import com.sun.appserv.management.util.misc.MapUtil; 36 import com.sun.appserv.management.util.misc.GSetUtil; 37 38 import com.sun.appserv.management.config.PersistenceManagerFactoryResourceConfigKeys; 39 import com.sun.appserv.management.config.ResourceRefConfig; 40 41 44 public final class PersistenceManagerFactoryResourceConfigFactory extends ResourceFactoryImplBase 45 { 46 public 47 PersistenceManagerFactoryResourceConfigFactory( final ConfigFactoryCallback callbacks ) 48 { 49 super( callbacks ); 50 } 51 52 private final Set <String > LEGAL_OPTIONAL_KEYS = 53 GSetUtil.newUnmodifiableStringSet( 54 PersistenceManagerFactoryResourceConfigKeys.FACTORY_CLASS_KEY, 55 PersistenceManagerFactoryResourceConfigKeys.JDBC_RESOURCE_JNDI_NAME_KEY ); 56 57 protected Set <String > 58 getLegalOptionalCreateKeys() 59 { 60 return( LEGAL_OPTIONAL_KEYS ); 61 } 62 63 64 67 protected ObjectName 68 createOldChildConfig( 69 final AttributeList translatedAttrs ) 70 { 71 final ObjectName objectName = 72 getOldResourcesMBean().createPersistenceManagerFactoryResource( translatedAttrs ); 73 74 return( objectName ); 75 } 76 77 protected Map <String ,String > 78 getParamNameOverrides() 79 { 80 return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) ); 81 } 82 83 84 90 public ObjectName 91 create( final String jndiName, final Map <String ,String > optional) 92 { 93 final String [] requiredParams = new String []{}; 94 final Map <String ,String > params = initParams( jndiName, requiredParams, optional ); 95 final ObjectName amxName = createNamedChild( jndiName, params ); 96 return( amxName ); 97 } 98 99 protected void 100 removeByName( final String name ) 101 { 102 final Set <ResourceRefConfig> refs = 103 findAllRefConfigs( XTypes.PERSISTENCE_MANAGER_FACTORY_RESOURCE_CONFIG, name ); 104 105 if ( refs.size() == 0 ) 106 { 107 getOldResourcesMBean().removePersistenceManagerFactoryResourceByJndiName( name ); 108 } 109 else 110 { 111 for( final ResourceRefConfig ref : refs ) 112 { 113 final String target = ref.getContainer().getName(); 114 getOldResourcesMBean().deletePersistenceManagerFactoryResource( name, target ); 115 } 116 } 117 } 118 119 } 120 121 | Popular Tags |