KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > stats > impl > WebServiceEndpointStatsImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.admin.wsmgmt.stats.impl;
24
25 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
26 import com.sun.appserv.management.j2ee.statistics.StringStatistic;
27 import com.sun.appserv.management.j2ee.statistics.NumberStatistic;
28
29 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl;
30 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl;
31 import com.sun.enterprise.admin.monitor.stats.BoundedRangeStatisticImpl;
32 //import com.sun.enterprise.admin.monitor.stats.StringStatisticImpl;
33
import com.sun.appserv.management.j2ee.statistics.StringStatisticImpl;
34 import com.sun.appserv.management.j2ee.statistics.NumberStatisticImpl;
35
36 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry;
37 import com.sun.enterprise.admin.monitor.registry.MonitoringLevelListener;
38 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel;
39 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException;
40
41 import com.sun.enterprise.admin.wsmgmt.stats.spi.WebServiceEndpointStatsProvider;
42 import com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats;
43
44 import java.util.logging.Logger JavaDoc;
45 import com.sun.enterprise.log.Log;
46 import com.sun.logging.LogDomains;
47 import com.sun.enterprise.util.i18n.StringManager;
48
49 /**
50  * A Class for providing stats for Web Service Endpoint.
51  *
52  * @author Satish Viswanatham
53  */

54 public class WebServiceEndpointStatsImpl
55     extends StatsImpl
56     implements WebServiceEndpointAggregateStats
57 {
58     private WebServiceEndpointStatsProvider delegate;
59
60     private MutableCountStatisticImpl averageResponseTime;
61     private MutableCountStatisticImpl responseTime;
62     private MutableCountStatisticImpl minResponseTime;
63     private MutableCountStatisticImpl maxResponseTime;
64     private MutableCountStatisticImpl totalFaults;
65     private MutableCountStatisticImpl totalSuccesses;
66     private NumberStatisticImpl throughput;
67     private MutableCountStatisticImpl totalAuthFailures;
68     private MutableCountStatisticImpl totalAuthSuccesses;
69     private MutableCountStatisticImpl requestSize;
70     private MutableCountStatisticImpl responseSize;
71     private StringStatisticImpl faultCode;
72     private StringStatisticImpl faultString;
73     private StringStatisticImpl faultActor;
74     private StringStatisticImpl clientHost;
75     private StringStatisticImpl clientUser;
76     private static final StringManager _stringMgr =
77             StringManager.getManager(WebServiceEndpointStatsProvider.class);
78     
79
80     public WebServiceEndpointStatsImpl(
81         WebServiceEndpointStatsProvider delegate){
82         this.delegate = delegate;
83
84         initialize();
85     }
86
87     protected void initialize() {
88        super.initialize(
89        "com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats");
90
91         averageResponseTime = new MutableCountStatisticImpl(
92             new CountStatisticImpl("AverageResponseTime"));
93         minResponseTime = new MutableCountStatisticImpl(
94             new CountStatisticImpl("MinResponseTime"));
95         maxResponseTime = new MutableCountStatisticImpl(
96             new CountStatisticImpl("MaxResponseTime"));
97         responseTime = new MutableCountStatisticImpl(
98             new CountStatisticImpl("ResponseTime"));
99         totalFaults = new MutableCountStatisticImpl(
100             new CountStatisticImpl("TotalFaults"));
101         totalSuccesses = new MutableCountStatisticImpl(
102             new CountStatisticImpl("TotalNumSuccess"));
103         totalAuthFailures = new MutableCountStatisticImpl(
104             new CountStatisticImpl("TotalAuthFailures"));
105         totalAuthSuccesses = new MutableCountStatisticImpl(
106             new CountStatisticImpl("TotalAuthSuccesses"));
107         long t = System.currentTimeMillis();
108         String JavaDoc description = _stringMgr.getString("throughput.description");
109         throughput = new NumberStatisticImpl(
110             "Throughput", description, "Requests Per Second", t, t,
111             new Double JavaDoc(0.0));
112         requestSize = new MutableCountStatisticImpl(
113             new CountStatisticImpl("RequestSize"));
114         responseSize = new MutableCountStatisticImpl(
115             new CountStatisticImpl("ResponseSize"));
116
117     }
118
119     public CountStatistic JavaDoc getAverageResponseTime(){
120         averageResponseTime.setCount(delegate.getAverageResponseTime());
121         return (CountStatistic JavaDoc) averageResponseTime.modifiableView();
122     }
123
124     public CountStatistic JavaDoc getResponseTime(){
125         responseTime.setCount(delegate.getResponseTime());
126         return (CountStatistic JavaDoc) responseTime.modifiableView();
127     }
128
129     public CountStatistic JavaDoc getMinResponseTime(){
130         minResponseTime.setCount(delegate.getMinResponseTime());
131         return (CountStatistic JavaDoc) minResponseTime.modifiableView();
132     }
133
134     public CountStatistic JavaDoc getMaxResponseTime(){
135         maxResponseTime.setCount(delegate.getMaxResponseTime());
136         return (CountStatistic JavaDoc) maxResponseTime.modifiableView();
137     }
138
139     public CountStatistic JavaDoc getTotalFaults(){
140         totalFaults.setCount(delegate.getTotalFailures());
141         return (CountStatistic JavaDoc) totalFaults.modifiableView();
142     }
143
144     public CountStatistic JavaDoc getTotalNumSuccess(){
145         totalSuccesses.setCount(delegate.getTotalSuccesses());
146         return (CountStatistic JavaDoc) totalSuccesses.modifiableView();
147     }
148
149     public CountStatistic JavaDoc getTotalAuthFailures(){
150         totalAuthFailures.setCount(delegate.getTotalAuthFailures());
151         return (CountStatistic JavaDoc) totalAuthFailures.modifiableView();
152     }
153
154     public CountStatistic JavaDoc getTotalAuthSuccesses() {
155         totalAuthSuccesses.setCount(delegate.getTotalAuthSuccesses());
156         return (CountStatistic JavaDoc) totalAuthSuccesses.modifiableView();
157     }
158
159     public NumberStatistic getThroughput(){
160         throughput.setNumber(new Double JavaDoc(delegate.getThroughput()));
161         return (NumberStatistic) throughput;
162     }
163
164 }
165
Popular Tags