You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by mo...@apache.org on 2002/10/03 20:21:59 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/persistence JetspeedPortalPersistenceService.java

morciuch    2002/10/03 11:21:59

  Modified:    src/java/org/apache/jetspeed/services/persistence
                        JetspeedPortalPersistenceService.java
  Log:
  This patch minimizes object creation of PortletInstances by doing per-request caching on PortletInstance within the current HttpRequest.  PortletInstance's are keyed as "portlet_instance:<portlet id>".
  
  Bug fixed:
  This also fixed a bug I was experiencing when minimizing/restoring portlets.
  After either of these actions I was required to refresh the screen to see the expected effect, basically causing the portlet to re-read its state from the profile.  I attributed this to too many instances of the same portlet instances floating around and being out of sync.
  
  Patch by Scott Weaver
  
  Revision  Changes    Path
  1.2       +17 -2     jakarta-jetspeed/src/java/org/apache/jetspeed/services/persistence/JetspeedPortalPersistenceService.java
  
  Index: JetspeedPortalPersistenceService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/persistence/JetspeedPortalPersistenceService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JetspeedPortalPersistenceService.java	1 Jul 2002 04:30:24 -0000	1.1
  +++ JetspeedPortalPersistenceService.java	3 Oct 2002 18:21:59 -0000	1.2
  @@ -121,7 +121,22 @@
        */
       public PortletInstance getInstance(Portlet portlet, RunData data)
       {
  -         return new JetspeedPortletInstance(portlet, data);
  +     	String attrKey = "portlet_instance:"+portlet.getID();
  +    	// optimize portlet instance retreival by saving it to the request
  +    	// this also guarantees the PortletInstance object is the same
  +    	// object for the entire life of the request
  +    	PortletInstance instance = (PortletInstance) data.getRequest().getAttribute(attrKey);
  +    	if(instance != null)
  +    	{
  +    		return instance;
  +    	}
  +    	else
  +    	{
  +         	instance=  new JetspeedPortletInstance(portlet, data);
  +         	data.getRequest().setAttribute(attrKey, instance);
  +         	return instance;
  +    	}
  +
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>