1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.poller;
16  
17  import com.liferay.portal.kernel.poller.PollerProcessor;
18  
19  import java.util.Map;
20  import java.util.concurrent.ConcurrentHashMap;
21  
22  /**
23   * <a href="PollerProcessorUtil.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class PollerProcessorUtil {
28  
29      public static void addPollerProcessor(
30          String portletId, PollerProcessor pollerProcessor) {
31  
32          _instance._addPollerProcessor(portletId, pollerProcessor);
33      }
34  
35      public static void deletePollerProcessor(String portletId) {
36          _instance._deletePollerProcessor(portletId);
37      }
38  
39      public static PollerProcessor getPollerProcessor(String portletId) {
40          return _instance._getPollerProcessor(portletId);
41      }
42  
43      private PollerProcessorUtil() {
44      }
45  
46      private void _addPollerProcessor(
47          String portletId, PollerProcessor pollerProcessor) {
48  
49          _pollerPorcessors.put(portletId, pollerProcessor);
50      }
51  
52      private void _deletePollerProcessor(String portletId) {
53          _pollerPorcessors.remove(portletId);
54      }
55  
56      private PollerProcessor _getPollerProcessor(String portletId) {
57          return _pollerPorcessors.get(portletId);
58      }
59  
60      private static PollerProcessorUtil _instance = new PollerProcessorUtil();
61  
62      private Map<String, PollerProcessor> _pollerPorcessors =
63          new ConcurrentHashMap<String, PollerProcessor>();
64  
65  }