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.portlet;
016    
017    import com.liferay.portal.kernel.model.Portlet;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import javax.portlet.PortletException;
021    
022    import javax.servlet.ServletContext;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class PortletInstanceFactoryUtil {
028    
029            public static void clear(Portlet portlet) {
030                    getPortletInstanceFactory().clear(portlet);
031            }
032    
033            public static void clear(Portlet portlet, boolean resetRemotePortletBag) {
034                    getPortletInstanceFactory().clear(portlet, resetRemotePortletBag);
035            }
036    
037            public static InvokerPortlet create(
038                            Portlet portlet, ServletContext servletContext)
039                    throws PortletException {
040    
041                    return getPortletInstanceFactory().create(portlet, servletContext);
042            }
043    
044            public static InvokerPortlet create(
045                            Portlet portlet, ServletContext servletContext,
046                            boolean destroyPrevious)
047                    throws PortletException {
048    
049                    return getPortletInstanceFactory().create(
050                            portlet, servletContext, destroyPrevious);
051            }
052    
053            public static void delete(Portlet portlet) {
054                    getPortletInstanceFactory().delete(portlet);
055            }
056    
057            public static void destroy(Portlet portlet) {
058                    getPortletInstanceFactory().destroy(portlet);
059            }
060    
061            public static PortletInstanceFactory getPortletInstanceFactory() {
062                    PortalRuntimePermission.checkGetBeanProperty(
063                            PortletInstanceFactoryUtil.class);
064    
065                    return _portletInstanceFactory;
066            }
067    
068            public void destroy() {
069    
070                    // LPS-10473
071    
072            }
073    
074            public void setPortletInstanceFactory(
075                    PortletInstanceFactory portletInstanceFactory) {
076    
077                    PortalRuntimePermission.checkSetBeanProperty(getClass());
078    
079                    _portletInstanceFactory = portletInstanceFactory;
080            }
081    
082            private static PortletInstanceFactory _portletInstanceFactory;
083    
084    }