1 package org.jfox.ioc.management.http; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.List ; 6 import java.util.Map ; 7 import java.util.TreeMap ; 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpSession ; 10 11 import org.apache.velocity.context.Context; 12 import org.jfox.ioc.ComponentMeta; 13 import org.jfox.ioc.Registry; 14 15 18 19 public class IndexServlet extends SuperServlet { 20 21 public String getTemplate() { 22 return "index.vm"; 23 } 24 25 public void buildContext(HttpServletRequest request, Context ctx) throws Exception { 26 27 HttpSession session = request.getSession(true); 28 session.setAttribute("time",System.currentTimeMillis() + ""); 29 30 Registry registry = getRegistry(); 31 32 List <ComponentMeta> metas = registry.getAllComponentMetas(); 33 Map <String ,List > modules = new TreeMap <String ,List >(); 34 for(ComponentMeta meta : metas){ 35 String module = meta.getModule(); 36 String moduleKey = "<b>" + meta.getModuleDesc() + "</b> - "+ module; 37 if(modules.containsKey(moduleKey)){ 38 List list = (List )modules.get(moduleKey); 39 list.add(meta); 40 Collections.sort(list); 41 } 42 else { 43 List list = new ArrayList (); 44 list.add(meta); 45 modules.put(moduleKey,list); 46 } 47 } 48 49 ctx.put("title","Index View"); 50 ctx.put("modules",modules); 51 ctx.put("moduleCounts",modules.size()); 52 ctx.put("typeCounts",registry.countComponentTypes()); 53 ctx.put("componentCounts",metas.size()); 54 } 55 56 public static void main(String [] args) { 57 58 } 59 } 60 61 | Popular Tags |