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.portlet;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.model.Portlet;
019    
020    import javax.portlet.PortletContext;
021    
022    import javax.servlet.ServletContext;
023    
024    /**
025     * @author Michael C. Han
026     */
027    public class PortletContextFactoryUtil {
028    
029            public static PortletContext create(
030                    Portlet portlet, ServletContext servletContext) {
031    
032                    return getPortletContextFactory().create(portlet, servletContext);
033            }
034    
035            public static PortletContext createUntrackedInstance(
036                    Portlet portlet, ServletContext servletContext) {
037    
038                    return getPortletContextFactory().createUntrackedInstance(
039                            portlet, servletContext);
040            }
041    
042            public static void destroy(Portlet portlet) {
043                    getPortletContextFactory().destroy(portlet);
044            }
045    
046            public static PortletContextFactory getPortletContextFactory() {
047                    PortalRuntimePermission.checkGetBeanProperty(
048                            PortletContextFactoryUtil.class);
049    
050                    return _portletContextFactory;
051            }
052    
053            public void setPortletContextFactory(
054                    PortletContextFactory portletContextFactory) {
055    
056                    PortalRuntimePermission.checkSetBeanProperty(getClass());
057    
058                    _portletContextFactory = portletContextFactory;
059            }
060    
061            private static PortletContextFactory _portletContextFactory;
062    
063    }