1 23 24 package com.sun.enterprise.management.support.oldconfig; 25 26 import java.util.Set ; 27 28 import javax.management.ObjectName ; 29 import javax.management.MBeanServer ; 30 import javax.management.MBeanServerInvocationHandler ; 31 32 import com.sun.appserv.management.util.misc.GSetUtil; 33 import com.sun.appserv.management.util.jmx.JMXUtil; 34 import com.sun.appserv.management.base.Util; 35 36 37 40 public class OldConfigProxies 41 { 42 final MBeanServer mServer; 43 44 private 45 OldConfigProxies( final MBeanServer server ) 46 { 47 mServer = server; 48 } 49 50 private final String OLD_DOMAIN = "com.sun.appserv"; 51 private final String CONFIGS_IN_OLD_DOMAIN = "com.sun.appserv:category=config"; 52 53 private static OldConfigProxies INSTANCE = null; 54 55 public static synchronized OldConfigProxies 56 getInstance( final MBeanServer server ) 57 { 58 if ( INSTANCE == null ) 59 { 60 INSTANCE = new OldConfigProxies( server ); 61 } 62 else 63 { 64 assert( INSTANCE.getMBeanServer() == server ); 65 } 66 return( INSTANCE ); 67 } 68 69 private MBeanServer 70 getMBeanServer() 71 { 72 return( mServer ); 73 } 74 75 79 public <T> T 80 newProxy( 81 final ObjectName target, 82 final Class <T> interfaceClass ) 83 { 84 return interfaceClass.cast( MBeanServerInvocationHandler.newProxyInstance( 85 mServer, target, interfaceClass, false ) ); 86 } 87 88 92 public <T> T 93 newProxy( 94 final String props, 95 final Class <T> interfaceClass ) 96 { 97 final ObjectName objectName = queryOldConfigObjectName( props ); 98 99 return newProxy( objectName, interfaceClass ); 100 } 101 102 private ObjectName 103 queryOldConfigObjectName( String props ) 104 { 105 final ObjectName pattern = 106 Util.newObjectNamePattern( OLD_DOMAIN, 107 Util.concatenateProps( props, "category=config" ) ); 108 109 final Set <ObjectName > candidates = JMXUtil.queryNames( mServer, pattern, null ); 110 111 ObjectName oldConfigObjectName = null; 112 113 if ( candidates.size() == 1 ) 114 { 115 oldConfigObjectName = GSetUtil.getSingleton( candidates ); 116 } 117 else if ( candidates.size() == 0 ) 118 { 119 oldConfigObjectName = null; 120 } 121 else 122 { 123 throw new IllegalArgumentException ( "found more than one match: " + props ); 124 } 125 126 return( oldConfigObjectName ); 127 128 } 129 130 public OldProperties 131 getOldProperties( final ObjectName objectName ) 132 { 133 return( newProxy( objectName, OldProperties.class ) ); 134 } 135 136 public OldConfigsMBean 137 getOldConfigsMBean() 138 { 139 return( newProxy( "type=configs", OldConfigsMBean.class ) ); 140 } 141 142 public OldConfig 143 getOldConfig( final String name ) 144 { 145 return( newProxy( "type=config,name=" + name, OldConfig.class ) ); 146 } 147 148 public OldClustersMBean 149 getOldClustersMBean() 150 { 151 return( newProxy( "type=clusters", OldClustersMBean.class ) ); 152 } 153 154 public OldServersMBean 155 getOldServersMBean() 156 { 157 return( newProxy( "type=servers", OldServersMBean.class ) ); 158 } 159 160 public OldResourcesMBean 161 getOldResourcesMBean() 162 { 163 return( newProxy( "type=resources", OldResourcesMBean.class ) ); 164 } 165 166 public OldApplicationsConfigMBean 167 getOldApplicationsConfigMBean() 168 { 169 return( newProxy( 170 "type=applications", OldApplicationsConfigMBean.class ) ); 171 } 172 173 public OldDomainMBean 174 getOldDomainMBean() 175 { 176 return( newProxy( "type=domain", OldDomainMBean.class ) ); 177 } 178 179 public OldClusterMBean 180 getOldClusterMBean( final String clusterName ) 181 { 182 return( newProxy( 183 "type=cluster,name=" + clusterName, OldClusterMBean.class ) ); 184 } 185 186 public OldServerMBean 187 getOldServerMBean( final String serverName ) 188 { 189 return( newProxy( 190 "type=server,name=" + serverName, OldServerMBean.class ) ); 191 } 192 193 public OldAdminServiceMBean 194 getOldAdminServiceMBean( final String configName ) 195 { 196 return( newProxy( 197 "type=admin-service,config=" + configName, OldAdminServiceMBean.class ) ); 198 } 199 200 public OldHTTPServiceMBean 201 getOldHTTPServiceMBean( final String configName ) 202 { 203 return( newProxy( 204 "type=http-service,config=" + configName, OldHTTPServiceMBean.class ) ); 205 } 206 207 public OldVirtualServerMBean 208 getOldVirtualServerMBean( 209 final String configName, 210 final String virtualServer ) 211 { 212 return( newProxy( 213 "type=virtual-server,config=" + configName + 214 ",id=" + virtualServer, OldVirtualServerMBean.class ) ); 215 } 216 217 public OldIIOPServiceMBean 218 getOldIIOPServiceMBean( final String configName ) 219 { 220 return( newProxy( 221 "type=iiop-service,config=" + configName, OldIIOPServiceMBean.class ) ); 222 } 223 224 225 public OldSecurityServiceMBean 226 getOldSecurityServiceMBean( final String configName ) 227 { 228 return( newProxy( 229 "type=security-service,config=" + configName, OldSecurityServiceMBean.class ) ); 230 } 231 232 233 public OldTransactionServiceMBean 234 getOldTransactionServiceMBean( final String configName ) 235 { 236 return( newProxy( 237 "type=transaction-service,config=" + configName, OldTransactionServiceMBean.class ) ); 238 } 239 240 241 public OldLogServiceMBean 242 getOldLogServiceMBean( final String configName ) 243 { 244 return( newProxy( 245 "type=log-service,config=" + configName, OldLogServiceMBean.class ) ); 246 } 247 248 249 public OldMonitoringServiceMBean 250 getOldMonitoringServiceMBean( final String configName ) 251 { 252 return( newProxy( 253 "type=monitoring-service,config=" + configName, OldMonitoringServiceMBean.class ) ); 254 } 255 256 public OldSessionConfigMBean 257 getOldSessionConfigMBean( final String configName ) 258 { 259 return( newProxy( 260 "type=session,config=" + configName, OldSessionConfigMBean.class ) ); 261 } 262 263 public OldSessionManagerMBean 264 getOldSessionManagerMBean( final String configName ) 265 { 266 return( newProxy( 267 "type=session-manager,config=" + configName, OldSessionManagerMBean.class ) ); 268 } 269 270 271 public OldEJBContainerConfigMBean 272 getOldEJBContainerConfigMBean( final String configName ) 273 { 274 return( newProxy( 275 "type=ejb-container,config=" + configName, OldEJBContainerConfigMBean.class ) ); 276 } 277 278 279 public OldWebContainerConfigMBean 280 getOldWebContainerConfigMBean( final String configName ) 281 { 282 return( newProxy( 283 "type=web-container,config=" + configName, OldWebContainerConfigMBean.class ) ); 284 } 285 286 public OldAvailabilityServiceMBean 287 getOldAvailabilityServiceMBean( final String configName ) 288 { 289 return( newProxy( 290 "type=availability,config=" + configName, OldAvailabilityServiceMBean.class ) ); 291 } 292 293 294 public OldJavaConfigMBean 295 getOldJavaConfigMBean( final String configName ) 296 { 297 return( newProxy( 298 "type=java-config,config=" + configName, OldJavaConfigMBean.class ) ); 299 } 300 301 302 public OldModuleLogLevelsMBean 303 getOldModuleLogLevelsMBean( final String configName ) 304 { 305 return( newProxy( 306 "type=module-log-levels,config=" + configName, OldModuleLogLevelsMBean.class ) ); 307 } 308 309 310 public OldModuleMonitoringLevelsMBean 311 getOldModuleMonitoringLevelsMBean( final String configName ) 312 { 313 return( newProxy( 314 "type=module-monitoring-levels,config=" + configName, OldModuleMonitoringLevelsMBean.class ) ); 315 } 316 317 318 public OldThreadPoolsConfigMBean 319 getOldThreadPoolsConfigMBean( final String configName ) 320 { 321 return( newProxy( 322 "type=thread-pools,config=" + configName, OldThreadPoolsConfigMBean.class ) ); 323 } 324 325 326 public OldDASConfigMBean 327 getOldDASConfigMBean( final String configName ) 328 { 329 return( newProxy( 330 "type=das-config,config=" + configName, OldDASConfigMBean.class ) ); 331 } 332 333 public OldSystemServicesMBean 334 getOldSystemServicesMBean() 335 { 336 return( newProxy( 337 "ias:type=system-services,server=server", 338 OldSystemServicesMBean.class ) ); 339 } 340 341 public OldJMSServiceMBean 342 getOldJMSServiceMBean( final String configName ) 343 { 344 return( newProxy( 345 "type=jms-service,config=" + configName, OldJMSServiceMBean.class ) ); 346 } 347 348 public OldMessageSecurityConfigMBean 349 getOldMessageSecurityConfigMBean( final String name ) 350 { 351 return( newProxy( 352 "type=message-security-config,name=" + name, 353 OldMessageSecurityConfigMBean.class ) ); 354 } 355 356 357 public OldLbConfigs 358 getOldLbConfigs( ) 359 { 360 return( newProxy( "type=lb-configs", OldLbConfigs.class ) ); 361 } 362 363 public OldLbConfig 364 getOldLbConfig( final String name) 365 { 366 return( (OldLbConfig)newProxy( 367 "type=lb-config,name="+name, OldLbConfig.class ) ); 368 } 369 370 public OldServerRefMBean 371 getOldServerRefMBean( final String name) 372 { 373 return( ( OldServerRefMBean)newProxy( 374 "type=server-ref,ref=" + name, OldServerRefMBean.class)); 375 } 376 377 public OldClusterRefMBean 378 getOldClusterRefMBean( final String name) 379 { 380 return( ( OldClusterRefMBean)newProxy( 381 "type=cluster-ref,ref=" + name, OldClusterRefMBean.class)); 382 } 383 384 public OldLoadBalancers 385 getOldLoadBalancers( ) 386 { 387 return( newProxy( "type=load-balancers", OldLoadBalancers.class ) ); 388 } 389 390 private static String 391 getManagementRulesProps( final String configName ) 392 { 393 return "type=management-rules,config=" + configName; 394 } 395 396 public ObjectName 397 createOldManagementRules( final String configName ) 398 { 399 final String props = getManagementRulesProps( configName ); 400 401 ObjectName objectName = 402 queryOldConfigObjectName( props ); 403 404 if ( objectName == null ) 405 { 406 getOldConfig( configName ).createManagementRules( null ); 408 409 objectName = queryOldConfigObjectName( props ); 410 } 411 return objectName; 412 } 413 414 415 public OldManagementRules 416 getOldManagementRules( final String configName ) 417 { 418 return( 419 newProxy( getManagementRulesProps( configName ), OldManagementRules.class ) ); 420 } 421 422 423 public OldConnectorConnectionPoolMBean 424 getOldConnectorConnectionPool( final String name ) 425 { 426 return( 427 newProxy( "type=connector-connection-pool,name=" + name, OldConnectorConnectionPoolMBean.class ) ); 428 } 429 430 431 public ObjectName 432 getOldSecurityMapObjectName( 433 final String connectorConnectionPoolName, 434 final String name ) 435 { 436 return getOldConnectorConnectionPool( connectorConnectionPoolName ).getSecurityMapByName( name ); 437 } 438 439 public OldSecurityMap 440 getOldSecurityMap( 441 final String connectorConnectionPoolName, 442 final String name ) 443 { 444 final ObjectName securityMapObjectName = 445 getOldSecurityMapObjectName( connectorConnectionPoolName, name ); 446 447 return newProxy( securityMapObjectName, OldSecurityMap.class ); 448 } 449 450 public OldWebServiceEndpointConfigMBean 451 getOldWebServiceEndpointConfigMBean( final String name) 452 { 453 return( ( OldWebServiceEndpointConfigMBean)newProxy( 454 "type=web-service-endpoint,name=" + name, 455 OldWebServiceEndpointConfigMBean.class)); 456 } 457 458 } 459 460 461 462 463 464 465 466 467 468 469 470 | Popular Tags |