Source Code Cross Referenced for ViewClassBean.java in  » J2EE » openejb3 » org » apache » openejb » webadmin » clienttools » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » openejb3 » org.apache.openejb.webadmin.clienttools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.webadmin.clienttools;
017:
018:        import java.io.IOException;
019:        import java.io.PrintWriter;
020:        import java.lang.reflect.Method;
021:        import java.lang.reflect.Modifier;
022:
023:        import org.apache.openejb.webadmin.HttpRequest;
024:        import org.apache.openejb.webadmin.HttpResponse;
025:        import org.apache.openejb.webadmin.WebAdminBean;
026:        import org.apache.openejb.webadmin.HttpHome;
027:
028:        import javax.ejb.Stateless;
029:        import javax.ejb.RemoteHome;
030:
031:        /**
032:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
033:         */
034:        @Stateless(name="ClientTools/ViewClass")
035:        @RemoteHome(HttpHome.class)
036:        public class ViewClassBean extends WebAdminBean implements  Constants {
037:
038:            boolean hasMethods;
039:
040:            public void preProcess(HttpRequest request, HttpResponse response)
041:                    throws IOException {
042:            }
043:
044:            public void postProcess(HttpRequest request, HttpResponse response)
045:                    throws IOException {
046:            }
047:
048:            public void writeHtmlTitle(PrintWriter out) throws IOException {
049:                out.write("Client Tools -- JNDI Viewer");
050:            }
051:
052:            public void writePageTitle(PrintWriter out) throws IOException {
053:                out.write("JNDI Viewer");
054:            }
055:
056:            public void writeBody(PrintWriter out) throws IOException {
057:                try {
058:                    String className = request.getQueryParameter("class");
059:                    if (className == null) {
060:                        out.print("<b>Enter a class name to browse:</b>");
061:                        out.print("<FORM NAME='view' METHOD='GET' ACTION='"
062:                                + VIEW_CLASS + "'>");
063:                        out
064:                                .print("<INPUT type='text' NAME='class' size='40' VALUE=''>");
065:                        out
066:                                .print("<INPUT type='SUBMIT' NAME='view' value='View'>");
067:                        out.print("</form>");
068:                        out
069:                                .print("<b>Or browse one of these fun classes:</b><br><br>");
070:                        out.print(tab + getClassRef("javax.ejb.EJBHome")
071:                                + "<br>");
072:                        out.print(tab + getClassRef("javax.ejb.EJBObject")
073:                                + "<br>");
074:                        out.print(tab + getClassRef("javax.ejb.EnterpriseBean")
075:                                + "<br>");
076:                        out.print(tab + getClassRef("javax.ejb.SessionBean")
077:                                + "<br>");
078:                        out.print(tab + getClassRef("javax.ejb.EntityBean")
079:                                + "<br>");
080:                        out.print(tab
081:                                + getClassRef("javax.servlet.http.HttpServlet")
082:                                + "<br>");
083:                        out
084:                                .print(tab
085:                                        + getClassRef("javax.servlet.http.HttpServletRequest")
086:                                        + "<br>");
087:                        out
088:                                .print(tab
089:                                        + getClassRef("javax.servlet.http.HttpServletResponse")
090:                                        + "<br>");
091:                        out.print(tab
092:                                + getClassRef("javax.servlet.http.HttpSession")
093:                                + "<br>");
094:                        out.print(tab
095:                                + getClassRef("javax.naming.InitialContext")
096:                                + "<br>");
097:                        out.print(tab + getClassRef("javax.naming.Context")
098:                                + "<br>");
099:
100:                    } else {
101:                        Class clazz = this .getClass().forName(className);
102:                        printClass(clazz, out);
103:                    }
104:                } catch (Exception e) {
105:                    out.println("FAIL");
106:                    return;
107:                }
108:                out.print("<BR><BR>");
109:                if (hasMethods) {
110:                    out
111:                            .print("<font color='green'>*</font>&nbsp;Public &nbsp; ");
112:                    out.print("<font color='red'>*</font>&nbsp;Private &nbsp;");
113:                    out
114:                            .print("<font color='blue'>*</font>&nbsp;Protected &nbsp;");
115:                    out.print("<font color='yellow'>*</font>&nbsp;Default ");
116:                    out.print("<BR>");
117:                }
118:            }
119:
120:            public void printClass(Class clazz, PrintWriter out)
121:                    throws Exception {
122:                out.print("<b>" + clazz.getName() + "</b><br>");
123:                Method[] methods = clazz.getDeclaredMethods();
124:                hasMethods = (methods.length > 0);
125:                for (int i = 0; i < methods.length; i++) {
126:                    printMethod(methods[i], out);
127:                }
128:
129:                /*
130:                 * //out.print("&nbsp;&nbsp; <font color='gray'><u> Public Methods:
131:                 * </u></font><br> "); for (int i=0; i < methods.length; i++){ if
132:                 * (Modifier.isPublic(methods[i].getModifiers())){ printMethod(
133:                 * methods[i], out ); } } //out.print("&nbsp;&nbsp; <font color='gray'>
134:                 * <u> Private Methods: </u></font><br> "); for (int i=0; i
135:                 * < methods.length; i++){ if
136:                 * (Modifier.isPrivate(methods[i].getModifiers())){ printMethod(
137:                 * methods[i], out ); } } for (int i=0; i < methods.length; i++){ if
138:                 * (Modifier.isProtected(methods[i].getModifiers())){ printMethod(
139:                 * methods[i], out ); } } for (int i=0; i < methods.length; i++){ if
140:                 * (!Modifier.isSrict(methods[i].getModifiers())){ printMethod(
141:                 * methods[i], out ); } }
142:                 */
143:                Class sup = clazz.getSuperclass();
144:                if (sup != null) {
145:                    out.print("<br><b>Extends:</b><br>");
146:                    out.print(tab + getClassRef(sup) + "<br>");
147:                }
148:
149:                Class[] intf = clazz.getInterfaces();
150:
151:                if (intf.length > 0) {
152:                    out.print("<br><b>Implements:</b><br>");
153:                    for (int i = 0; i < intf.length; i++) {
154:                        out.print(tab + getClassRef(intf[i]) + "<br>");
155:                    }
156:                }
157:            }
158:
159:            public void printMethod(Method m, PrintWriter out) throws Exception {
160:                out.print(tab);
161:                out.print(" " + getModifier(m));
162:
163:                out.print(" " + getShortClassRef(m.getReturnType())
164:                        + "&nbsp;&nbsp;");
165:
166:                out.print("" + m.getName() + "&nbsp;");
167:                Class[] params = m.getParameterTypes();
168:                out.print("<font color='gray'>(</font>");
169:                for (int j = 0; j < params.length; j++) {
170:                    out.print(getShortClassRef(params[j]));
171:                    if (j != params.length - 1) {
172:                        out.print(",&nbsp;");
173:                    }
174:                }
175:                out.print("<font color='gray'>)</font>");
176:
177:                Class[] excp = m.getExceptionTypes();
178:                if (excp.length > 0) {
179:                    out.print(" <font color='gray'>throws</font>&nbsp;&nbsp;");
180:                    for (int j = 0; j < excp.length; j++) {
181:                        out.print(getShortClassRef(excp[j]));
182:                        if (j != excp.length - 1) {
183:                            out.print(",&nbsp;");
184:                        }
185:                    }
186:                }
187:                out.print("<br>");
188:            }
189:
190:            public String getModifier(Method m) throws Exception {
191:                int mod = m.getModifiers();
192:                String color = "";
193:
194:                if (Modifier.isPublic(mod)) {
195:                    color = "green";
196:                } else if (Modifier.isPrivate(mod)) {
197:                    color = "red";
198:                } else if (Modifier.isProtected(mod)) {
199:                    color = "blue";
200:                } else {
201:                    color = "yellow";
202:                }
203:                return "<font color='" + color + "'>*</font>";
204:            }
205:
206:            public String getClassRef(Class clazz) throws Exception {
207:                String name = clazz.getName();
208:                return "<a href='" + VIEW_CLASS + "?class=" + name + "'>"
209:                        + name + "</a>";
210:            }
211:
212:            public String getClassRef(String name) throws Exception {
213:                return "<a href='" + VIEW_CLASS + "?class=" + name + "'>"
214:                        + name + "</a>";
215:            }
216:
217:            public String getShortClassRef(Class clazz) throws Exception {
218:                if (clazz.isPrimitive()) {
219:                    return "<font color='gray'>" + clazz.getName() + "</font>";
220:                } else if (clazz.isArray()
221:                        && clazz.getComponentType().isPrimitive()) {
222:                    return "<font color='gray'>" + clazz.getComponentType()
223:                            + "[]</font>";
224:                } else if (clazz.isArray()) {
225:                    String name = clazz.getComponentType().getName();
226:                    int dot = name.lastIndexOf(".") + 1;
227:                    String shortName = name.substring(dot, name.length());
228:                    return "<a href='" + VIEW_CLASS + "?class=" + name + "'>"
229:                            + shortName + "[]</a>";
230:                } else {
231:                    String name = clazz.getName();
232:                    int dot = name.lastIndexOf(".") + 1;
233:                    String shortName = name.substring(dot, name.length());
234:                    return "<a href='" + VIEW_CLASS + "?class=" + name + "'>"
235:                            + shortName + "</a>";
236:                }
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.