FileDocCategorySizeDatePackage
ProxyFactoryTest.javaAPI DocGlassfish v2 API4765Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.client

ProxyFactoryTest

public final class ProxyFactoryTest extends com.sun.enterprise.management.AMXTestBase

Fields Summary
Constructors Summary
public ProxyFactoryTest()

	
Methods Summary
public static com.sun.enterprise.management.CapabilitiesgetCapabilities()

	    return getOfflineCapableCapabilities( false );
	
public voidtestProxyFactoryDetectsMBeanRemoved()
Verify that when an MBean is removed, the ProxyFactory detects this, and removes any proxy from its cache.

		// use the NotificationServiceMgr as a convenient way of making
		// an MBean (a NotificationService) come and go.
		final NotificationServiceMgr	mgr	= getDomainRoot().getNotificationServiceMgr();
		final NotificationService	ns	= mgr.createNotificationService( "UserData", 10 );
		final ObjectName	nsObjectName	= Util.getObjectName( ns );
		assert( ns.getUserData().equals( "UserData" ) );
		
		final ProxyFactory	factory	= getProxyFactory();
		final NotificationService	proxy	=
			factory.getProxy( nsObjectName, NotificationService.class, false );
		assert( proxy == ns ) : "proxies differ: " + ns + "\n" + proxy;
		
		mgr.removeNotificationService( ns.getName() );

		int	iterations	= 0;
		long	sleepMillis	= 10;
		while( factory.getProxy( nsObjectName, NotificationService.class, false ) != null )
		{
			mySleep( sleepMillis );
			if ( sleepMillis >= 400 )
			{
				trace( "testProxyFactoryDetectsMBeanRemoved: waiting for proxy to be removed" );
			}
			sleepMillis	*= 2;
		}