1 5 package net.sf.panoptes.controller.digester; 6 7 import java.util.HashMap ; 8 9 import javax.management.ObjectName ; 10 11 import org.apache.commons.digester.Digester; 12 import org.apache.commons.digester.ObjectCreationFactory; 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.xml.sax.Attributes ; 16 17 import net.sf.panoptes.registry.ConfiguratorRegistry; 18 19 25 public class ConfiguratorFactory implements ObjectCreationFactory { 26 27 private Digester digester; 28 private Log log = LogFactory.getLog(getClass()); 29 ConfiguratorRegistry configRegistry; 30 31 public ConfiguratorFactory(ConfiguratorRegistry configRegistry) { 32 this.configRegistry = configRegistry; 33 } 34 35 38 public Object createObject(Attributes attributes) throws Exception { 39 String name = attributes.getValue("name"); 40 String configuratorClassName = attributes.getValue("configuratorClass"); 41 String className = attributes.getValue("pojoClass"); 42 String mbeanClassName = attributes.getValue("mbeanClass"); 43 String guiType = attributes.getValue("gui"); 44 if (guiType == null) log.warn("Configurator " + name + " does not define the gui-attribtue and will not be displayed"); 45 ObjectName objectName = null; 46 if (attributes.getValue("objectName") != null) { 47 objectName = new ObjectName (attributes.getValue("objectName")); 48 } 49 String iconName = attributes.getValue("iconName"); 50 51 HashMap atts = new HashMap (); 52 for (int i = 0; i < attributes.getLength(); i++) { 53 atts.put(attributes.getQName(i), attributes.getValue(i)); 54 } 55 56 return configRegistry.addConfigurator(name, guiType, configuratorClassName, objectName, mbeanClassName, className, iconName, atts); 57 58 } 59 60 63 public Digester getDigester() { 64 return digester; 65 } 66 67 70 public void setDigester(Digester digester) { 71 this.digester = digester; 72 } 73 } 74 | Popular Tags |