001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.monitoring.jmx;
016    
017    import com.liferay.portal.kernel.monitoring.MonitoringException;
018    import com.liferay.portal.kernel.util.ArrayUtil;
019    import com.liferay.portal.monitoring.statistics.portlet.PortletSummaryStatistics;
020    import com.liferay.portal.monitoring.statistics.portlet.ServerStatistics;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Michael C. Han
026     * @author Brian Wing Shun Chan
027     */
028    public class PortletManager implements PortletManagerMBean {
029    
030            @Override
031            public long getAverageTime() throws MonitoringException {
032                    return _portletSummaryStatistics.getAverageTime();
033            }
034    
035            @Override
036            public long getAverageTimeByCompany(long companyId)
037                    throws MonitoringException {
038    
039                    return _portletSummaryStatistics.getAverageTimeByCompany(companyId);
040            }
041    
042            @Override
043            public long getAverageTimeByCompany(String webId)
044                    throws MonitoringException {
045    
046                    return _portletSummaryStatistics.getAverageTimeByCompany(webId);
047            }
048    
049            @Override
050            public long getAverageTimeByPortlet(String portletId)
051                    throws MonitoringException {
052    
053                    return _portletSummaryStatistics.getAverageTimeByPortlet(portletId);
054            }
055    
056            @Override
057            public long getAverageTimeByPortlet(String portletId, long companyId)
058                    throws MonitoringException {
059    
060                    return _portletSummaryStatistics.getAverageTimeByPortlet(
061                            portletId, companyId);
062            }
063    
064            @Override
065            public long getAverageTimeByPortlet(String portletId, String webId)
066                    throws MonitoringException {
067    
068                    return _portletSummaryStatistics.getAverageTimeByPortlet(
069                            portletId, webId);
070            }
071    
072            @Override
073            public long[] getCompanyIds() {
074                    Set<Long> companyIds = _serverStatistics.getCompanyIds();
075    
076                    return ArrayUtil.toArray(
077                            companyIds.toArray(new Long[companyIds.size()]));
078            }
079    
080            @Override
081            public long getErrorCount() throws MonitoringException {
082                    return _portletSummaryStatistics.getErrorCount();
083            }
084    
085            @Override
086            public long getErrorCountByCompany(long companyId)
087                    throws MonitoringException {
088    
089                    return _portletSummaryStatistics.getErrorCountByCompany(companyId);
090            }
091    
092            @Override
093            public long getErrorCountByCompany(String webId)
094                    throws MonitoringException {
095    
096                    return _portletSummaryStatistics.getErrorCountByCompany(webId);
097            }
098    
099            @Override
100            public long getErrorCountByPortlet(String portletId)
101                    throws MonitoringException {
102    
103                    return _portletSummaryStatistics.getErrorCountByPortlet(portletId);
104            }
105    
106            @Override
107            public long getErrorCountByPortlet(String portletId, long companyId)
108                    throws MonitoringException {
109    
110                    return _portletSummaryStatistics.getErrorCountByPortlet(
111                            portletId, companyId);
112            }
113    
114            @Override
115            public long getErrorCountByPortlet(String portletId, String webId)
116                    throws MonitoringException {
117    
118                    return _portletSummaryStatistics.getErrorCountByPortlet(
119                            portletId, webId);
120            }
121    
122            @Override
123            public long getMaxTime() throws MonitoringException {
124                    return _portletSummaryStatistics.getMaxTime();
125            }
126    
127            @Override
128            public long getMaxTimeByCompany(long companyId) throws MonitoringException {
129                    return _portletSummaryStatistics.getMaxTimeByCompany(companyId);
130            }
131    
132            @Override
133            public long getMaxTimeByCompany(String webId) throws MonitoringException {
134                    return _portletSummaryStatistics.getMaxTimeByCompany(webId);
135            }
136    
137            @Override
138            public long getMaxTimeByPortlet(String portletId)
139                    throws MonitoringException {
140    
141                    return _portletSummaryStatistics.getMaxTimeByPortlet(portletId);
142            }
143    
144            @Override
145            public long getMaxTimeByPortlet(String portletId, long companyId)
146                    throws MonitoringException {
147    
148                    return _portletSummaryStatistics.getMaxTimeByPortlet(
149                            portletId, companyId);
150            }
151    
152            @Override
153            public long getMaxTimeByPortlet(String portletId, String webId)
154                    throws MonitoringException {
155    
156                    return _portletSummaryStatistics.getMaxTimeByPortlet(portletId, webId);
157            }
158    
159            @Override
160            public long getMinTime() throws MonitoringException {
161                    return _portletSummaryStatistics.getMinTime();
162            }
163    
164            @Override
165            public long getMinTimeByCompany(long companyId) throws MonitoringException {
166                    return _portletSummaryStatistics.getMinTimeByCompany(companyId);
167            }
168    
169            @Override
170            public long getMinTimeByCompany(String webId) throws MonitoringException {
171                    return _portletSummaryStatistics.getMinTimeByCompany(webId);
172            }
173    
174            @Override
175            public long getMinTimeByPortlet(String portletId)
176                    throws MonitoringException {
177    
178                    return _portletSummaryStatistics.getMinTimeByPortlet(portletId);
179            }
180    
181            @Override
182            public long getMinTimeByPortlet(String portletId, long companyId)
183                    throws MonitoringException {
184    
185                    return _portletSummaryStatistics.getMinTimeByPortlet(
186                            portletId, companyId);
187            }
188    
189            @Override
190            public long getMinTimeByPortlet(String portletId, String webId)
191                    throws MonitoringException {
192    
193                    return _portletSummaryStatistics.getMinTimeByPortlet(portletId, webId);
194            }
195    
196            @Override
197            public String[] getPortletIds() {
198                    Set<String> portletIds = _serverStatistics.getPortletIds();
199    
200                    return portletIds.toArray(new String[portletIds.size()]);
201            }
202    
203            @Override
204            public long getRequestCount() throws MonitoringException {
205                    return _portletSummaryStatistics.getRequestCount();
206            }
207    
208            @Override
209            public long getRequestCountByCompany(long companyId)
210                    throws MonitoringException {
211    
212                    return _portletSummaryStatistics.getRequestCountByCompany(companyId);
213            }
214    
215            @Override
216            public long getRequestCountByCompany(String webId)
217                    throws MonitoringException {
218    
219                    return _portletSummaryStatistics.getRequestCountByCompany(webId);
220            }
221    
222            @Override
223            public long getRequestCountByPortlet(String portletId)
224                    throws MonitoringException {
225    
226                    return _portletSummaryStatistics.getRequestCountByPortlet(portletId);
227            }
228    
229            @Override
230            public long getRequestCountByPortlet(String portletId, long companyId)
231                    throws MonitoringException {
232    
233                    return _portletSummaryStatistics.getRequestCountByPortlet(
234                            portletId, companyId);
235            }
236    
237            @Override
238            public long getRequestCountByPortlet(String portletId, String webId)
239                    throws MonitoringException {
240    
241                    return _portletSummaryStatistics.getRequestCountByPortlet(
242                            portletId, webId);
243            }
244    
245            @Override
246            public long getSuccessCount() throws MonitoringException {
247                    return _portletSummaryStatistics.getSuccessCount();
248            }
249    
250            @Override
251            public long getSuccessCountByCompany(long companyId)
252                    throws MonitoringException {
253    
254                    return _portletSummaryStatistics.getSuccessCountByCompany(companyId);
255            }
256    
257            @Override
258            public long getSuccessCountByCompany(String webId)
259                    throws MonitoringException {
260    
261                    return _portletSummaryStatistics.getSuccessCountByCompany(webId);
262            }
263    
264            @Override
265            public long getSuccessCountByPortlet(String portletId)
266                    throws MonitoringException {
267    
268                    return _portletSummaryStatistics.getSuccessCountByPortlet(portletId);
269            }
270    
271            @Override
272            public long getSuccessCountByPortlet(String portletId, long companyId)
273                    throws MonitoringException {
274    
275                    return _portletSummaryStatistics.getSuccessCountByPortlet(
276                            portletId, companyId);
277            }
278    
279            @Override
280            public long getSuccessCountByPortlet(String portletId, String webId)
281                    throws MonitoringException {
282    
283                    return _portletSummaryStatistics.getSuccessCountByPortlet(
284                            portletId, webId);
285            }
286    
287            @Override
288            public long getTimeoutCount() throws MonitoringException {
289                    return _portletSummaryStatistics.getTimeoutCount();
290            }
291    
292            @Override
293            public long getTimeoutCountByCompany(long companyId)
294                    throws MonitoringException {
295    
296                    return _portletSummaryStatistics.getTimeoutCountByCompany(companyId);
297            }
298    
299            @Override
300            public long getTimeoutCountByCompany(String webId)
301                    throws MonitoringException {
302    
303                    return _portletSummaryStatistics.getTimeoutCountByCompany(webId);
304            }
305    
306            @Override
307            public long getTimeoutCountByPortlet(String portletId)
308                    throws MonitoringException {
309    
310                    return _portletSummaryStatistics.getTimeoutCountByPortlet(portletId);
311            }
312    
313            @Override
314            public long getTimeoutCountByPortlet(String portletId, long companyId)
315                    throws MonitoringException {
316    
317                    return _portletSummaryStatistics.getTimeoutCountByPortlet(
318                            portletId, companyId);
319            }
320    
321            @Override
322            public long getTimeoutCountByPortlet(String portletId, String webId)
323                    throws MonitoringException {
324    
325                    return _portletSummaryStatistics.getTimeoutCountByPortlet(
326                            portletId, webId);
327            }
328    
329            @Override
330            public String[] getWebIds() {
331                    Set<String> webIds = _serverStatistics.getWebIds();
332    
333                    return webIds.toArray(new String[webIds.size()]);
334            }
335    
336            @Override
337            public void reset() {
338                    _serverStatistics.reset();
339            }
340    
341            @Override
342            public void reset(long companyId) {
343                    _serverStatistics.reset(companyId);
344            }
345    
346            @Override
347            public void reset(String webId) {
348                    _serverStatistics.reset(webId);
349            }
350    
351            public void setPortletSummaryStatistics(
352                    PortletSummaryStatistics portletSummaryStatistics) {
353    
354                    _portletSummaryStatistics = portletSummaryStatistics;
355            }
356    
357            public void setServerStatistics(ServerStatistics serverStatistics) {
358                    _serverStatistics = serverStatistics;
359            }
360    
361            private PortletSummaryStatistics _portletSummaryStatistics;
362            private ServerStatistics _serverStatistics;
363    
364    }