Source Code Cross Referenced for ServletStatsDisplayer.java in  » Profiler » MessAdmin » clime » messadmin » providers » userdata » 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 » Profiler » MessAdmin » clime.messadmin.providers.userdata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package clime.messadmin.providers.userdata;
004:
005:        import java.text.NumberFormat;
006:        import java.util.ArrayList;
007:        import java.util.Collections;
008:        import java.util.HashMap;
009:        import java.util.Iterator;
010:        import java.util.List;
011:        import java.util.Map;
012:
013:        import javax.servlet.ServletContext;
014:        import javax.servlet.http.HttpSession;
015:
016:        import clime.messadmin.i18n.I18NSupport;
017:        import clime.messadmin.model.Application;
018:        import clime.messadmin.model.RequestInfo;
019:        import clime.messadmin.model.Server;
020:        import clime.messadmin.model.Session;
021:        import clime.messadmin.providers.spi.ApplicationDataProvider;
022:        import clime.messadmin.providers.spi.BaseTabularDataProvider;
023:        import clime.messadmin.providers.spi.SessionDataProvider;
024:        import clime.messadmin.providers.spi.SizeOfProvider;
025:        import clime.messadmin.servletstats.RequestInfoTimeComparator;
026:        import clime.messadmin.servletstats.Utils;
027:        import clime.messadmin.utils.BytesFormat;
028:
029:        /**
030:         * @author Cédrik LIME
031:         */
032:        public class ServletStatsDisplayer extends BaseTabularDataProvider
033:                implements  ApplicationDataProvider, SessionDataProvider {
034:            private static final String BUNDLE_NAME = ServletStatsDisplayer.class
035:                    .getName();
036:
037:            /**
038:             * 
039:             */
040:            public ServletStatsDisplayer() {
041:                super ();
042:            }
043:
044:            /****************************************************************/
045:            /*							Common methods						*/
046:            /****************************************************************/
047:
048:            public String[] getTabularDataLabels(ClassLoader cl) {
049:                return new String[] {
050:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
051:                                "label.url"),//$NON-NLS-1$
052:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
053:                                "label.n_errors"),//$NON-NLS-1$
054:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
055:                                "label.n_hits"),//$NON-NLS-1$
056:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
057:                                "label.used_time.mean"),//$NON-NLS-1$
058:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
059:                                "label.used_time.std_dev"),//$NON-NLS-1$
060:                        I18NSupport.getLocalizedMessage(BUNDLE_NAME, cl,
061:                                "label.used_time.total") //$NON-NLS-1$
062:                };
063:            }
064:
065:            protected String getTableCaption(String[] labels,
066:                    Object[][] values, ClassLoader cl) {
067:                NumberFormat numberFormatter = NumberFormat
068:                        .getNumberInstance(I18NSupport.getAdminLocale());
069:                String caption = I18NSupport
070:                        .getLocalizedMessage(
071:                                BUNDLE_NAME,
072:                                cl,
073:                                "table.caption", new Object[] { numberFormatter.format(values.length) });//$NON-NLS-1$
074:                return caption;
075:            }
076:
077:            protected String getDataTitle(Map data, ClassLoader cl) {
078:                NumberFormat bytesFormatter = BytesFormat.getBytesInstance(
079:                        I18NSupport.getAdminLocale(), " ");//$NON-NLS-1$
080:                long currentItemSize = SizeOfProvider.Util.getObjectSize(data,
081:                        cl);
082:                String result = I18NSupport
083:                        .getLocalizedMessage(
084:                                BUNDLE_NAME,
085:                                cl,
086:                                "title", new Object[] { bytesFormatter.format(currentItemSize) });//$NON-NLS-1$
087:                return result;
088:            }
089:
090:            protected Object[][] getTabularData(Map data) {
091:                NumberFormat numberFormatter = NumberFormat
092:                        .getNumberInstance(I18NSupport.getAdminLocale());
093:                List inputList = new ArrayList(data.values());
094:                List resultList = new ArrayList(data.size());
095:                // sort data by total used time
096:                Collections.sort(inputList, new RequestInfoTimeComparator());
097:                Iterator iter = inputList.iterator();
098:                while (iter.hasNext()) {
099:                    RequestInfo request = (RequestInfo) iter.next();
100:                    resultList
101:                            .add(new Object[] {
102:                                    request.getURL(),
103:                                    request.getNErrors() > 0 ? "<span style=\"color: red; font-weight: bolder;\">" + numberFormatter.format(request.getNErrors()) + "</span>"//$NON-NLS-1$//$NON-NLS-2$
104:                                            : numberFormatter.format(request
105:                                                    .getNErrors()),
106:                                    numberFormatter.format(request.getHits()),
107:                                    numberFormatter.format(request
108:                                            .getMeanUsedTime())
109:                                            + " ms",
110:                                    numberFormatter.format(request
111:                                            .getStdDevUsedTime())
112:                                            + " ms",
113:                                    numberFormatter.format(request
114:                                            .getTotalUsedTime())
115:                                            + " ms" });
116:                }
117:                Object[][] result = new Object[resultList.size()][];
118:                return (Object[][]) resultList.toArray(result);
119:            }
120:
121:            /**
122:             * {@inheritDoc}
123:             */
124:            public int getPriority() {
125:                return 0;
126:            }
127:
128:            /****************************************************************/
129:            /*							Session methods						*/
130:            /****************************************************************/
131:
132:            public Object[][] getSessionTabularData(HttpSession httpSession) {
133:                Session session = Server.getInstance().getApplication(
134:                        httpSession.getServletContext()).getSession(
135:                        httpSession.getId());
136:                Map data = new HashMap(Utils.getPluginData(session));
137:                Object[][] result = getTabularData(data);
138:                return result;
139:            }
140:
141:            /**
142:             * {@inheritDoc}
143:             */
144:            public String getSessionDataTitle(HttpSession httpSession) {
145:                Application application = Server.getInstance().getApplication(
146:                        httpSession.getServletContext());
147:                Session session = application.getSession(httpSession.getId());
148:                Map data = new HashMap(Utils.getPluginData(session));
149:                String result = getDataTitle(data, application
150:                        .getApplicationInfo().getClassLoader());
151:                return result;
152:            }
153:
154:            /**
155:             * {@inheritDoc}
156:             */
157:            public String getXHTMLSessionData(HttpSession session) {
158:                try {
159:                    ClassLoader cl = getClassLoader(session);
160:                    String[] labels = getTabularDataLabels(cl);
161:                    Object[][] values = getSessionTabularData(session);
162:                    return buildXHTML(
163:                            labels,
164:                            values,
165:                            "extraSessionAttributesTable-" + getClass().getName(), getTableCaption(labels, values, cl));//$NON-NLS-1$
166:                } catch (RuntimeException rte) {
167:                    return "Error in " + this .getClass().getName() + ": " + rte;
168:                }
169:            }
170:
171:            /****************************************************************/
172:            /*						Application methods						*/
173:            /****************************************************************/
174:
175:            public Object[][] getApplicationTabularData(ServletContext context) {
176:                Application application = Server.getInstance().getApplication(
177:                        context);
178:                Map data = new HashMap(Utils.getPluginData(application));
179:                Object[][] result = getTabularData(data);
180:                return result;
181:            }
182:
183:            /**
184:             * {@inheritDoc}
185:             */
186:            public String getApplicationDataTitle(ServletContext context) {
187:                Application application = Server.getInstance().getApplication(
188:                        context);
189:                Map data = new HashMap(Utils.getPluginData(application));
190:                String result = getDataTitle(data, application
191:                        .getApplicationInfo().getClassLoader());
192:                return result;
193:            }
194:
195:            /**
196:             * {@inheritDoc}
197:             */
198:            public String getXHTMLApplicationData(ServletContext context) {
199:                try {
200:                    ClassLoader cl = getClassLoader(context);
201:                    String[] labels = getTabularDataLabels(cl);
202:                    Object[][] values = getApplicationTabularData(context);
203:                    return buildXHTML(
204:                            labels,
205:                            values,
206:                            "extraApplicationAttributesTable-" + getClass().getName(), getTableCaption(labels, values, cl));//$NON-NLS-1$
207:                } catch (RuntimeException rte) {
208:                    return "Error in " + this .getClass().getName() + ": " + rte;
209:                }
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.