FileDocCategorySizeDatePackage
NotificationServiceMgrImpl.javaAPI DocGlassfish v2 API5712Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

NotificationServiceMgrImpl

public class NotificationServiceMgrImpl extends AMXImplBase implements NotificationListener

Fields Summary
private final Map
mServices
private final com.sun.enterprise.management.support.UniqueIDGenerator
mUniqueIDs
Constructors Summary
public NotificationServiceMgrImpl()

		mServices	= Collections.synchronizedMap( new HashMap<ObjectName,NotificationServiceImpl>() );
		
		mUniqueIDs	= new UniqueIDGenerator( "notif-service-" );
	
Methods Summary
public javax.management.ObjectNamecreateNotificationService(java.lang.Object userData, int bufferSize)

		final NotificationServiceImpl	service	=
			new NotificationServiceImpl( userData, bufferSize );
		
		final ObjectName	self	= getObjectName();
		
		final String	domain		= self.getDomain();
		final String	childName	= mUniqueIDs.createID().toString();
		final String	requiredProps	=
			Util.makeRequiredProps( XTypes.NOTIFICATION_SERVICE, childName );
		
		final ObjectName	tempName	= JMXUtil.newObjectName( domain, requiredProps );
		
		ObjectName	objectName	= null;
		try
		{
			objectName	= registerMBean( service, tempName );
			mServices.put( objectName, service );
		}
		catch( Exception e )
		{
			throw new RuntimeException( e );
		}
		
		return( objectName );
	
public java.lang.StringgetGroup()

		return( AMX.GROUP_UTILITY );
	
public javax.management.ObjectNamegetNotificationServiceObjectName(java.lang.String name)

		return( getContaineeObjectName( XTypes.NOTIFICATION_SERVICE, name ) );
	
public voidhandleNotification(javax.management.Notification notifIn, java.lang.Object handback)

		final String	type	= notifIn.getType();
		
		// ensure that if a NotificationService is unregistered that we remove
		// it from our list
		if ( type.equals( MBeanServerNotification.UNREGISTRATION_NOTIFICATION)  )
		{
			final MBeanServerNotification	notif	= (MBeanServerNotification)notifIn;
			final ObjectName	objectName	= notif.getMBeanName();
			
			if ( Util.getJ2EEType( objectName ).
					equals( XTypes.NOTIFICATION_SERVICE ) )
			{
				mServices.remove( objectName );
			}
		}
	
public voidpreRegisterDone()

		JMXUtil.listenToMBeanServerDelegate( getMBeanServer(), this, null, null );
	
public synchronized voidremoveNotificationService(java.lang.String name)

		final ObjectName	objectName	= getNotificationServiceObjectName( name );
		if ( objectName == null )
		{
			throw new IllegalArgumentException( name );
		}
		
		if ( ! mServices.containsKey( objectName ) )
		{
			throw new InstanceNotFoundException( objectName.toString() );
		}
		
		try
		{
			getMBeanServer().unregisterMBean( objectName );
		}
		catch( MBeanRegistrationException e )
		{
			throw new RuntimeException( e );
		}
		
		// remove it after unregistering it, in case an exception is thrown
		mServices.remove( objectName );