weaver      2003/08/03 08:01:07

  Modified:    portal/src/java/org/apache/jetspeed/services/entity
                        PortletEntityServiceImpl.java
  Log:
  Added simple caching of of PortletEntities
  
  Revision  Changes    Path
  1.2       +19 -5     
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java
  
  Index: PortletEntityServiceImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletEntityServiceImpl.java     1 Aug 2003 20:10:31 -0000       1.1
  +++ PortletEntityServiceImpl.java     3 Aug 2003 15:01:07 -0000       1.2
  @@ -53,6 +53,8 @@
    */
   package org.apache.jetspeed.services.entity;
   
  +import java.util.HashMap;
  +
   import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
   import org.apache.jetspeed.om.common.entity.PortletEntityImpl;
  @@ -73,6 +75,9 @@
   public class PortletEntityServiceImpl extends BaseService implements 
PortletEntityService
   {
   
  +    // TODO: this should eventually use a system cach like JCS
  +    private HashMap entityCache = new HashMap();
  +
       /**
        * @see org.apache.fulcrum.Service#init()
        */
  @@ -99,11 +104,20 @@
        */
       public PortletEntity getPortletEntity(RequestContext request, PortletDefinition 
portletDefinition, String portletName)
       {
  +        PortletEntityImpl portletEntity = new PortletEntityImpl(portletDefinition, 
portletName);
  +
  +        if (entityCache.containsKey(portletEntity.getId()))
  +        {
  +            // Speed GC object reclaimation.
  +            portletEntity = null;
  +            return (PortletEntity) entityCache.get(portletEntity.getId());
  +        }
  +        else
  +        {
  +            entityCache.put(portletEntity.getId(), portletEntity);
  +            return portletEntity;
  +        }
   
  -        // TODO This will change as the ID will be generated from the DB
  -        PortletEntityImpl portletEntity = new PortletEntityImpl(portletDefinition);
  -        portletEntity.setId(portletName);
  -        return portletEntity;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to