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.googleapps;
016    
017    import com.liferay.portal.kernel.googleapps.GEmailSettingsManager;
018    import com.liferay.portal.kernel.googleapps.GGroupManager;
019    import com.liferay.portal.kernel.googleapps.GNicknameManager;
020    import com.liferay.portal.kernel.googleapps.GUserManager;
021    import com.liferay.portal.kernel.googleapps.GoogleAppsFactory;
022    
023    import java.util.Map;
024    import java.util.concurrent.ConcurrentHashMap;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class GoogleAppsFactoryImpl implements GoogleAppsFactory {
030    
031            public GEmailSettingsManager getGEmailSettingsManager(long companyId) {
032                    return getGoogleApps(companyId).getGEmailSettingsManager();
033            }
034    
035            public GGroupManager getGGroupManager(long companyId) {
036                    return getGoogleApps(companyId).getGGroupManager();
037            }
038    
039            public GNicknameManager getGNicknameManager(long companyId) {
040                    return getGoogleApps(companyId).getGNicknameManager();
041            }
042    
043            public GUserManager getGUserManager(long companyId) {
044                    return getGoogleApps(companyId).getGUserManager();
045            }
046    
047            protected GoogleApps getGoogleApps(long companyId) {
048                    GoogleApps googleApps = _googleAppsMap.get(companyId);
049    
050                    if (googleApps == null) {
051                            googleApps = new GoogleApps(companyId);
052    
053                            _googleAppsMap.put(companyId, googleApps);
054                    }
055    
056                    return googleApps;
057            }
058    
059            private static Map<Long, GoogleApps> _googleAppsMap =
060                    new ConcurrentHashMap<Long, GoogleApps>();
061    
062    }