1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Map ; 26 27 import com.sun.appserv.management.base.Container; 28 import com.sun.appserv.management.base.XTypes; 29 30 import com.sun.appserv.management.config.AMXConfig; 31 import com.sun.appserv.management.config.DomainConfig; 32 import com.sun.appserv.management.config.JNDIResourceConfig; 33 34 import com.sun.appserv.management.helper.RefHelper; 35 36 38 public final class JNDIResourceConfigTest extends ResourceConfigTestBase 39 { 40 private static final String JNDI_RESOURCE_JNDI_LOOKUP_NAME = "jndi/jndiTest"; 41 private static final String JNDI_RESOURCE_RES_TYPE = "javax.sql.DataSource"; 42 private static final String JNDI_RESOURCE_FACTORY_CLASS = "com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl"; 43 private static final Map <String ,String > OPTIONAL = null; 44 45 public 46 JNDIResourceConfigTest () 47 { 48 if ( checkNotOffline( "ensureDefaultInstance" ) ) 49 { 50 ensureDefaultInstance( getDomainConfig() ); 51 } 52 } 53 54 public static String 55 getDefaultInstanceName() 56 { 57 return getDefaultInstanceName( "JNDIResourceConfig" ); 58 } 59 60 public static JNDIResourceConfig 61 ensureDefaultInstance( final DomainConfig dc ) 62 { 63 JNDIResourceConfig result = 64 dc.getJNDIResourceConfigMap().get( getDefaultInstanceName() ); 65 66 if ( result == null ) 67 { 68 result = createInstance( dc, 69 getDefaultInstanceName(), 70 JNDI_RESOURCE_JNDI_LOOKUP_NAME, 71 JNDI_RESOURCE_RES_TYPE, 72 JNDI_RESOURCE_FACTORY_CLASS, 73 OPTIONAL ); 74 } 75 76 return result; 77 } 78 79 public static JNDIResourceConfig 80 createInstance( 81 final DomainConfig dc, 82 final String name, 83 final String jndiLookupName, 84 final String resType, 85 final String factoryClass, 86 final Map <String ,String > optional) 87 { 88 return dc.createJNDIResourceConfig( 89 name, jndiLookupName, resType, factoryClass , optional ); 90 } 91 92 93 protected Container 94 getProgenyContainer() 95 { 96 return getDomainConfig(); 97 } 98 99 protected String 100 getProgenyJ2EEType() 101 { 102 return XTypes.JNDI_RESOURCE_CONFIG; 103 } 104 105 106 protected void 107 removeProgeny( final String name ) 108 { 109 final JNDIResourceConfig item = 110 getDomainConfig().getJNDIResourceConfigMap().get( name ); 111 112 getDomainConfig().removeJNDIResourceConfig( name ); 113 } 114 115 protected final AMXConfig 116 createProgeny(final String name, final Map <String ,String > options) 117 { 118 final JNDIResourceConfig config = getDomainConfig().createJNDIResourceConfig( name, 119 JNDI_RESOURCE_JNDI_LOOKUP_NAME, 120 JNDI_RESOURCE_RES_TYPE, 121 JNDI_RESOURCE_FACTORY_CLASS, 122 options ); 123 124 addReference( config ); 125 126 return( config ); 127 } 128 } 129 130 131 | Popular Tags |