Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 65136 invoked from network); 21 May 2006 22:43:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 May 2006 22:43:19 -0000 Received: (qmail 87597 invoked by uid 500); 21 May 2006 22:43:18 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 87579 invoked by uid 500); 21 May 2006 22:43:18 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 87561 invoked by uid 99); 21 May 2006 22:43:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 May 2006 15:43:17 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 May 2006 15:43:17 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D10581A983A; Sun, 21 May 2006 15:42:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r408514 - in /portals/jetspeed-2/trunk: components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java src/webapp/WEB-INF/assembly/jetspeed-spring.xml Date: Sun, 21 May 2006 22:42:55 -0000 To: jetspeed-dev@portals.apache.org From: ate@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060521224255.D10581A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ate Date: Sun May 21 15:42:54 2006 New Revision: 408514 URL: http://svn.apache.org/viewvc?rev=408514&view=rev Log: Automatically clear cached but no longer valid PortletWindow/PortletEntity instances. A PortletEntity normally holds a reference to a PortletDefinition and its PortletApplication. When a Portlet Application is restarted/redeployed with changes in its portlet.xml, the registry for it is updated. Then, cached PortletWindow/PortletEntity instances still holding out-of-sync references to the "old" registry instances may cause rendering problems which can only be solved by restarting the portal! Now, each PortletWindow and its PortletEntity instance will first be checked when retrieved from the cache and removed from it when out-of-sync. Note: this is a light-weight validation checking if the referenced PortletApplication is registered in the PortletFactory (meaning its active/available). These checks will have no real performance penalty for "valid" PortletWindows, only for "offline" Portlet Applications they will (need to) be recreated each and every time. Warning: this change requires a mandatory change to the Spring assembly definition for the PortletWindowAccessorImpl (in jetspeed-spring.xml). Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java?rev=408514&r1=408513&r2=408514&view=diff ============================================================================== --- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java (original) +++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java Sun May 21 15:42:54 2006 @@ -28,7 +28,9 @@ import org.apache.jetspeed.container.window.FailedToCreateWindowException; import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow; import org.apache.jetspeed.container.window.PortletWindowAccessor; +import org.apache.jetspeed.factory.PortletFactory; import org.apache.jetspeed.om.common.portlet.MutablePortletEntity; +import org.apache.jetspeed.om.common.portlet.PortletApplication; import org.apache.jetspeed.om.page.ContentFragment; import org.apache.jetspeed.om.window.impl.PortletWindowImpl; import org.apache.jetspeed.util.ArgUtil; @@ -49,12 +51,14 @@ private Map windows = Collections.synchronizedMap(new HashMap()); private PortletEntityAccessComponent entityAccessor; + private PortletFactory portletFactory; private boolean validateWindows = false; - public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor, boolean validateWindows) + public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor, PortletFactory portletFactory, boolean validateWindows) { this.entityAccessor = entityAccessor; + this.portletFactory = portletFactory; this.validateWindows = validateWindows; } @@ -68,13 +72,18 @@ PortletWindow found = getWindowFromCache(windowId); if (found != null) { + // remove from cache if invalid entity + checkPortletWindowEntity(found); ((PortletWindowCtrl)found).setPortletEntity(entity); return found; } PortletWindowImpl window = new PortletWindowImpl(windowId); window.setPortletEntity(entity); - windows.put(windowId, window); + if ( isValidPortletEntity(entity)) + { + windows.put(windowId, window); + } return window; } @@ -83,6 +92,8 @@ PortletWindow found = getWindowFromCache(windowId); if (found != null) { + // remove from cache if invalid entity + checkPortletWindowEntity(found); return found; } PortletWindowImpl window = new PortletWindowImpl(windowId); @@ -91,14 +102,20 @@ public PortletWindow getPortletWindow(String windowId) { - return getWindowFromCache(windowId); + PortletWindow window = getWindowFromCache(windowId); + if (window != null) + { + // remove from cache if invalid entity + checkPortletWindowEntity(window); + } + return window; } public PortletWindow getPortletWindow(ContentFragment fragment) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException { ArgUtil.assertNotNull(ContentFragment.class, fragment, this, "getPortletWindow(Fragment fragment)"); - PortletWindow portletWindow = getWindowFromCache(fragment); - if (portletWindow == null) + PortletWindow portletWindow = getWindowFromCache(fragment); + if (portletWindow == null || !checkPortletWindowEntity(portletWindow)) { try { @@ -137,6 +154,8 @@ if(portletEntity != null) { ((PortletWindowCtrl) portletWindow).setPortletEntity(portletEntity); + // if not a valid entity, remove window from cache + checkPortletWindowEntity(portletWindow); } else { @@ -180,7 +199,7 @@ { portletEntity = entityAccessor.generateEntityFromFragment(fragment, principal); // not portlet definition most likely means that the portlet has not been deployed so dont worry about storing off the entity - if(portletEntity.getPortletDefinition() != null) + if(isValidPortletEntity(portletEntity)) { entityAccessor.storePortletEntity(portletEntity); } @@ -240,5 +259,23 @@ { return (PortletWindow)windows.get(id); } + + private boolean checkPortletWindowEntity(PortletWindow window) + { + if (!isValidPortletEntity(window.getPortletEntity())) + { + removeWindow(window); + return false; + } + return true; + } + private boolean isValidPortletEntity(PortletEntity pe) + { + return pe != null + && pe.getPortletDefinition() != null + && pe.getPortletDefinition().getPortletApplicationDefinition() != null + && portletFactory.isPortletApplicationRegistered((PortletApplication) pe.getPortletDefinition() + .getPortletApplicationDefinition()); + } } Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml?rev=408514&r1=408513&r2=408514&view=diff ============================================================================== --- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml (original) +++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml Sun May 21 15:42:54 2006 @@ -103,6 +103,9 @@ + + + false --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org For additional commands, e-mail: jetspeed-dev-help@portals.apache.org