1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.calendar.service.impl;
16  
17  import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
18  import com.liferay.portal.kernel.cache.PortalCache;
19  import com.liferay.portal.kernel.util.StringPool;
20  import com.liferay.portlet.calendar.model.CalEvent;
21  
22  import java.util.List;
23  import java.util.Map;
24  import java.util.concurrent.ConcurrentHashMap;
25  
26  /**
27   * <a href="CalEventLocalUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   * @author Michael Young
31   */
32  public class CalEventLocalUtil {
33  
34      public static final String CACHE_NAME = CalEventLocalUtil.class.getName();
35  
36      protected static void clearEventsPool(long groupId) {
37          String key = _encodeKey(groupId);
38  
39          _cache.remove(key);
40      }
41  
42      protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
43          String key = _encodeKey(groupId);
44  
45          Map <String, List<CalEvent>> eventsPool =
46              (Map<String, List<CalEvent>>)_cache.get(key);
47  
48          if (eventsPool == null) {
49              eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
50  
51              _cache.put(key, eventsPool);
52          }
53  
54          return eventsPool;
55      }
56  
57      private static String _encodeKey(long groupId) {
58          return CACHE_NAME.concat(StringPool.POUND).concat(
59              String.valueOf(groupId));
60      }
61  
62      private static PortalCache _cache = MultiVMPoolUtil.getCache(CACHE_NAME);
63  
64  }