javax.management.AttributeChangeNotificationFilter Java Examples

The following examples show how to use javax.management.AttributeChangeNotificationFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void addAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
{
   if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
   AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
   if (attributeName != null)
   {
      filter.enableAttribute(attributeName);
   }
   else
   {
      MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
      for (int i = 0; i < ai.length; i++)
      {
         Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
         filter.enableAttribute((String)d.getFieldValue("name"));
      }
   }

   getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " added successfully, handback is " + handback);
}
 
Example #2
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
{
   if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
   AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
   if (attributeName != null)
   {
      filter.enableAttribute(attributeName);
   }
   else
   {
      MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
      for (int i = 0; i < ai.length; i++)
      {
         Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
         filter.enableAttribute((String)d.getFieldValue("name"));
      }
   }

   getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " removed successfully, handback is " + handback);
}
 
Example #3
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void addAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
{
   if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
   AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
   if (attributeName != null)
   {
      filter.enableAttribute(attributeName);
   }
   else
   {
      MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
      for (int i = 0; i < ai.length; i++)
      {
         Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
         filter.enableAttribute((String)d.getFieldValue("name"));
      }
   }

   getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " added successfully, handback is " + handback);
}
 
Example #4
Source File: MX4JModelMBean.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
{
   if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
   AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
   if (attributeName != null)
   {
      filter.enableAttribute(attributeName);
   }
   else
   {
      MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
      for (int i = 0; i < ai.length; i++)
      {
         Descriptor d = ((ModelMBeanAttributeInfo)ai[i]).getDescriptor();
         filter.enableAttribute((String)d.getFieldValue("name"));
      }
   }

   getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback);

   Logger logger = getLogger();
   if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " removed successfully, handback is " + handback);
}