Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 104   Methods: 6
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractDynamicMBean.java 0% 0% 0% 0%
coverage
 1    package org.jconfig.jmx;
 2   
 3    //import org.apache.log4j.Logger;
 4   
 5    import java.util.Iterator;
 6   
 7    import javax.management.Attribute;
 8    import javax.management.AttributeList;
 9    import javax.management.DynamicMBean;
 10    import javax.management.MBeanRegistration;
 11    import javax.management.MBeanServer;
 12    import javax.management.ObjectName;
 13    import javax.management.RuntimeOperationsException;
 14   
 15    public abstract class AbstractDynamicMBean implements DynamicMBean, MBeanRegistration {
 16   
 17    String dClassName;
 18    MBeanServer server;
 19   
 20    /**
 21    * Enables the to get the values of several attributes of the Dynamic MBean.
 22    */
 23  0 public AttributeList getAttributes(String[] attributeNames) {
 24   
 25    // Check attributeNames is not null to avoid NullPointerException later on
 26  0 if (attributeNames == null) {
 27  0 throw new RuntimeOperationsException(
 28    new IllegalArgumentException("attributeNames[] cannot be null"),
 29    "Cannot invoke a getter of " + dClassName);
 30    }
 31   
 32  0 AttributeList resultList = new AttributeList();
 33   
 34    // if attributeNames is empty, return an empty result list
 35  0 if (attributeNames.length == 0)
 36  0 return resultList;
 37   
 38    // build the result attribute list
 39  0 for (int i = 0; i < attributeNames.length; i++) {
 40  0 try {
 41  0 Object value = getAttribute((String) attributeNames[i]);
 42  0 resultList.add(new Attribute(attributeNames[i], value));
 43    } catch (Exception e) {
 44  0 e.printStackTrace();
 45    }
 46    }
 47  0 return (resultList);
 48    }
 49   
 50    /**
 51    * Sets the values of several attributes of the Dynamic MBean, and returns the
 52    * list of attributes that have been set.
 53    */
 54  0 public AttributeList setAttributes(AttributeList attributes) {
 55   
 56    // Check attributes is not null to avoid NullPointerException later on
 57  0 if (attributes == null) {
 58  0 throw new RuntimeOperationsException(
 59    new IllegalArgumentException("AttributeList attributes cannot be null"),
 60    "Cannot invoke a setter of " + dClassName);
 61    }
 62  0 AttributeList resultList = new AttributeList();
 63   
 64    // if attributeNames is empty, nothing more to do
 65  0 if (attributes.isEmpty())
 66  0 return resultList;
 67   
 68    // for each attribute, try to set it and add to the result list if successfull
 69  0 for (Iterator i = attributes.iterator(); i.hasNext();) {
 70  0 Attribute attr = (Attribute) i.next();
 71  0 try {
 72  0 setAttribute(attr);
 73  0 String name = attr.getName();
 74  0 Object value = getAttribute(name);
 75  0 resultList.add(new Attribute(name, value));
 76    } catch (Exception e) {
 77  0 e.printStackTrace();
 78    }
 79    }
 80  0 return (resultList);
 81    }
 82   
 83    //protected abstract Logger getLogger();
 84   
 85  0 public void postDeregister() {
 86    // getLogger().debug("postDeregister is called.");
 87    }
 88   
 89  0 public void postRegister(java.lang.Boolean registrationDone) {
 90    }
 91   
 92  0 public void preDeregister() {
 93    // getLogger().debug("preDeregister called.");
 94    }
 95   
 96  0 public ObjectName preRegister(MBeanServer server, ObjectName name) {
 97    /*
 98    getLogger().debug(
 99    "preRegister called. Server=" + server + ", name=" + name);
 100    */
 101  0 this.server = server;
 102  0 return name;
 103    }
 104    }