001    /**
002     * Copyright (c) 2000-2012 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.security.permission;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.security.pacl.PACLClassLoaderUtil;
020    import com.liferay.portal.util.PropsValues;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class PermissionsListFilterFactory {
026    
027            public static PermissionsListFilter getInstance() {
028                    if (_permissionsListFilter == null) {
029                            if (_log.isDebugEnabled()) {
030                                    _log.debug(
031                                            "Instantiate " + PropsValues.PERMISSIONS_LIST_FILTER);
032                            }
033    
034                            ClassLoader classLoader =
035                                    PACLClassLoaderUtil.getPortalClassLoader();
036    
037                            try {
038                                    _permissionsListFilter =
039                                            (PermissionsListFilter)classLoader.loadClass(
040                                                    PropsValues.PERMISSIONS_LIST_FILTER).newInstance();
041                            }
042                            catch (Exception e) {
043                                    _log.error(e, e);
044                            }
045                    }
046    
047                    if (_log.isDebugEnabled()) {
048                            _log.debug("Return " + _permissionsListFilter.getClass().getName());
049                    }
050    
051                    return _permissionsListFilter;
052            }
053    
054            public static void setInstance(
055                    PermissionsListFilter permissionsListFilter) {
056    
057                    if (_log.isDebugEnabled()) {
058                            _log.debug("Set " + permissionsListFilter.getClass().getName());
059                    }
060    
061                    _permissionsListFilter = permissionsListFilter;
062            }
063    
064            private static Log _log = LogFactoryUtil.getLog(
065                    PermissionsListFilterFactory.class);
066    
067            private static PermissionsListFilter _permissionsListFilter;
068    
069    }