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.poller;
016    
017    import com.liferay.portal.kernel.poller.PollerProcessor;
018    
019    import java.util.Map;
020    import java.util.concurrent.ConcurrentHashMap;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class PollerProcessorUtil {
026    
027            public static void addPollerProcessor(
028                    String portletId, PollerProcessor pollerProcessor) {
029    
030                    _instance._addPollerProcessor(portletId, pollerProcessor);
031            }
032    
033            public static void deletePollerProcessor(String portletId) {
034                    _instance._deletePollerProcessor(portletId);
035            }
036    
037            public static PollerProcessor getPollerProcessor(String portletId) {
038                    return _instance._getPollerProcessor(portletId);
039            }
040    
041            private PollerProcessorUtil() {
042            }
043    
044            private void _addPollerProcessor(
045                    String portletId, PollerProcessor pollerProcessor) {
046    
047                    _pollerPorcessors.put(portletId, pollerProcessor);
048            }
049    
050            private void _deletePollerProcessor(String portletId) {
051                    _pollerPorcessors.remove(portletId);
052            }
053    
054            private PollerProcessor _getPollerProcessor(String portletId) {
055                    return _pollerPorcessors.get(portletId);
056            }
057    
058            private static PollerProcessorUtil _instance = new PollerProcessorUtil();
059    
060            private Map<String, PollerProcessor> _pollerPorcessors =
061                    new ConcurrentHashMap<String, PollerProcessor>();
062    
063    }