001    /**
002     * Copyright (c) 2000-2013 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.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 void delete(Portlet portlet) {
045                    getPortletInstanceFactory().delete(portlet);
046            }
047    
048            public static void destroy(Portlet portlet) {
049                    getPortletInstanceFactory().destroy(portlet);
050            }
051    
052            public static PortletInstanceFactory getPortletInstanceFactory() {
053                    PortalRuntimePermission.checkGetBeanProperty(
054                            PortletInstanceFactoryUtil.class);
055    
056                    return _portletInstanceFactory;
057            }
058    
059            public void destroy() {
060    
061                    // LPS-10473
062    
063            }
064    
065            public void setPortletInstanceFactory(
066                    PortletInstanceFactory portletInstanceFactory) {
067    
068                    PortalRuntimePermission.checkSetBeanProperty(getClass());
069    
070                    _portletInstanceFactory = portletInstanceFactory;
071            }
072    
073            private static PortletInstanceFactory _portletInstanceFactory;
074    
075    }