KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lc > jmxconsole > model > node > TemplateNode


1 package com.lc.jmxconsole.model.node;
2
3 import java.io.StringWriter JavaDoc;
4 import java.io.Writer JavaDoc;
5
6 import net.sf.panoptes.component.jmx.model.ServerRegistry;
7 import net.sf.panoptes.controller.MainController;
8 import net.sf.panoptes.model.node.GroupNode;
9 import net.sf.panoptes.model.node.NodeSupport;
10 import net.sf.panoptes.registry.Template;
11
12 import org.apache.commons.jelly.JellyContext;
13 import org.apache.commons.jelly.XMLOutput;
14
15 public class TemplateNode extends GroupNode {
16         
17     private Template template;
18     
19     /**
20      *
21      */

22     public TemplateNode(NodeSupport parent, String JavaDoc name, String JavaDoc description, Template template) {
23         super(parent, name, description);
24         this.template = template;
25     }
26     
27     public void init() {
28         
29     }
30     
31     /* (non-Javadoc)
32      * @see net.sf.panoptes.view.configurator.NodeSupport#acceptsChildren()
33      */

34     public boolean acceptsChildren() {
35         return false;
36     }
37
38
39     public void refresh() {
40         clear();
41         JellyContext context = new JellyContext();
42         
43         context.setVariables(getContext());
44         context.setVariable("rootNode", this);
45         context.setVariable("serverRegistry", ServerRegistry.getInstance());
46         Writer JavaDoc output = new StringWriter JavaDoc(0);
47         XMLOutput xmlOutput = XMLOutput.createXMLOutput(output); // Why do I need this?
48
long startTime = System.currentTimeMillis();
49         try {
50             context.runScript(template.getScript(), xmlOutput);
51         } catch (Exception JavaDoc e) {
52             MainController.getInstance().displayError("Unable to construct template", e.getMessage(), e);
53         }
54         
55         
56     }
57
58
59
60 }
61
Popular Tags