Package javax.management

Examples of javax.management.AttributeChangeNotificationFilter



        if (attributeBroadcaster == null)
            attributeBroadcaster = new NotificationBroadcasterSupport();

        AttributeChangeNotificationFilter currFilter =
            new AttributeChangeNotificationFilter();

        MBeanAttributeInfo[] attrInfo = modelMBeanInfo.getAttributes();
        boolean found = false;
        if (inAttributeName == null) {
            if ((attrInfo != null) && (attrInfo.length>0)) {
                for (int i=0; i<attrInfo.length; i++) {
                    currFilter.enableAttribute(attrInfo[i].getName());
                }
            }
        } else {
            if ((attrInfo != null) && (attrInfo.length>0)) {
                for (int i=0; i<attrInfo.length; i++) {
                    if (inAttributeName.equals(attrInfo[i].getName())) {
                        found = true;
                        currFilter.enableAttribute(inAttributeName);
                        break;
                    }
                }
            }
            if (!found) {
                throw new RuntimeOperationsException(new
                    IllegalArgumentException(
                    "The attribute name does not exist"),
                    "Exception occurred trying to add an "+
                    "AttributeChangeNotification listener");
            }
        }

        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
            Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
            String s = (enabledAttrs.size() > 1) ?
                        "[" + enabledAttrs.firstElement() + ", ...]" :
                        enabledAttrs.toString();
            MODELMBEAN_LOGGER.logp(Level.FINER,
                    RequiredModelMBean.class.getName(), mth,
View Full Code Here


  // Tests ---------------------------------------------------------------------

  public void testGetEnabledAttributes()
  {
      AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
     
      assertTrue(filter.getEnabledAttributes().size() == 0);
     
      filter.enableAttribute("foo");
      filter.enableAttribute("bar");
     
      assertTrue(filter.getEnabledAttributes().size() == 2);
  }
View Full Code Here

      assertTrue(filter.getEnabledAttributes().size() == 2);
  }

  public void testDisableAttribute()
  {
     AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
    
     filter.enableAttribute("foo");
     filter.enableAttribute("bar");
    
     assertTrue(filter.getEnabledAttributes().size() == 2);
    
     filter.disableAttribute("foo");
    
     assertTrue(filter.getEnabledAttributes().size() == 1);
     assertTrue(filter.getEnabledAttributes().get(0).equals("bar"));
    
     filter.disableAllAttributes();
    
     assertTrue(filter.getEnabledAttributes().size() == 0);
    
  }
View Full Code Here

  // Tests ---------------------------------------------------------------------

  public void testGetEnabledAttributes()
  {
      AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
     
      assertTrue(filter.getEnabledAttributes().size() == 0);
     
      filter.enableAttribute("foo");
      filter.enableAttribute("bar");
     
      assertTrue(filter.getEnabledAttributes().size() == 2);
  }
View Full Code Here

      assertTrue(filter.getEnabledAttributes().size() == 2);
  }

  public void testDisableAttribute()
  {
     AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
    
     filter.enableAttribute("foo");
     filter.enableAttribute("bar");
    
     assertTrue(filter.getEnabledAttributes().size() == 2);
    
     filter.disableAttribute("foo");
    
     assertTrue(filter.getEnabledAttributes().size() == 1);
     assertTrue(filter.getEnabledAttributes().get(0).equals("bar"));
    
     filter.disableAllAttributes();
    
     assertTrue(filter.getEnabledAttributes().size() == 0);
    
  }
