Package javax.management

Examples of javax.management.MBeanServerNotification


    }
    catch (Exception e)
    {
      fail(e.toString());
    }
    n1 = new MBeanServerNotification(MBeanServerNotification.REGISTRATION_NOTIFICATION,
                                     new Object(), 1, on1);
    n2 = new MBeanServerNotification(MBeanServerNotification.REGISTRATION_NOTIFICATION,
                                     new Object(), 2, on2);
  }


    if (notification == null ||
        !(notification instanceof MBeanServerNotification))
      return;

    // It still might be malicous
    MBeanServerNotification mbsn = (MBeanServerNotification) notification;
    if (mbsn.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION) == false)
      return;

    // Add the object to the list of mbeans to remove
    ObjectName objectName = mbsn.getMBeanName();
    unregistered.push(objectName);

    try
    {
      // Are we set to automatic purge?

            {
                ObjectName mbs = JMXUtil.getMBeanServerObjectName();
//                log.debug("mbs="+mbs+", src="+src);
                if (mbs.equals((ObjectName) src))
                {
                    MBeanServerNotification mn = (MBeanServerNotification) notification;
                    String type = notification.getType();

                    // MBeanServer notification
                    if (o != null)
                    {
                        // remove MBeanServer notification
                        String key = (String) o;
                        Connector con = (Connector) connectors.get(key);
                        if (con != null)
                        {

                            if (type.equals("JMX.mbean.registered"))
                            {
                                // remote mbean is registered
                                ObjectName on = mn.getMBeanName();
                                if (on.getKeyProperty("MBeanServerId") == null)
                                {
                                    //FIXME: double check this...
                                    registerMBean(con, (ObjectName) mn.getMBeanName());
                                    return;
                                }
                            }
                            else if (type.equals("JMX.mbean.unregistered"))
                            {
                                // remove mbean is unregistered
                                MBean mbean = findMBean(con, (ObjectName) mn.getMBeanName());
                                if (mbean != null)
                                {
                                    log.debug("found mbean: " + mbean + ", unregistering...");
                                    unregisterMBean(con, mbean);
                                    return;

     */
    protected void sendRegistrationNotification (ObjectName regName)
    {
        long sequence = registrationNotificationSequence.increment ();
        delegate.sendNotification (
                new MBeanServerNotification (
                        MBeanServerNotification.REGISTRATION_NOTIFICATION,
                        delegate, sequence, regName));
    }

  protected void sendUnRegistrationNotification (ObjectName name)
  {
      long sequence = unregistrationNotificationSequence.increment ();

      delegate.sendNotification (
              new MBeanServerNotification (
                      MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
                      delegate,
                      sequence,
                      name
              )

      if (MBeanServerNotificationSer.MBEAN_NAME.equals(hint)) mbeanName = (ObjectName)value;
   }

   protected Object createObject() throws SAXException
   {
      MBeanServerNotification notification = new MBeanServerNotification(getType(), getSource(), getSequenceNumber(), mbeanName);
      notification.setTimeStamp(getTimeStamp());
      notification.setUserData(getUserData());
      return notification;
   }

      Map localMBeanToRelationId = new HashMap();
      synchronized (m_referencedMBeanObjectNameToRelationIds)
      {
         for (Iterator i = localDeregisteredNotificationList.iterator(); i.hasNext();)
         {
            MBeanServerNotification serverNotification = (MBeanServerNotification)i.next();
            ObjectName deregisteredMBeanName = serverNotification.getMBeanName();
            obsoleteReferenceList.add(deregisteredMBeanName);

            HashMap relationIdMap = (HashMap)m_referencedMBeanObjectNameToRelationIds.get(deregisteredMBeanName);
            localMBeanToRelationId.put(deregisteredMBeanName, relationIdMap);
            m_referencedMBeanObjectNameToRelationIds.remove(deregisteredMBeanName);
         }
      }

      // update listener filter to avoid recieving notifications for same MBeans
      updateUnregistrationListener(null, obsoleteReferenceList);
      for (Iterator i = localDeregisteredNotificationList.iterator(); i.hasNext();)
      {
         MBeanServerNotification currentNotification = (MBeanServerNotification)i.next();
         ObjectName unregisteredMBeanObjectName = currentNotification.getMBeanName();
         HashMap localRelationIdMap = (HashMap)(localMBeanToRelationId.get(unregisteredMBeanObjectName));

         Set localRelationIdSet = localRelationIdMap.keySet();
         // handles the unregistration of mbeans
         unregisterReferences(localRelationIdSet, localRelationIdMap, unregisteredMBeanObjectName);

      {
         sequenceNumber = notifications;
         ++notifications;
      }

      delegate.sendNotification(new MBeanServerNotification(notificationType, delegateName, sequenceNumber, objectName));
   }

      if (goOn)
      {
         if (notification instanceof MBeanServerNotification)
         {
            MBeanServerNotification n = (MBeanServerNotification)notification;
            ObjectName name = n.getMBeanName();

            if (m_enabledObjectNames == null)
            {
               // All enabled, check the disabled ones
               if (m_disabledObjectNames != null && m_disabledObjectNames.contains(name))

     * does nothing; the notification is ignored.</p>
     *
     * @see NotificationListener#handleNotification(Notification, Object)
     */
    public void handleNotification(Notification notification, Object handback) {
        MBeanServerNotification mbsNotif = null;

        if (notification instanceof MBeanServerNotification) {
            mbsNotif = (MBeanServerNotification) notification;

            // synchronize now so we only have to do it once, any mods done to the directory
            // are thread-safe from this point on
            synchronized (m_allCommandTypes) {
                if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(mbsNotif.getType())) {
                    addAllSupportedCommandTypes(mbsNotif.getMBeanName());
                } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(mbsNotif.getType())) {
                    removeAllSupportedCommandTypes(mbsNotif.getMBeanName());
                } else {
                    mbsNotif = null;
                }
            }
        }

TOP

Related Classes of javax.management.MBeanServerNotification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.