1 package com.jcorporate.expresso.services.controller.configuration; 2 3 66 67 import com.jcorporate.expresso.core.controller.Block; 68 import com.jcorporate.expresso.core.controller.ControllerException; 69 import com.jcorporate.expresso.core.controller.ControllerRequest; 70 import com.jcorporate.expresso.core.controller.ControllerResponse; 71 import com.jcorporate.expresso.core.controller.ErrorCollection; 72 import com.jcorporate.expresso.core.controller.NonHandleableException; 73 import com.jcorporate.expresso.core.controller.Transition; 74 import com.jcorporate.expresso.kernel.Containable; 75 import com.jcorporate.expresso.kernel.ExpressoComponent; 76 import com.jcorporate.expresso.kernel.RootContainerInterface; 77 import com.jcorporate.expresso.services.controller.Configuration; 78 79 import java.util.Iterator ; 80 81 82 90 91 public class ShowContainerTree extends ConfigurationBase { 92 93 94 public ShowContainerTree() { 95 super("showContainerTree", "Show Container Tree"); 96 } 97 98 public void run(ControllerRequest request, ControllerResponse response) 99 throws NonHandleableException, ControllerException { 100 super.run(request, response); 101 102 response.setTitle("Show Container Hierarchy"); 103 104 RootContainerInterface root = this.getRuntime(request); 105 106 if (root == null) { 107 ErrorCollection ec = new ErrorCollection(); 108 ec.addError("There is no runtime available by this name"); 109 response.saveErrors(ec); 110 return; 111 } 112 113 Block rootBlock = new Block("root"); 114 rootBlock.setLabel("Root of Runtime"); 115 response.add(rootBlock); 116 this.addShowTransition((ExpressoComponent) root, rootBlock); 117 addOneContainer(rootBlock, root); 118 } 119 120 128 protected void addShowTransition(ExpressoComponent component, Block parent) throws ControllerException { 129 Transition t = new Transition("showContainerTransition", component.getMetaData() 130 .getName(), Configuration.class, Configuration.STATE_SHOW_COMPONENT); 131 t.addParam("runtimeName", lc.getPath(component)); 132 parent.add(t); 133 } 134 135 142 protected void addOneContainer(Block parentBlock, Containable current) throws ControllerException { 143 for (Iterator i = current.getContainerImplementation().getChildComponents().keySet().iterator(); 144 i.hasNext();) { 145 146 ExpressoComponent ec = (ExpressoComponent) i.next(); 147 if (ec instanceof Containable) { 148 Block containerBlock = new Block(ec.getMetaData().getName()); 149 parentBlock.add(containerBlock); 150 containerBlock.setLabel(ec.getMetaData().getName()); 151 this.addShowTransition(ec, containerBlock); 152 addOneContainer(containerBlock, (Containable) ec); 153 } else { 154 Transition t = new Transition(ec.getMetaData().getName(), ec.getMetaData() 155 .getName(), Configuration.class, Configuration.STATE_SHOW_COMPONENT); 156 t.addParam("runtimeName", lc.getPath(ec)); 157 parentBlock.add(t); 158 } 159 160 } 161 162 } 163 } | Popular Tags |