001    /**
002     * Copyright (c) 2000-present 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.kernel.settings;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.registry.collections.ServiceTrackerCollections;
019    import com.liferay.registry.collections.ServiceTrackerList;
020    
021    import java.util.List;
022    
023    /**
024     * @author Raymond Aug??
025     * @author Jorge Ferrer
026     */
027    public class SettingsFactoryUtil {
028    
029            public static ArchivedSettings getPortletInstanceArchivedSettings(
030                            long groupId, String portletId, String name)
031                    throws SettingsException {
032    
033                    return getSettingsFactory().getPortletInstanceArchivedSettings(
034                            groupId, portletId, name);
035            }
036    
037            public static List<ArchivedSettings> getPortletInstanceArchivedSettingsList(
038                    long groupId, String portletId) {
039    
040                    return getSettingsFactory().getPortletInstanceArchivedSettingsList(
041                            groupId, portletId);
042            }
043    
044            public static Settings getServerSettings(String settingsId) {
045                    return getSettingsFactory().getServerSettings(settingsId);
046            }
047    
048            public static Settings getSettings(SettingsLocator settingsLocator)
049                    throws SettingsException {
050    
051                    return getSettingsFactory().getSettings(settingsLocator);
052            }
053    
054            public static SettingsDescriptor getSettingsDescriptor(String settingsId) {
055                    return getSettingsFactory().getSettingsDescriptor(settingsId);
056            }
057    
058            public static SettingsFactory getSettingsFactory() {
059                    PortalRuntimePermission.checkGetBeanProperty(SettingsFactoryUtil.class);
060    
061                    return _settingsFactories.get(0);
062            }
063    
064            public static void registerSettingsMetadata(
065                    Class<?> settingsClass, Object configurationBean,
066                    FallbackKeys fallbackKeys) {
067    
068                    getSettingsFactory().registerSettingsMetadata(
069                            settingsClass, configurationBean, fallbackKeys);
070            }
071    
072            private static final ServiceTrackerList<SettingsFactory>
073                    _settingsFactories = ServiceTrackerCollections.openList(
074                            SettingsFactory.class);
075    
076    }