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.googleapps;
16  
17  import com.liferay.portal.kernel.googleapps.GEmailSettingsManager;
18  import com.liferay.portal.kernel.googleapps.GGroupManager;
19  import com.liferay.portal.kernel.googleapps.GNicknameManager;
20  import com.liferay.portal.kernel.googleapps.GUserManager;
21  import com.liferay.portal.kernel.googleapps.GoogleAppsFactory;
22  
23  import java.util.Map;
24  import java.util.concurrent.ConcurrentHashMap;
25  
26  /**
27   * <a href="GoogleAppsFactoryImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class GoogleAppsFactoryImpl implements GoogleAppsFactory {
32  
33      public GEmailSettingsManager getGEmailSettingsManager(long companyId) {
34          return getGoogleApps(companyId).getGEmailSettingsManager();
35      }
36  
37      public GGroupManager getGGroupManager(long companyId) {
38          return getGoogleApps(companyId).getGGroupManager();
39      }
40  
41      public GNicknameManager getGNicknameManager(long companyId) {
42          return getGoogleApps(companyId).getGNicknameManager();
43      }
44  
45      public GUserManager getGUserManager(long companyId) {
46          return getGoogleApps(companyId).getGUserManager();
47      }
48  
49      protected GoogleApps getGoogleApps(long companyId) {
50          GoogleApps googleApps = _googleAppsMap.get(companyId);
51  
52          if (googleApps == null) {
53              googleApps = new GoogleApps(companyId);
54  
55              _googleAppsMap.put(companyId, googleApps);
56          }
57  
58          return googleApps;
59      }
60  
61      private static Map<Long, GoogleApps> _googleAppsMap =
62          new ConcurrentHashMap<Long, GoogleApps>();
63  
64  }