Source Code Cross Referenced for Jsr77ServletHolderMBean.java in  » Sevlet-Container » jetty-extras » org » mortbay » jetty » servlet » jsr77 » management » 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 » Sevlet Container » jetty extras » org.mortbay.jetty.servlet.jsr77.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //========================================================================
002:        //$Id: Jsr77ServletHolderMBean.java 1259 2006-11-19 16:00:48Z janb $
003:        //Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
004:        //------------------------------------------------------------------------
005:        //Licensed under the Apache License, Version 2.0 (the "License");
006:        //you may not use this file except in compliance with the License.
007:        //You may obtain a copy of the License at 
008:        //http://www.apache.org/licenses/LICENSE-2.0
009:        //Unless required by applicable law or agreed to in writing, software
010:        //distributed under the License is distributed on an "AS IS" BASIS,
011:        //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        //See the License for the specific language governing permissions and
013:        //limitations under the License.
014:        //========================================================================
015:
016:        package org.mortbay.jetty.servlet.jsr77.management;
017:
018:        import javax.management.MBeanException;
019:        import javax.management.ObjectName;
020:        import javax.management.j2ee.statistics.ServletStats;
021:
022:        import org.jboss.jetty.JBossWebAppContext;
023:        import org.mortbay.jetty.servlet.jsr77.Jsr77ServletHolder;
024:        import org.mortbay.management.ObjectMBean;
025:        import org.mortbay.log.Log;
026:
027:        /**
028:         * 
029:         * Jsr77ServletHolderMBean
030:         *
031:         * @author janb
032:         * @version $Revision: 1259 $ $Date: 2006-11-19 17:00:48 +0100 (Sun, 19 Nov 2006) $
033:         *
034:         */
035:        public class Jsr77ServletHolderMBean extends ObjectMBean {
036:            private Jsr77ServletHolder _servletHolder = null;
037:            private ServletStats _stats;
038:
039:            public Jsr77ServletHolderMBean(Object managedObject)
040:                    throws MBeanException {
041:                super (managedObject);
042:                _servletHolder = (Jsr77ServletHolder) managedObject;
043:            }
044:
045:            /**StatisticsProvider
046:             * As per the jsr77 spec, we are providing statistics for a
047:             * servlet
048:             * @return true
049:             */
050:            public boolean getStatisticsProvider() {
051:                return true;
052:            }
053:
054:            /**ServletStats
055:             * @return the JSR77 servlet stats for the servlet we represent
056:             */
057:            public ServletStats getStats() {
058:                getJsr77Stats();
059:                return _stats;
060:            }
061:
062:            /**MaxTime
063:             * Necessary for JBoss's JSR77 impl.
064:             * @return the max service time statistic
065:             */
066:            public Long getMaxTime() {
067:                getJsr77Stats();
068:
069:                if (null == _stats)
070:                    return new Long(0L);
071:
072:                return new Long(_stats.getServiceTime().getMaxTime());
073:            }
074:
075:            /**MinTime
076:             * Necessary for JBoss's JSR77 impl.
077:             * @return the min service time statistic
078:             */
079:            public Long getMinTime() {
080:                getJsr77Stats();
081:                if (null == _stats)
082:                    return new Long(0L);
083:
084:                return new Long(_stats.getServiceTime().getMinTime());
085:            }
086:
087:            /**Satisfying JBoss's JSR77 impl
088:             * @return
089:             */
090:            public Long getProcessingTime() {
091:                return new Long(getTotalTime());
092:            }
093:
094:            /**Satisfying JBoss's JSR77 impl
095:             * @return
096:             */
097:            public Integer getRequestCount() {
098:                return new Integer((int) getCount());
099:            }
100:
101:            /**Count
102:             * Convenience method. Also helpful for JBoss's JSR77 impl.
103:             * @return the number of times the servlet service() method has been called.
104:             */
105:            private long getCount() {
106:                getJsr77Stats();
107:                if (null == _stats)
108:                    return 0L;
109:
110:                return _stats.getServiceTime().getCount();
111:            }
112:
113:            /**TotalTime
114:             * Convenience method. Also helpful for JBoss's JSR77 impl.
115:             * @return the total time spent in the servlet's service() method.
116:             */
117:            private long getTotalTime() {
118:                getJsr77Stats();
119:                if (null == _stats)
120:                    return 0L;
121:
122:                return _stats.getServiceTime().getTotalTime();
123:            }
124:
125:            /** Jsr77Stats
126:             * Lookup the statistic object for the servlet we represent.
127:             * Statistics are captured by a filter placed in front of each servlet.
128:             */
129:            private void getJsr77Stats() {
130:                if (null == _stats) {
131:                    if (null == _servletHolder)
132:                        return;
133:
134:                    _stats = _servletHolder.getServletStats();
135:                }
136:            }
137:
138:            public ObjectName getObjectName() {
139:
140:                if (getMBeanContainer() == null)
141:                    return null; //not possible to make a name
142:
143:                String name = _servletHolder.getName();
144:                ObjectName oname = null;
145:                try {
146:                    oname = new ObjectName(
147:                            getMBeanContainer().getDomain()
148:                                    + ":J2EEServer=none,J2EEApplication=none,J2EEWebModule="
149:                                    + ((JBossWebAppContext) _servletHolder
150:                                            .getWebAppContext())
151:                                            .getUniqueName()
152:                                    + ",j2eeType=Servlet,name=" + name);
153:                } catch (Exception e) {
154:                    Log.warn(e);
155:                }
156:                return oname;
157:
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.