KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > management > http > ViewServlet


1 package org.jfox.ioc.management.http;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4
5 import org.apache.velocity.context.Context;
6 import org.jfox.ioc.ComponentMeta;
7 import org.jfox.ioc.ComponentName;
8 import org.jfox.ioc.ext.ManagableComponent;
9 import org.jfox.ioc.management.ManagementInfo;
10
11 /**
12  * @author <a HREF="mailto:yy.young@gmail.com">Young Yang</a>
13  */

14
15 public class ViewServlet extends SuperServlet {
16
17     public String JavaDoc getTemplate() {
18         return "view.vm";
19     }
20
21     public void buildContext(HttpServletRequest JavaDoc request, Context ctx) throws Exception JavaDoc {
22         // Test Session
23
request.getSession(true).setAttribute("A","B");
24
25         String JavaDoc _componentName = request.getParameter("componentname");
26         ComponentName componentName = ComponentName.parseString(_componentName,getRegistry().getClassLoaderRepository());
27
28         ComponentMeta meta = getRegistry().getComponentMeta(componentName);
29
30         ctx.put("title","Component View");
31         ctx.put("componentMeta",meta);
32
33         if(!ManagableComponent.class.isAssignableFrom(meta.getComponentImplementation())) {
34             ctx.put("managable",false);
35         }
36         else {
37             ctx.put("managable",true);
38             ManagementInfo mgtInfo = meta.getManagementInfo();
39             ctx.put("managementInfo",mgtInfo);
40         }
41         
42     }
43
44     public static void main(String JavaDoc[] args) {
45
46     }
47 }
48
49
Popular Tags