1 23 24 package com.sun.enterprise.management.config; 25 26 import java.util.Map ; 27 import java.util.Set ; 28 29 import javax.management.ObjectName ; 30 31 import com.sun.appserv.management.base.Container; 32 import com.sun.appserv.management.base.XTypes; 33 import com.sun.appserv.management.base.AMX; 34 import com.sun.appserv.management.base.Util; 35 36 import com.sun.appserv.management.config.AMXConfig; 37 import com.sun.appserv.management.config.DomainConfig; 38 import com.sun.appserv.management.config.ConnectorConnectionPoolConfig; 39 import com.sun.appserv.management.config.ConnectorResourceConfig; 40 import com.sun.appserv.management.config.ResourceRefConfig; 41 import com.sun.appserv.management.config.ResourceRefConfigCR; 42 43 import com.sun.appserv.management.util.misc.StringUtil; 44 import com.sun.appserv.management.util.misc.CollectionUtil; 45 46 import com.sun.appserv.management.helper.RefHelper; 47 48 50 public final class ConnectorResourceConfigTest extends ResourceConfigTestBase 51 { 52 public ConnectorResourceConfigTest() 53 { 54 if ( checkNotOffline( "ensureDefaultInstance" ) ) 55 { 56 ensureDefaultInstance( getDomainConfig() ); 57 } 58 } 59 60 public static String 61 getDefaultInstanceName() 62 { 63 return getDefaultInstanceName( "ConnectorResourceConfig" ); 64 } 65 66 public static ConnectorResourceConfig 67 ensureDefaultInstance( final DomainConfig domainConfig ) 68 { 69 ConnectorResourceConfig result = 70 domainConfig.getConnectorResourceConfigMap().get( getDefaultInstanceName() ); 71 72 final ConnectorConnectionPoolConfig connectorConnectionPool = 73 ConnectorConnectionPoolConfigTest.ensureDefaultInstance( domainConfig ); 74 75 if ( result == null ) 76 { 77 result = createInstance( domainConfig, 78 getDefaultInstanceName(), 79 connectorConnectionPool.getName(), null ); 80 } 81 82 return result; 83 } 84 85 public static ConnectorResourceConfig 86 createInstance( 87 final DomainConfig domainConfig, 88 final String name, 89 final String poolName, 90 final Map <String ,String > optional ) 91 { 92 return domainConfig.createConnectorResourceConfig( 93 name, poolName, optional ); 94 } 95 96 protected String 97 getProgenyTestName() 98 { 99 return( "jndi/ConnectorResourceConfigTest" ); 100 } 101 102 protected Container 103 getProgenyContainer() 104 { 105 return getDomainConfig(); 106 } 107 108 protected String 109 getProgenyJ2EEType() 110 { 111 return XTypes.CONNECTOR_RESOURCE_CONFIG; 112 } 113 114 115 protected void 116 removeProgeny( final String name ) 117 { 118 final Set <ResourceRefConfig> resourceRefs = 119 getQueryMgr().queryJ2EETypeNameSet(XTypes.RESOURCE_REF_CONFIG,name); 120 121 getDomainConfig().removeConnectorResourceConfig( name ); 122 } 123 124 125 protected final AMXConfig 126 createProgeny( final String name, final Map <String ,String > options ) 127 { 128 final String poolName = 129 ConnectorConnectionPoolConfigTest.ensureDefaultInstance( getDomainConfig() ).getName(); 130 131 assert( getDomainConfig().getConnectorResourceConfigMap().get( name ) == null ) : 132 "A resource already exists with name: " + name; 133 134 final Set <ResourceRefConfig> resourceRefs = 135 getQueryMgr().queryJ2EETypeNameSet(XTypes.RESOURCE_REF_CONFIG,name); 136 137 ConnectorResourceConfig config = null; 138 139 final Set <ObjectName > resourceRefObjectNames = Util.toObjectNames( resourceRefs ); 140 if ( resourceRefs.size() != 0 ) 141 { 142 assert( false ); 143 warning( "A DANGLING resource ref already exists with name: " + name + 144 ", {" + 145 CollectionUtil.toString( resourceRefObjectNames ) + "} (SKIPPING TEST)"); 146 } 147 else 148 { 149 config = getDomainConfig().createConnectorResourceConfig( name, 150 poolName, options ); 151 152 final Set <ResourceRefConfig> refs = 153 getQueryMgr().queryJ2EETypeNameSet(XTypes.RESOURCE_REF_CONFIG,name); 154 if ( resourceRefs.size() != 0 ) 155 { 156 final ResourceRefConfig ref = refs.iterator().next(); 157 158 warning( "A resource ref within " + 159 Util.getObjectName( ref.getContainer() ) + 160 " was automatically created when creating the ConnectorResourceConfig " ); 161 } 162 } 163 164 addReference( config ); 165 166 return( config ); 167 } 168 } 169 170 171 | Popular Tags |