1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package com.mjh.switchrmi.protocol.html;
27
28 import com.mjh.switchrmi.*;
29 import com.mjh.switchrmi.jndi.*;
30
31 import java.io.*;
32
33 import java.util.*;
34
35 import javax.naming.*;
36
37 public class HtmlIndexResponse
38 extends HtmlResponse
39 {
40 public HtmlIndexResponse()
41 {
42 }
43
44 public HtmlIndexResponse(InputStream in)
45 {
46 super(in);
47 }
48
49 protected String toHtmlString()
50 throws Exception
51 {
52 Context jndiCtx = context.getJndiContext();
53 Context ctx = (Context) jndiCtx.lookup("/switchrmi/service/object");
54 Hashtable env = ctx.getEnvironment();
55
56 Collection names = new TreeSet(env.keySet());
57
58 StringBuffer sb = new StringBuffer();
59
60 sb.append("<html>\n");
61 sb.append("<head>\n");
62 sb.append(" <title>SwitchRMI Inspector</title>\n");
63 appendStyles(sb);
64 sb.append("</head>\n");
65 sb.append("<body bgcolor=\"lightsteelblue\">\n");
66 sb.append("<p class=\"heading\">\n");
67 sb.append("SwitchRMI Deployed Objects\n");
68 sb.append("<p>\n");
69 sb.append("The following objects are deployed in this instance. Click on the object name\n");
70 sb.append("for further detail.\n");
71 sb.append("<p>\n");
72 sb.append("<table border=\1\" cellpadding=\"2\" cellspacing=\"0\">\n");
73 sb.append(" <tr>\n");
74 sb.append(" <th valign=\"top\" align=\"center\" >Name</th>\n");
75 sb.append(" <th valign=\"top\" align=\"center\" >Description</th>\n");
76 sb.append(" </tr>\n");
77
78 Iterator iterator = names.iterator();
79
80 while (iterator.hasNext())
81 {
82 String name = (String) iterator.next();
83 ObjectReferenceable ref = (ObjectReferenceable) env.get(name);
84
85 sb.append(" <tr>\n");
86 sb.append(" <td valign=\"top\" ><a href=\"" + name + ".html\">"
87 + name + "</a></td>\n");
88 sb.append(" <td valign=\"top\" >" + ref.getDescription()
89 + "</td>\n");
90 sb.append(" </tr>\n");
91 }
92
93 sb.append("</table>\n");
94
95 sb.append("</body>\n");
96 sb.append("</html>\n");
97
98 htmlString = sb.toString();
99
100 return htmlString;
101 }
102
103 public Object getObject()
104 {
105 return htmlString;
106 }
107 }