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   */
39  public class PortletManager implements PortletManagerMBean {
40  
41      public PortletManager(
42          ServerStatistics serverStatistics,
43          PortletSummaryStatistics portletSummaryStatistics) {
44  
45          _serverStatistics = serverStatistics;
46          _portletSummaryStatistics = portletSummaryStatistics;
47      }
48  
49      public long getAverageTime() throws MonitoringException {
50          return _portletSummaryStatistics.getAverageTime();
51      }
52  
53      public long getAverageTimeByCompany(long companyId)
54          throws MonitoringException {
55  
56          return _portletSummaryStatistics.getAverageTimeByCompany(companyId);
57      }
58  
59      public long getAverageTimeByCompany(String webId)
60          throws MonitoringException {
61  
62          return _portletSummaryStatistics.getAverageTimeByCompany(webId);
63      }
64  
65      public long getAverageTimeByPortlet(String portletId)
66          throws MonitoringException {
67  
68          return _portletSummaryStatistics.getAverageTimeByPortlet(portletId);
69      }
70  
71      public long getAverageTimeByPortlet(String portletId, long companyId)
72          throws MonitoringException {
73  
74          return _portletSummaryStatistics.getAverageTimeByPortlet(
75              portletId, companyId);
76      }
77  
78      public long getAverageTimeByPortlet(String portletId, String webId)
79          throws MonitoringException {
80  
81          return _portletSummaryStatistics.getAverageTimeByPortlet(
82              portletId, webId);
83      }
84  
85      public long[] getCompanyIds() {
86          Set<Long> companyIds = _serverStatistics.getCompanyIds();
87  
88          return ArrayUtil.toArray(
89              companyIds.toArray(new Long[companyIds.size()]));
90      }
91  
92      public long getErrorCount() throws MonitoringException {
93          return _portletSummaryStatistics.getErrorCount();
94      }
95  
96      public long getErrorCountByCompany(long companyId)
97          throws MonitoringException {
98  
99          return _portletSummaryStatistics.getErrorCountByCompany(companyId);
100     }
101 
102     public long getErrorCountByCompany(String webId)
103         throws MonitoringException {
104 
105         return _portletSummaryStatistics.getErrorCountByCompany(webId);
106     }
107 
108     public long getErrorCountByPortlet(String portletId)
109         throws MonitoringException {
110 
111         return _portletSummaryStatistics.getErrorCountByPortlet(portletId);
112     }
113 
114     public long getErrorCountByPortlet(String portletId, long companyId)
115         throws MonitoringException {
116 
117         return _portletSummaryStatistics.getErrorCountByPortlet(
118             portletId, companyId);
119     }
120 
121     public long getErrorCountByPortlet(String portletId, String webId)
122         throws MonitoringException {
123 
124         return _portletSummaryStatistics.getErrorCountByPortlet(
125             portletId, webId);
126     }
127 
128     public long getMaxTime() throws MonitoringException {
129         return _portletSummaryStatistics.getMaxTime();
130     }
131 
132     public long getMaxTimeByCompany(long companyId) throws MonitoringException {
133         return _portletSummaryStatistics.getMaxTimeByCompany(companyId);
134     }
135 
136     public long getMaxTimeByCompany(String webId) throws MonitoringException {
137         return _portletSummaryStatistics.getMaxTimeByCompany(webId);
138     }
139 
140     public long getMaxTimeByPortlet(String portletId)
141         throws MonitoringException {
142 
143         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId);
144     }
145 
146     public long getMaxTimeByPortlet(String portletId, long companyId)
147         throws MonitoringException {
148 
149         return _portletSummaryStatistics.getMaxTimeByPortlet(
150             portletId, companyId);
151     }
152 
153     public long getMaxTimeByPortlet(String portletId, String webId)
154         throws MonitoringException {
155 
156         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId, webId);
157     }
158 
159     public long getMinTime() throws MonitoringException {
160         return _portletSummaryStatistics.getMinTime();
161     }
162 
163     public long getMinTimeByCompany(long companyId) throws MonitoringException {
164         return _portletSummaryStatistics.getMinTimeByCompany(companyId);
165     }
166 
167     public long getMinTimeByCompany(String webId) throws MonitoringException {
168         return _portletSummaryStatistics.getMinTimeByCompany(webId);
169     }
170 
171     public long getMinTimeByPortlet(String portletId)
172         throws MonitoringException {
173 
174         return _portletSummaryStatistics.getMinTimeByPortlet(portletId);
175     }
176 
177     public long getMinTimeByPortlet(String portletId, long companyId)
178         throws MonitoringException {
179 
180         return _portletSummaryStatistics.getMinTimeByPortlet(
181             portletId, companyId);
182     }
183 
184     public long getMinTimeByPortlet(String portletId, String webId)
185         throws MonitoringException {
186 
187         return _portletSummaryStatistics.getMinTimeByPortlet(portletId, webId);
188     }
189 
190     public String[] getPortletIds() {
191         Set<String> portletIds = _serverStatistics.getPortletIds();
192 
193         return portletIds.toArray(new String[portletIds.size()]);
194     }
195 
196     public long getRequestCount() throws MonitoringException {
197         return _portletSummaryStatistics.getRequestCount();
198     }
199 
200     public long getRequestCountByCompany(long companyId)
201         throws MonitoringException {
202 
203         return _portletSummaryStatistics.getRequestCountByCompany(companyId);
204     }
205 
206     public long getRequestCountByCompany(String webId)
207         throws MonitoringException {
208 
209         return _portletSummaryStatistics.getRequestCountByCompany(webId);
210     }
211 
212     public long getRequestCountByPortlet(String portletId)
213         throws MonitoringException {
214 
215         return _portletSummaryStatistics.getRequestCountByPortlet(portletId);
216     }
217 
218     public long getRequestCountByPortlet(String portletId, long companyId)
219         throws MonitoringException {
220 
221         return _portletSummaryStatistics.getRequestCountByPortlet(
222             portletId, companyId);
223     }
224 
225     public long getRequestCountByPortlet(String portletId, String webId)
226         throws MonitoringException {
227 
228         return _portletSummaryStatistics.getRequestCountByPortlet(
229             portletId, webId);
230     }
231 
232     public long getSuccessCount() throws MonitoringException {
233         return _portletSummaryStatistics.getSuccessCount();
234     }
235 
236     public long getSuccessCountByCompany(long companyId)
237         throws MonitoringException {
238 
239         return _portletSummaryStatistics.getSuccessCountByCompany(companyId);
240     }
241 
242     public long getSuccessCountByCompany(String webId)
243         throws MonitoringException {
244 
245         return _portletSummaryStatistics.getSuccessCountByCompany(webId);
246     }
247 
248     public long getSuccessCountByPortlet(String portletId)
249         throws MonitoringException {
250 
251         return _portletSummaryStatistics.getSuccessCountByPortlet(portletId);
252     }
253 
254     public long getSuccessCountByPortlet(String portletId, long companyId)
255         throws MonitoringException {
256 
257         return _portletSummaryStatistics.getSuccessCountByPortlet(
258             portletId, companyId);
259     }
260 
261     public long getSuccessCountByPortlet(String portletId, String webId)
262         throws MonitoringException {
263 
264         return _portletSummaryStatistics.getSuccessCountByPortlet(
265             portletId, webId);
266     }
267 
268     public long getTimeoutCount() throws MonitoringException {
269         return _portletSummaryStatistics.getTimeoutCount();
270     }
271 
272     public long getTimeoutCountByCompany(long companyId)
273         throws MonitoringException {
274 
275         return _portletSummaryStatistics.getTimeoutCountByCompany(companyId);
276     }
277 
278     public long getTimeoutCountByCompany(String webId)
279         throws MonitoringException {
280 
281         return _portletSummaryStatistics.getTimeoutCountByCompany(webId);
282     }
283 
284     public long getTimeoutCountByPortlet(String portletId)
285         throws MonitoringException {
286 
287         return _portletSummaryStatistics.getTimeoutCountByPortlet(portletId);
288     }
289 
290     public long getTimeoutCountByPortlet(String portletId, long companyId)
291         throws MonitoringException {
292 
293         return _portletSummaryStatistics.getTimeoutCountByPortlet(
294             portletId, companyId);
295     }
296 
297     public long getTimeoutCountByPortlet(String portletId, String webId)
298         throws MonitoringException {
299 
300         return _portletSummaryStatistics.getTimeoutCountByPortlet(
301             portletId, webId);
302     }
303 
304     public String[] getWebIds() {
305         Set<String> webIds = _serverStatistics.getWebIds();
306 
307         return webIds.toArray(new String[webIds.size()]);
308     }
309 
310     public void reset() {
311         _serverStatistics.reset();
312     }
313 
314     public void reset(long companyId) {
315         _serverStatistics.reset(companyId);
316     }
317 
318     public void reset(String webId) {
319         _serverStatistics.reset(webId);
320     }
321 
322     private PortletSummaryStatistics _portletSummaryStatistics;
323     private ServerStatistics _serverStatistics;
324 
325 }