FileDocCategorySizeDatePackage
MBeanServerDelegate.javaAPI DocJava SE 6 API6565Tue Jun 10 00:26:12 BST 2008javax.management

MBeanServerDelegate

public class MBeanServerDelegate extends Object implements NotificationEmitter, MBeanServerDelegateMBean
Represents the MBean server from the management point of view. The MBeanServerDelegate MBean emits the MBeanServerNotifications when an MBean is registered/unregistered in the MBean server.
since
1.5

Fields Summary
private String
mbeanServerId
The MBean server agent identification.
private final NotificationBroadcasterSupport
broadcaster
The NotificationBroadcasterSupport object that sends the notifications
private static long
oldStamp
private final long
stamp
private long
sequenceNumber
private static final MBeanNotificationInfo[]
notifsInfo
public static final ObjectName
DELEGATE_NAME
Defines the default ObjectName of the MBeanServerDelegate.
Constructors Summary
public MBeanServerDelegate()
Create a MBeanServerDelegate object.


     
        final String[] types  = { 
	    MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
	    MBeanServerNotification.REGISTRATION_NOTIFICATION
	};
	notifsInfo = new MBeanNotificationInfo[1];
	notifsInfo[0] = 
	    new MBeanNotificationInfo(types,
		    "javax.management.MBeanServerNotification",
		    "Notifications sent by the MBeanServerDelegate MBean");
    
	stamp = getStamp();
        broadcaster = new NotificationBroadcasterSupport() ;
    
Methods Summary
public synchronized voidaddNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)

        broadcaster.addNotificationListener(listener,filter,handback) ;
    
public java.lang.StringgetImplementationName()
Returns the JMX implementation name (the name of this product).

return
the implementation name.

	return ServiceName.JMX_IMPL_NAME;
    
public java.lang.StringgetImplementationVendor()
Returns the JMX implementation vendor (the vendor of this product).

return
the implementation vendor.

	return ServiceName.JMX_IMPL_VENDOR;
    
public java.lang.StringgetImplementationVersion()
Returns the JMX implementation version (the version of this product).

return
the implementation version.

        try {
            return System.getProperty("java.runtime.version");
        } catch (SecurityException e) {
            return "";
        }
    
public synchronized java.lang.StringgetMBeanServerId()
Returns the MBean server agent identity.

return
the identity.

	if (mbeanServerId == null) {
	    String localHost;
	    try {
		localHost = java.net.InetAddress.getLocalHost().getHostName();
	    } catch (java.net.UnknownHostException e) {
		localHost = "localhost";
	    }	
	    mbeanServerId = new String(localHost + "_" + stamp);
	}
	return mbeanServerId;
    
public javax.management.MBeanNotificationInfo[]getNotificationInfo()

	final int len = MBeanServerDelegate.notifsInfo.length;
        final MBeanNotificationInfo[] infos = 
	new MBeanNotificationInfo[len];
	System.arraycopy(MBeanServerDelegate.notifsInfo,0,infos,0,len);
	return infos;
    
public java.lang.StringgetSpecificationName()
Returns the full name of the JMX specification implemented by this product.

return
the specification name.

	return ServiceName.JMX_SPEC_NAME;
    
public java.lang.StringgetSpecificationVendor()
Returns the vendor of the JMX specification implemented by this product.

return
the specification vendor.

	return ServiceName.JMX_SPEC_VENDOR;
    
public java.lang.StringgetSpecificationVersion()
Returns the version of the JMX specification implemented by this product.

return
the specification version.

	return ServiceName.JMX_SPEC_VERSION;
    
private static synchronized longgetStamp()

        try {
            DELEGATE_NAME =
                new ObjectName("JMImplementation:type=MBeanServerDelegate");
        } catch (MalformedObjectNameException e) {
            throw new Error("Can't initialize delegate name", e);
        }
    
	long s = System.currentTimeMillis();
	if (oldStamp >= s) {
	    s = oldStamp + 1;
	}
	oldStamp = s;
	return s;
    
public synchronized voidremoveNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)

        broadcaster.removeNotificationListener(listener,filter,handback) ;
    
public synchronized voidremoveNotificationListener(javax.management.NotificationListener listener)

        broadcaster.removeNotificationListener(listener) ;
    
public voidsendNotification(javax.management.Notification notification)
Enables the MBean server to send a notification. If the passed notification has a sequence number lesser or equal to 0, then replace it with the delegate's own sequence number.

param
notification The notification to send.

	if (notification.getSequenceNumber() < 1) {
	    synchronized (this) {
		notification.setSequenceNumber(this.sequenceNumber++);
	    }
	}
        broadcaster.sendNotification(notification);