001    /**
002     * Copyright (c) 2000-2010 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.exception.SystemException;
018    import com.liferay.portal.kernel.util.MethodKey;
019    import com.liferay.portal.monitoring.statistics.service.ServerStatistics;
020    import com.liferay.portal.monitoring.statistics.service.ServiceMonitorAdvice;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Michael C. Han
026     */
027    public class ServiceManager implements ServiceManagerMBean {
028    
029            public void addMonitoredClass(String className) {
030                    _serviceMonitorAdvice.addMonitoredClass(className);
031            }
032    
033            public void addMonitoredMethod(
034                            String className, String methodName, String[] parameterTypes)
035                    throws SystemException {
036    
037                    _serviceMonitorAdvice.addMonitoredMethod(
038                            className, methodName, parameterTypes);
039            }
040    
041            public long getErrorCount(
042                            String className, String methodName, String[] parameterTypes)
043                    throws SystemException {
044    
045                    return _serverStatistics.getErrorCount(
046                            className, methodName, parameterTypes);
047            }
048    
049            public long getMaxTime(
050                            String className, String methodName, String[] parameterTypes)
051                    throws SystemException {
052    
053                    return _serverStatistics.getMaxTime(
054                            className, methodName, parameterTypes);
055            }
056    
057            public long getMinTime(
058                            String className, String methodName, String[] parameterTypes)
059                    throws SystemException {
060    
061                    return _serverStatistics.getMinTime(
062                            className, methodName, parameterTypes);
063            }
064    
065            public Set<String> getMonitoredClasses() {
066                    return _serviceMonitorAdvice.getMonitoredClasses();
067            }
068    
069            public Set<MethodKey> getMonitoredMethods() {
070                    return _serviceMonitorAdvice.getMonitoredMethods();
071            }
072    
073            public long getRequestCount(
074                            String className, String methodName, String[] parameterTypes)
075                    throws SystemException {
076    
077                    return _serverStatistics.getRequestCount(
078                            className, methodName, parameterTypes);
079            }
080    
081            public boolean isActive() {
082                    return _serviceMonitorAdvice.isActive();
083            }
084    
085            public boolean isPermissiveMode() {
086                    return _serviceMonitorAdvice.isPermissiveMode();
087            }
088    
089            public void setActive(boolean active) {
090                    _serviceMonitorAdvice.setActive(active);
091            }
092    
093            public void setPermissiveMode(boolean permissiveMode) {
094                    _serviceMonitorAdvice.setPermissiveMode(permissiveMode);
095            }
096    
097            public void setServerStatistics(ServerStatistics serverStatistics) {
098                    _serverStatistics = serverStatistics;
099            }
100    
101            private ServerStatistics _serverStatistics;
102            private ServiceMonitorAdvice _serviceMonitorAdvice =
103                    ServiceMonitorAdvice.getInstance();
104    
105    }