1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 import java.util.Map ; 27 28 import javax.management.AttributeList ; 29 import javax.management.ObjectName ; 30 31 import com.sun.appserv.management.base.XTypes; 32 33 import com.sun.appserv.management.config.JNDIResourceConfig; 34 import com.sun.appserv.management.config.ResourceRefConfig; 35 36 import com.sun.appserv.management.helper.RefHelper; 37 38 import com.sun.appserv.management.util.misc.MapUtil; 39 40 41 44 45 public final class JNDIResourceConfigFactory extends ResourceFactoryImplBase 46 { 47 public 48 JNDIResourceConfigFactory( final ConfigFactoryCallback callbacks ) 49 { 50 super( callbacks ); 51 } 52 53 private static final String JNDI_LOOKUP_NAME_KEY = "JNDILookupName"; 54 private static final String FACTORY_CLASS_KEY = "FactoryClass"; 55 private static final String RES_TYPE_KEY = "ResType"; 56 57 58 61 protected ObjectName 62 createOldChildConfig( 63 final AttributeList translatedAttrs ) 64 { 65 66 trace( "JNDIResourceConfigFactory.createOldChildConfig: creating using: " + 67 stringify( translatedAttrs ) ); 68 69 final ObjectName objectName = 70 getOldResourcesMBean().createExternalJndiResource( translatedAttrs ); 71 72 return( objectName ); 73 } 74 75 protected Map <String ,String > 76 getParamNameOverrides() 77 { 78 return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) ); 79 } 80 81 90 public ObjectName 91 create( String jndiName, 92 String jndiLookupName, 93 String resType, 94 String factoryClass, 95 Map <String ,String > optional) 96 { 97 final String [] requiredParams = new String [] 98 { 99 JNDI_LOOKUP_NAME_KEY, jndiLookupName, 100 RES_TYPE_KEY, resType, 101 FACTORY_CLASS_KEY, factoryClass, 102 }; 103 104 final Map <String ,String > params = initParams( jndiName, requiredParams, optional ); 105 106 final ObjectName amxName = createNamedChild( jndiName, params ); 107 108 return( amxName ); 109 } 110 111 112 protected void 113 removeByName( final String name ) 114 { 115 final Set <ResourceRefConfig> refs = 116 findAllRefConfigs( XTypes.JNDI_RESOURCE_CONFIG, name ); 117 118 if ( refs.size() == 0 ) 119 { 120 getOldResourcesMBean().removeExternalJndiResourceByJndiName( name ); 121 } 122 else 123 { 124 for( final ResourceRefConfig ref : refs ) 125 { 126 final String target = ref.getContainer().getName(); 127 getOldResourcesMBean().deleteExternalJndiResource( name, target ); 128 } 129 } 130 } 131 } 132 133 | Popular Tags |