View Full Code Here

   
      
  if (attributeBroadcaster == null)
      attributeBroadcaster = new NotificationBroadcasterSupport();

  AttributeChangeNotificationFilter currFilter =
      new AttributeChangeNotificationFilter();

  MBeanAttributeInfo[] attrInfo = modelMBeanInfo.getAttributes();
  boolean found = false;
  if (inAttributeName == null) {   
      if ((attrInfo != null) && (attrInfo.length>0)) {
    for (int i=0; i<attrInfo.length; i++) {
        currFilter.enableAttribute(attrInfo[i].getName());
    }
      }
  } else {
      if ((attrInfo != null) && (attrInfo.length>0)) {
    for (int i=0; i<attrInfo.length; i++) {
        if (inAttributeName.equals(attrInfo[i].getName())) {
      found = true;
      currFilter.enableAttribute(inAttributeName);
      break;
        }       
    }
            }
            if (!found) {
                throw new RuntimeOperationsException(new
                    IllegalArgumentException(
                    "The attribute name does not exist"),
                    "Exception occurred trying to add an "+
                    "AttributeChangeNotification listener");
            }
  }

  if (tracing())
      trace(ftag, "Set attribute change filter to " +
      ((currFilter.getEnabledAttributes()).firstElement()).toString());

  attributeBroadcaster.addNotificationListener(inlistener,currFilter,
                 inhandback);
  if (tracing()) trace("addAttributeChangeNotificationListener",
           "added for " + inAttributeName);
View Full Code Here

     * @throws RuntimeOperationsException
     * @throws IllegalArgumentException
     */
    public void addAttributeChangeNotificationListener(NotificationListener l, String attrName, Object handback)
            throws MBeanException, RuntimeOperationsException, IllegalArgumentException {
        AttributeChangeNotificationFilter currFilter = new AttributeChangeNotificationFilter();
        currFilter.enableAttribute(attrName);
        broadcasterSupport.addNotificationListener(l, currFilter, handback);
    }
View Full Code Here

     * @throws RuntimeOperationsException
     * @throws IllegalArgumentException
     */
    public void addAttributeChangeNotificationListener(NotificationListener l, String attrName, Object handback) throws MBeanException,
                    RuntimeOperationsException, IllegalArgumentException {
        AttributeChangeNotificationFilter currFilter = new AttributeChangeNotificationFilter();
        currFilter.enableAttribute(attrName);
        broadcasterSupport.addNotificationListener(l, currFilter, handback);
    }
View Full Code Here

      if (!n1.getOldValue().equals(n2.getOldValue())) throw new RuntimeException();
   }

   public void compareAttributeChangeNotificationFilter(Object o1, Object o2)
   {
      AttributeChangeNotificationFilter f1 = (AttributeChangeNotificationFilter)o1;
      AttributeChangeNotificationFilter f2 = (AttributeChangeNotificationFilter)o2;

      if (!f1.getEnabledAttributes().equals(f2.getEnabledAttributes())) throw new RuntimeException();
   }
View Full Code Here


        if (attributeBroadcaster == null)
            attributeBroadcaster = new NotificationBroadcasterSupport();

        AttributeChangeNotificationFilter currFilter =
            new AttributeChangeNotificationFilter();

        MBeanAttributeInfo[] attrInfo = modelMBeanInfo.getAttributes();
        boolean found = false;
        if (inAttributeName == null) {
            if ((attrInfo != null) && (attrInfo.length>0)) {
                for (int i=0; i<attrInfo.length; i++) {
                    currFilter.enableAttribute(attrInfo[i].getName());
                }
            }
        } else {
            if ((attrInfo != null) && (attrInfo.length>0)) {
                for (int i=0; i<attrInfo.length; i++) {
                    if (inAttributeName.equals(attrInfo[i].getName())) {
                        found = true;
                        currFilter.enableAttribute(inAttributeName);
                        break;
                    }
                }
            }
            if (!found) {
                throw new RuntimeOperationsException(new
                    IllegalArgumentException(
                    "The attribute name does not exist"),
                    "Exception occurred trying to add an "+
                    "AttributeChangeNotification listener");
            }
        }

        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
            Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
            String s = (enabledAttrs.size() > 1) ?
                        "[" + enabledAttrs.firstElement() + ", ...]" :
                        enabledAttrs.toString();
            MODELMBEAN_LOGGER.logp(Level.FINER,
                    RequiredModelMBean.class.getName(), mth,
View Full Code Here

TOP

Related Classes of javax.management.AttributeChangeNotificationFilter

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.