Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 101   Methods: 9
NCLOC: 49   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DynamicConfiguration.java - 0% 0% 0%
coverage
 1    /*
 2    * DynamicConfigurationMBean.java
 3    *
 4    * Created on 3. Mai 2004, 17:06
 5    */
 6   
 7    package org.jconfig.jmx;
 8   
 9    import javax.management.MBeanRegistration;
 10    import javax.management.MBeanServer;
 11    import javax.management.ObjectName;
 12   
 13    import org.jconfig.Configuration;
 14    import org.jconfig.ConfigurationManager;
 15    /**
 16    *
 17    * @author mecky
 18    */
 19    public class DynamicConfiguration implements DynamicConfigurationMBean, MBeanRegistration {
 20   
 21    private MBeanServer mBeanServer;
 22    private String name;
 23    private ObjectName objectName;
 24   
 25  0 public DynamicConfiguration() {
 26    }
 27   
 28  0 public String getName() {
 29  0 return name;
 30    }
 31   
 32  0 public void setName(String name) {
 33  0 this.name = name;
 34  0 Configuration config = ConfigurationManager.getConfiguration(name);
 35  0 loadConfiguration(name);
 36    }
 37   
 38  0 public void postDeregister() {
 39    }
 40   
 41  0 public void postRegister(Boolean booleanParam) {
 42    }
 43   
 44  0 public void preDeregister() throws java.lang.Exception {
 45    }
 46   
 47  0 public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws java.lang.Exception {
 48  0 this.mBeanServer = mBeanServer;
 49  0 this.objectName = objectName;
 50  0 return objectName;
 51    }
 52   
 53  0 public ObjectName loadConfiguration(String name) {
 54   
 55  0 System.out.println("loadConfiguration called:"+name);
 56   
 57    // test if MBean has been already loaded
 58    // it can also be tested asking directly to MBeanServer
 59    /*
 60    for (int i = 0; i < alAttributes.size(); i++) {
 61    MBeanAttributeInfo mai = (MBeanAttributeInfo) alAttributes.get(i);
 62    if (mai.getName().equalsIgnoreCase("configuration=" + name))
 63    return null; // shoud throw an exception??
 64    }
 65    */
 66  0 return registerConfigurationMBean(name);
 67    }
 68   
 69  0 ObjectName registerConfigurationMBean(String name) {
 70   
 71  0 ObjectName configurationObjectName = null;
 72  0 try {
 73  0 configurationObjectName =
 74    new ObjectName(objectName.getDomain(), "configuration", name);
 75  0 ConfigurationDynamicMBean configurationMBean =
 76    new ConfigurationDynamicMBean(configurationObjectName, name);
 77  0 mBeanServer.registerMBean(configurationMBean, configurationObjectName);
 78   
 79    // tenemos un atributo nuevo
 80    /*
 81    alAttributes
 82    .add(new MBeanAttributeInfo(
 83    "configuration=" + name,
 84    "javax.management.ObjectName",
 85    "The " + name + " configuration.",
 86    true,
 87    true,
 88    // this makes the object clickable
 89    false));
 90    */
 91   
 92    } catch (Exception e) {
 93    //log.error(
 94    // "Could not add configurationMBean for [" + name + "].",
 95    // e);
 96  0 e.printStackTrace();
 97    }
 98  0 return objectName;
 99    }
 100   
 101    }