001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.monitoring.jmx;
016    
017    import com.liferay.portal.monitoring.Level;
018    import com.liferay.portal.monitoring.MonitoringProcessor;
019    
020    import java.util.Set;
021    
022    /**
023     * @author Michael C. Han
024     * @author Brian Wing Shun Chan
025     */
026    public class MonitoringProcessorManager
027            implements MonitoringProcessorManagerMBean {
028    
029            public String getLevel(String namespace) {
030                    Level level = _monitoringProcessor.getLevel(
031                            namespace);
032    
033                    if (level == null) {
034                            level = Level.OFF;
035                    }
036    
037                    return level.toString();
038            }
039    
040            public String[] getNamespaces() {
041                    Set<String> namespaces = _monitoringProcessor.getNamespaces();
042    
043                    return namespaces.toArray(new String[namespaces.size()]);
044            }
045    
046            public void setLevel(String namespace, String levelName) {
047                    Level level = Level.valueOf(levelName);
048    
049                    _monitoringProcessor.setLevel(namespace, level);
050            }
051    
052            public void setMonitoringProcessor(
053                    MonitoringProcessor monitoringProcessor) {
054    
055                    _monitoringProcessor = monitoringProcessor;
056            }
057    
058            private MonitoringProcessor _monitoringProcessor;
059    
060    }