Source Code Cross Referenced for ThreadStatFrame.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » status » 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 » Web Server » Jigsaw » org.w3c.jigsaw.status 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ThreadStatFrame.java
002:        // $Id: ThreadStatFrame.java,v 1.8 2000/08/16 21:37:48 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.status;
007:
008:        import java.util.Hashtable;
009:
010:        import org.w3c.tools.resources.Attribute;
011:        import org.w3c.tools.resources.AttributeRegistry;
012:        import org.w3c.tools.resources.FramedResource;
013:        import org.w3c.tools.resources.IntegerAttribute;
014:        import org.w3c.tools.resources.Resource;
015:        import org.w3c.tools.resources.ResourceFrame;
016:
017:        import org.w3c.www.http.HTTP;
018:
019:        import org.w3c.jigsaw.http.HTTPException;
020:        import org.w3c.jigsaw.http.Reply;
021:        import org.w3c.jigsaw.http.Request;
022:
023:        import org.w3c.jigsaw.frames.HTTPFrame;
024:
025:        import org.w3c.jigsaw.html.HtmlGenerator;
026:
027:        /**
028:         * The server thread status.
029:         * This ought to be the client status, it will shortly (FIXME). It should uses
030:         * a two frame display, one listing the clients, and the other one listing per
031:         * client informations.
032:         * <p>By the Way, this uses the nasty refresh stuff from netscape. It should
033:         * perhaps be a servlet.
034:         */
035:
036:        public class ThreadStatFrame extends HTTPFrame {
037:            protected static Integer REFRESH_DEFAULT = new Integer(5);
038:
039:            /**
040:             * Attribute index - Our refresh interval.
041:             */
042:            protected static int ATTR_REFRESH = -1;
043:
044:            static {
045:                Attribute a = null;
046:                Class cls = null;
047:                try {
048:                    cls = Class
049:                            .forName("org.w3c.jigsaw.status.ThreadStatFrame");
050:                } catch (Exception ex) {
051:                    ex.printStackTrace();
052:                    System.exit(1);
053:                }
054:                // The refresh interval attribute:
055:                a = new IntegerAttribute("refresh", new Integer(5),
056:                        Attribute.EDITABLE);
057:                ATTR_REFRESH = AttributeRegistry.registerAttribute(cls, a);
058:            }
059:
060:            Runtime runtime = null;
061:
062:            public void registerResource(FramedResource resource) {
063:                super .registerOtherResource(resource);
064:            }
065:
066:            /**
067:             * Dump the currenr threads into an HTML page.
068:             * @param request The request we are to reply to.
069:             */
070:            public Reply listThreads(Request request) {
071:                // enumerate all thread, and return a full thread listing:
072:                int tcount = Thread.activeCount();
073:                HtmlGenerator g = new HtmlGenerator("Thread status");
074:                g.meta("Refresh", getValue(ATTR_REFRESH, REFRESH_DEFAULT)
075:                        .toString());
076:                addStyleSheet(g);
077:                // Dump thread informations:
078:                Thread tarray[] = new Thread[tcount];
079:                Thread.enumerate(tarray);
080:                g.append("<h1>Thread dump</h1>");
081:                g.append("<ul>");
082:                String rname = getResource().getIdentifier();
083:                for (int i = 0; i < tcount; i++) {
084:                    String name = tarray[i].getName();
085:                    g.append("<li>" + "<a href=\"" + rname + "?" + name + "\">"
086:                            + name + "</a>"
087:                            + (tarray[i].isDaemon() ? "D " : "  ")
088:                            + (tarray[i].isAlive() ? "R " : "  ") + " Prio: "
089:                            + (tarray[i].getPriority()));
090:                }
091:                g.append("</ul>");
092:                // Dark features:
093:                g
094:                        .append("<p>To kill a thread, add a <b>?</b><em>thread-name</em> "
095:                                + "to the current URL.</p>");
096:                // Add global java process informations:
097:                g.append("<h2>Misc informations</h2>");
098:                g.append("<p>Total free memory: " + runtime.freeMemory());
099:                g.append("<p>Toal memory      : " + runtime.totalMemory());
100:                g.close();
101:                // Reply back:
102:                Reply reply = request.makeReply(HTTP.OK);
103:                reply.setStream(g);
104:                return reply;
105:            }
106:
107:            protected Reply dumpThread(Request request) throws HTTPException {
108:                // enumerate all thread, and return a full thread listing:
109:                int tcount = Thread.activeCount();
110:                Thread tarray[] = new Thread[tcount];
111:                Thread.enumerate(tarray);
112:                // Find ZE thread
113:                String tname = request.getQueryString();
114:                Thread queried = null;
115:                for (int i = 0; i < tcount; i++) {
116:                    if (tarray[i].getName().equals(tname)) {
117:                        queried = tarray[i];
118:                        break;
119:                    }
120:                }
121:                if (queried == null) {
122:                    Reply reply = request.makeReply(HTTP.NOT_FOUND);
123:                    reply.setContent("Thread " + tname + " not found.");
124:                    return reply;
125:                }
126:                // Default to killing the thread
127:                queried.destroy();
128:                return listThreads(request);
129:            }
130:
131:            /**
132:             * Get the threads.
133:             * If a search string is present, kill the indicated thread, otherwise
134:             * list the currently running threads.
135:             * @param request The request to handle.
136:             * @exception HTTPException If processing the request failed.
137:             */
138:            public Reply get(Request request) throws HTTPException {
139:                if (request.hasQueryString()) {
140:                    return dumpThread(request);
141:                } else {
142:                    return listThreads(request);
143:                }
144:            }
145:
146:            /**
147:             * Initialize the thread lister.
148:             * Just get a pointer to our runtime object.
149:             * @param values The default attribute values.
150:             */
151:            public void initialize(Object values[]) {
152:                super.initialize(values);
153:                runtime = Runtime.getRuntime();
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.