Index: portal-impl/src/com/liferay/portlet/PortletInstanceFactoryImpl.java =================================================================== --- portal-impl/src/com/liferay/portlet/PortletInstanceFactoryImpl.java (revision 39554) +++ portal-impl/src/com/liferay/portlet/PortletInstanceFactoryImpl.java (working copy) @@ -66,6 +66,21 @@ InvokerPortlet invokerPortletInstance = entry.getValue(); if (PortletConstants.getInstanceId(portletId) == null) { + destroyLifecycleListener(portlet.getConfigurationActionInstance()); + destroyLifecycleListener(portlet.getControlPanelEntryInstance()); + destroyLifecycleListener(portlet.getFriendlyURLMapperInstance()); + destroyLifecycleListener(portlet.getIndexerInstance()); + destroyLifecycleListener(portlet.getOpenSearchInstance()); + destroyLifecycleListener(portlet.getPollerProcessorInstance()); + destroyLifecycleListener(portlet.getPopMessageListenerInstance()); + destroyLifecycleListener(portlet.getPortletDataHandlerInstance()); + destroyLifecycleListener(portlet.getPortletLayoutListenerInstance()); + destroyLifecycleListener(portlet.getSchedulerInstance()); + destroyLifecycleListener(portlet.getSocialActivityInterpreterInstance()); + destroyLifecycleListener(portlet.getSocialRequestInterpreterInstance()); + destroyLifecycleListener(portlet.getURLEncoderInstance()); + destroyLifecycleListener(portlet.getWebDAVStorageInstance()); + invokerPortletInstance.destroy(); break; @@ -219,6 +234,22 @@ portlet, portletInstance, portletContext); invokerPortlet.init(portletConfig); + + initLifecycleListener(portlet.getConfigurationActionInstance(), portlet ); + initLifecycleListener(portlet.getControlPanelEntryInstance(), portlet); + initLifecycleListener(portlet.getFriendlyURLMapperInstance(), portlet); + initLifecycleListener(portlet.getIndexerInstance(), portlet); + initLifecycleListener(portlet.getOpenSearchInstance(), portlet); + initLifecycleListener(portlet.getPollerProcessorInstance(), portlet); + initLifecycleListener(portlet.getPopMessageListenerInstance(), portlet); + initLifecycleListener(portlet.getPortletDataHandlerInstance(), portlet); + initLifecycleListener(portlet.getPortletLayoutListenerInstance(), portlet); + initLifecycleListener(portlet.getSchedulerInstance(), portlet); + initLifecycleListener(portlet.getSocialActivityInterpreterInstance(), portlet); + initLifecycleListener(portlet.getSocialRequestInterpreterInstance(), portlet); + initLifecycleListener(portlet.getURLEncoderInstance(), portlet); + initLifecycleListener(portlet.getWebDAVStorageInstance(), portlet); + } catch (ClassNotFoundException cnofe) { throw new UnavailableException(cnofe.getMessage()); @@ -233,6 +264,19 @@ return invokerPortlet; } + private void initLifecycleListener( Object object, Portlet portlet){ + if( object!=null && object instanceof PortletLifecycleListener){ + PortletLifecycleListener listener = (PortletLifecycleListener) object; + listener.init(portlet); + } + } + private void destroyLifecycleListener( Object object){ + if( object!=null && object instanceof PortletLifecycleListener){ + PortletLifecycleListener listener = (PortletLifecycleListener) object; + listener.destroy(); + } + } + private InvokerPortlet _internalInvokerPortletPrototype; private Map> _pool; Index: portal-service/src/com/liferay/portlet/PortletLifecycleListener.java =================================================================== --- portal-service/src/com/liferay/portlet/PortletLifecycleListener.java (revision 0) +++ portal-service/src/com/liferay/portlet/PortletLifecycleListener.java (revision 0) @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.liferay.portlet; + +import com.liferay.portal.model.Portlet; + + +/** + * View Source + * + * @author Rasto Rehak + */ +public interface PortletLifecycleListener { + + public void init( Portlet portlet ); + + public void destroy(); +}