1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.monitoring.jmx;
24  
25  import com.liferay.portal.kernel.util.ArrayUtil;
26  import com.liferay.portal.monitoring.MonitoringException;
27  import com.liferay.portal.monitoring.statistics.portlet.PortletSummaryStatistics;
28  import com.liferay.portal.monitoring.statistics.portlet.ServerStatistics;
29  
30  import java.util.Set;
31  
32  /**
33   * <a href="PortletManager.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Michael C. Han
36   * @author Brian Wing Shun Chan
37   */
38  public class PortletManager implements PortletManagerMBean {
39  
40      public long getAverageTime() throws MonitoringException {
41          return _portletSummaryStatistics.getAverageTime();
42      }
43  
44      public long getAverageTimeByCompany(long companyId)
45          throws MonitoringException {
46  
47          return _portletSummaryStatistics.getAverageTimeByCompany(companyId);
48      }
49  
50      public long getAverageTimeByCompany(String webId)
51          throws MonitoringException {
52  
53          return _portletSummaryStatistics.getAverageTimeByCompany(webId);
54      }
55  
56      public long getAverageTimeByPortlet(String portletId)
57          throws MonitoringException {
58  
59          return _portletSummaryStatistics.getAverageTimeByPortlet(portletId);
60      }
61  
62      public long getAverageTimeByPortlet(String portletId, long companyId)
63          throws MonitoringException {
64  
65          return _portletSummaryStatistics.getAverageTimeByPortlet(
66              portletId, companyId);
67      }
68  
69      public long getAverageTimeByPortlet(String portletId, String webId)
70          throws MonitoringException {
71  
72          return _portletSummaryStatistics.getAverageTimeByPortlet(
73              portletId, webId);
74      }
75  
76      public long[] getCompanyIds() {
77          Set<Long> companyIds = _serverStatistics.getCompanyIds();
78  
79          return ArrayUtil.toArray(
80              companyIds.toArray(new Long[companyIds.size()]));
81      }
82  
83      public long getErrorCount() throws MonitoringException {
84          return _portletSummaryStatistics.getErrorCount();
85      }
86  
87      public long getErrorCountByCompany(long companyId)
88          throws MonitoringException {
89  
90          return _portletSummaryStatistics.getErrorCountByCompany(companyId);
91      }
92  
93      public long getErrorCountByCompany(String webId)
94          throws MonitoringException {
95  
96          return _portletSummaryStatistics.getErrorCountByCompany(webId);
97      }
98  
99      public long getErrorCountByPortlet(String portletId)
100         throws MonitoringException {
101 
102         return _portletSummaryStatistics.getErrorCountByPortlet(portletId);
103     }
104 
105     public long getErrorCountByPortlet(String portletId, long companyId)
106         throws MonitoringException {
107 
108         return _portletSummaryStatistics.getErrorCountByPortlet(
109             portletId, companyId);
110     }
111 
112     public long getErrorCountByPortlet(String portletId, String webId)
113         throws MonitoringException {
114 
115         return _portletSummaryStatistics.getErrorCountByPortlet(
116             portletId, webId);
117     }
118 
119     public long getMaxTime() throws MonitoringException {
120         return _portletSummaryStatistics.getMaxTime();
121     }
122 
123     public long getMaxTimeByCompany(long companyId) throws MonitoringException {
124         return _portletSummaryStatistics.getMaxTimeByCompany(companyId);
125     }
126 
127     public long getMaxTimeByCompany(String webId) throws MonitoringException {
128         return _portletSummaryStatistics.getMaxTimeByCompany(webId);
129     }
130 
131     public long getMaxTimeByPortlet(String portletId)
132         throws MonitoringException {
133 
134         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId);
135     }
136 
137     public long getMaxTimeByPortlet(String portletId, long companyId)
138         throws MonitoringException {
139 
140         return _portletSummaryStatistics.getMaxTimeByPortlet(
141             portletId, companyId);
142     }
143 
144     public long getMaxTimeByPortlet(String portletId, String webId)
145         throws MonitoringException {
146 
147         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId, webId);
148     }
149 
150     public long getMinTime() throws MonitoringException {
151         return _portletSummaryStatistics.getMinTime();
152     }
153 
154     public long getMinTimeByCompany(long companyId) throws MonitoringException {
155         return _portletSummaryStatistics.getMinTimeByCompany(companyId);
156     }
157 
158     public long getMinTimeByCompany(String webId) throws MonitoringException {
159         return _portletSummaryStatistics.getMinTimeByCompany(webId);
160     }
161 
162     public long getMinTimeByPortlet(String portletId)
163         throws MonitoringException {
164 
165         return _portletSummaryStatistics.getMinTimeByPortlet(portletId);
166     }
167 
168     public long getMinTimeByPortlet(String portletId, long companyId)
169         throws MonitoringException {
170 
171         return _portletSummaryStatistics.getMinTimeByPortlet(
172             portletId, companyId);
173     }
174 
175     public long getMinTimeByPortlet(String portletId, String webId)
176         throws MonitoringException {
177 
178         return _portletSummaryStatistics.getMinTimeByPortlet(portletId, webId);
179     }
180 
181     public String[] getPortletIds() {
182         Set<String> portletIds = _serverStatistics.getPortletIds();
183 
184         return portletIds.toArray(new String[portletIds.size()]);
185     }
186 
187     public long getRequestCount() throws MonitoringException {
188         return _portletSummaryStatistics.getRequestCount();
189     }
190 
191     public long getRequestCountByCompany(long companyId)
192         throws MonitoringException {
193 
194         return _portletSummaryStatistics.getRequestCountByCompany(companyId);
195     }
196 
197     public long getRequestCountByCompany(String webId)
198         throws MonitoringException {
199 
200         return _portletSummaryStatistics.getRequestCountByCompany(webId);
201     }
202 
203     public long getRequestCountByPortlet(String portletId)
204         throws MonitoringException {
205 
206         return _portletSummaryStatistics.getRequestCountByPortlet(portletId);
207     }
208 
209     public long getRequestCountByPortlet(String portletId, long companyId)
210         throws MonitoringException {
211 
212         return _portletSummaryStatistics.getRequestCountByPortlet(
213             portletId, companyId);
214     }
215 
216     public long getRequestCountByPortlet(String portletId, String webId)
217         throws MonitoringException {
218 
219         return _portletSummaryStatistics.getRequestCountByPortlet(
220             portletId, webId);
221     }
222 
223     public long getSuccessCount() throws MonitoringException {
224         return _portletSummaryStatistics.getSuccessCount();
225     }
226 
227     public long getSuccessCountByCompany(long companyId)
228         throws MonitoringException {
229 
230         return _portletSummaryStatistics.getSuccessCountByCompany(companyId);
231     }
232 
233     public long getSuccessCountByCompany(String webId)
234         throws MonitoringException {
235 
236         return _portletSummaryStatistics.getSuccessCountByCompany(webId);
237     }
238 
239     public long getSuccessCountByPortlet(String portletId)
240         throws MonitoringException {
241 
242         return _portletSummaryStatistics.getSuccessCountByPortlet(portletId);
243     }
244 
245     public long getSuccessCountByPortlet(String portletId, long companyId)
246         throws MonitoringException {
247 
248         return _portletSummaryStatistics.getSuccessCountByPortlet(
249             portletId, companyId);
250     }
251 
252     public long getSuccessCountByPortlet(String portletId, String webId)
253         throws MonitoringException {
254 
255         return _portletSummaryStatistics.getSuccessCountByPortlet(
256             portletId, webId);
257     }
258 
259     public long getTimeoutCount() throws MonitoringException {
260         return _portletSummaryStatistics.getTimeoutCount();
261     }
262 
263     public long getTimeoutCountByCompany(long companyId)
264         throws MonitoringException {
265 
266         return _portletSummaryStatistics.getTimeoutCountByCompany(companyId);
267     }
268 
269     public long getTimeoutCountByCompany(String webId)
270         throws MonitoringException {
271 
272         return _portletSummaryStatistics.getTimeoutCountByCompany(webId);
273     }
274 
275     public long getTimeoutCountByPortlet(String portletId)
276         throws MonitoringException {
277 
278         return _portletSummaryStatistics.getTimeoutCountByPortlet(portletId);
279     }
280 
281     public long getTimeoutCountByPortlet(String portletId, long companyId)
282         throws MonitoringException {
283 
284         return _portletSummaryStatistics.getTimeoutCountByPortlet(
285             portletId, companyId);
286     }
287 
288     public long getTimeoutCountByPortlet(String portletId, String webId)
289         throws MonitoringException {
290 
291         return _portletSummaryStatistics.getTimeoutCountByPortlet(
292             portletId, webId);
293     }
294 
295     public String[] getWebIds() {
296         Set<String> webIds = _serverStatistics.getWebIds();
297 
298         return webIds.toArray(new String[webIds.size()]);
299     }
300 
301     public void reset() {
302         _serverStatistics.reset();
303     }
304 
305     public void reset(long companyId) {
306         _serverStatistics.reset(companyId);
307     }
308 
309     public void reset(String webId) {
310         _serverStatistics.reset(webId);
311     }
312 
313     public void setPortletSummaryStatistics(
314         PortletSummaryStatistics portletSummaryStatistics) {
315 
316         _portletSummaryStatistics = portletSummaryStatistics;
317     }
318 
319     public void setServerStatistics(ServerStatistics serverStatistics) {
320         _serverStatistics = serverStatistics;
321     }
322 
323     private PortletSummaryStatistics _portletSummaryStatistics;
324     private ServerStatistics _serverStatistics;
325 
326 }