CreateRemoveListenerpublic final class CreateRemoveListener extends Object implements NotificationListenerA NotificationListener which expects to receive a
CONFIG_CREATED_NOTIFICATION_TYPE and CONFIG_REMOVED_NOTIFICATION_TYPE
from an MBean with a particular j2eeType and name. |
Fields Summary |
---|
private final String | mNameExpected | private final String | mJ2EETypeExpected | private final com.sun.appserv.management.base.Container | mSource | private Notification | mCreateNotif | private Notification | mRemoveNotif |
Constructors Summary |
---|
public CreateRemoveListener(com.sun.appserv.management.base.Container source, String j2eeTypeExpected, String nameExpected)
mSource = source;
mNameExpected = nameExpected;
mJ2EETypeExpected = j2eeTypeExpected;
mSource.addNotificationListener( this, null, null );
|
Methods Summary |
---|
public void | handleNotification(javax.management.Notification notifIn, java.lang.Object handback)
final String type = notifIn.getType();
//final Map<String,Serializable> m = getAMXNotificationData * notifIn );
final ObjectName objectName =
Util.getAMXNotificationValue( notifIn, AMXConfig.CONFIG_OBJECT_NAME_KEY, ObjectName.class );
//trace( "CreateRemoveListener:\n" + SmartStringifier.toString( notifIn ) + ":\n" + objectName );
if ( Util.getJ2EEType( objectName ).equals( mJ2EETypeExpected ) &&
Util.getName( objectName ).equals( mNameExpected ) )
{
if ( type.equals( AMXConfig.CONFIG_CREATED_NOTIFICATION_TYPE ) )
{
mCreateNotif = notifIn;
}
else if ( type.equals( AMXConfig.CONFIG_REMOVED_NOTIFICATION_TYPE ) )
{
mRemoveNotif = notifIn;
}
}
| protected void | trace(java.lang.Object o)
System.out.println( SmartStringifier.toString( o ) );
| public void | waitCreate()
long millis = 10;
while ( mCreateNotif == null )
{
AMXTestBase.mySleep( millis );
trace( "waiting " + millis + "ms for CONFIG_CREATED_NOTIFICATION_TYPE for " + mNameExpected);
millis *= 2;
}
| public void | waitNotifs()
waitCreate();
waitRemove();
try
{
mSource.removeNotificationListener( (NotificationListener)this, null, null );
}
catch( ListenerNotFoundException e )
{
throw new RuntimeException( e );
}
| public void | waitRemove()
long millis = 10;
while ( mRemoveNotif == null )
{
AMXTestBase.mySleep( millis );
trace( "waiting " + millis + "ms for CONFIG_REMOVED_NOTIFICATION_TYPE for " + mNameExpected);
millis *= 2;
}
|
|