1 5 package net.sf.panoptes.controller.digester; 6 7 import net.sf.panoptes.model.node.RootNode; 8 import net.sf.panoptes.registry.ConfiguratorRegistry; 9 import net.sf.panoptes.registry.Template; 10 import net.sf.panoptes.registry.TemplateRegistry; 11 12 import org.apache.commons.digester.Digester; 13 import org.apache.commons.digester.ObjectCreationFactory; 14 import org.xml.sax.Attributes ; 15 16 import com.lc.jmxconsole.model.node.TemplateNode; 17 18 24 public class TemplateFactory implements ObjectCreationFactory { 25 26 private Digester digester; 27 ConfiguratorRegistry configRegistry; 28 RootNode rootNode; 29 30 public TemplateFactory(RootNode rootNode) { 31 this.rootNode = rootNode; 32 } 33 34 37 public Object createObject(Attributes attributes) throws Exception { 38 String name = attributes.getValue("name"); 39 String description = attributes.getValue("description"); 40 String script = "config/templates/" + attributes.getValue("script"); 41 boolean root = "root".equals(attributes.getValue("type")); 42 43 Template t = new Template(name, description, script); 44 TemplateRegistry.getInstance().addTemplate(t); 45 if (root) rootNode.addChild(new TemplateNode(rootNode, name, description, t)); 46 return t; 47 48 } 49 50 53 public Digester getDigester() { 54 return digester; 55 } 56 57 60 public void setDigester(Digester digester) { 61 this.digester = digester; 62 } 63 } 64 | Popular Tags |