users@glassfish.java.net

Re: NotificationListener in AMX

From: <glassfish_at_javadesktop.org>
Date: Mon, 15 Oct 2007 10:37:12 PDT

All AMX MBeans emit AttributeChangeNotification when an attribute changes. I'm looking at 9.1 source, but I don't think it's materially different (or different at all for this situation).

The variable 'mEmitAttributeChangeNotifications' is always 'true' and so if there is a listener, then a Notification will be emitted by setAttributeInternal():

                protected final boolean
        shouldEmitNotifications()
        {
                return( mEmitAttributeChangeNotifications && getListenerCount() != 0 );
        }

        protected void setAttributeInternal( final Attribute attr ) {
              ....
                final boolean shouldEmitNotifications = shouldEmitNotifications();
                final Object oldValue = shouldEmitNotifications ?
                                                getAttribute( attr.getName() ) : null;
                if ( shouldEmitNotifications )
                {
                        final String attrType = getAttributeType( attr.getName() );
                        
                        sendAttributeChangeNotification( "", attrType, oldValue, attr );
                }
              ....
        }

This logic applies to all AMX MBeans; it is in AMXImplBase, the base class for all AMX MBeans.
[Message sent by forum member 'llc' (llc)]

http://forums.java.net/jive/thread.jspa?messageID=240191