Source Code Cross Referenced for Statistic.java in  » Ajax » zk » org » zkoss » zk » ui » util » 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 » Ajax » zk » org.zkoss.zk.ui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Statistic.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Tue Mar 14 23:32:51     2006, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.zk.ui.util;
020:
021:        import java.util.List;
022:
023:        import org.zkoss.zk.ui.Session;
024:        import org.zkoss.zk.ui.Desktop;
025:
026:        /**
027:         * An implementation of {@link Monitor} to accumulate statistic data
028:         * in memory.
029:         *
030:         * <p>It has no effect until you specify it in WEB-INF/zk.xml.
031:         *
032:         * @author tomyeh
033:         */
034:        public class Statistic implements  Monitor {
035:            private final long _startTime;
036:            private int _nsess, _actsess, _ndt, _actdt, _nupd, _actupd;
037:
038:            public Statistic() {
039:                _startTime = System.currentTimeMillis();
040:            }
041:
042:            /** Returns when the server (actually, this monitor) started.
043:             */
044:            public long getStartTime() {
045:                return _startTime;
046:            }
047:
048:            /** Returns the total number of sessions that have been created
049:             * since the server started.
050:             */
051:            public int getTotalSessionCount() {
052:                return _nsess;
053:            }
054:
055:            /** Returns the number of active sessions.
056:             */
057:            public int getActiveSessionCount() {
058:                return _actsess;
059:            }
060:
061:            /** Returns the average number of sessions being created in an hour.
062:             */
063:            public double getAverageSessionCount() {
064:                return _nsess / getEscapedHours();
065:            }
066:
067:            /** Returns the total number of desktops that have been created
068:             * since the server started.
069:             */
070:            public int getTotalDesktopCount() {
071:                return _ndt;
072:            }
073:
074:            /** Returns the number of active desktops.
075:             */
076:            public int getActiveDesktopCount() {
077:                return _actdt;
078:            }
079:
080:            /** Returns the average number of desktops being created in an hour.
081:             */
082:            public double getAverageDesktopCount() {
083:                return _ndt / getEscapedHours();
084:            }
085:
086:            /** Returns the total number of asynchronous updates that have been received
087:             * since the server started.
088:             */
089:            public int getTotalUpdateCount() {
090:                return _nupd;
091:            }
092:
093:            /** Returns the number of active asynchronous updates.
094:             */
095:            public int getActiveUpdateCount() {
096:                return _actupd;
097:            }
098:
099:            /** Returns the average number of asynchronous updates being created
100:             * in an hour.
101:             */
102:            public double getAverageUpdateCount() {
103:                return _nupd / getEscapedHours();
104:            }
105:
106:            /** Returns how many hours escaped since the server started.
107:             */
108:            private double getEscapedHours() {
109:                long v = System.currentTimeMillis() - _startTime;
110:                return ((double) v) / 3600000;
111:            }
112:
113:            //-- Monitor --//
114:            synchronized public void sessionCreated(Session sess) {
115:                ++_nsess;
116:                ++_actsess;
117:            }
118:
119:            synchronized public void sessionDestroyed(Session sess) {
120:                --_actsess;
121:            }
122:
123:            synchronized public void desktopCreated(Desktop desktop) {
124:                ++_ndt;
125:                ++_actdt;
126:            }
127:
128:            synchronized public void desktopDestroyed(Desktop desktop) {
129:                --_actdt;
130:            }
131:
132:            synchronized public void beforeUpdate(Desktop desktop, List requests) {
133:                ++_nupd;
134:                ++_actupd;
135:            }
136:
137:            synchronized public void afterUpdate(Desktop desktop) {
138:                --_actupd;
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.