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