cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl SessionAspectDataStore.java
Date Fri, 11 Jul 2003 10:08:23 GMT
cziegeler    2003/07/11 03:08:23

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        SessionAspectDataStore.java
  Log:
  Reducing lookups
  
  Revision  Changes    Path
  1.5       +19 -20    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/SessionAspectDataStore.java
  
  Index: SessionAspectDataStore.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/SessionAspectDataStore.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SessionAspectDataStore.java	26 May 2003 09:52:59 -0000	1.4
  +++ SessionAspectDataStore.java	11 Jul 2003 10:08:23 -0000	1.5
  @@ -50,9 +50,6 @@
   */
   package org.apache.cocoon.portal.aspect.impl;
   
  -import java.util.HashMap;
  -import java.util.Map;
  -
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
  @@ -60,7 +57,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.ContextHelper;
  -import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.portal.aspect.AspectDataStore;
   import org.apache.cocoon.portal.aspect.Aspectalizable;
   
  @@ -77,27 +74,29 @@
       
       protected Context context;
       
  -    protected Map getMap(Aspectalizable owner) {
  -        final Request request = ContextHelper.getRequest(this.context);
  -        Map componentMap = (Map)request.getSession().getAttribute(this.getClass().getName());
  -        if ( componentMap == null) {
  -            componentMap = new HashMap(3);
  -            request.getSession().setAttribute(this.getClass().getName(), componentMap);
  -        }
  -        Map ownerMap = (Map)componentMap.get( owner );
  -        if ( ownerMap == null ) {
  -            ownerMap = new HashMap(3);
  -            componentMap.put( owner, ownerMap );
  -        }
  -        return ownerMap;
  +    protected String getKey(Aspectalizable owner, String aspectName) {
  +        StringBuffer buffer = new StringBuffer(this.getClass().getName());
  +        buffer.append('/');
  +        buffer.append(owner.getClass().getName());
  +        buffer.append('/');
  +        buffer.append(owner.hashCode());
  +        buffer.append('/');
  +        buffer.append(aspectName);
  +        return buffer.toString();
       }
       
       public Object getAspectData(Aspectalizable owner, String aspectName) {
  -        return this.getMap(owner).get( aspectName );
  +        final Session session = ContextHelper.getRequest(this.context).getSession();
  +        return session.getAttribute( this.getKey( owner, aspectName ) );
       }
       
       public void setAspectData(Aspectalizable owner, String aspectName, Object data) {
  -        this.getMap(owner).put(aspectName, data);
  +        final Session session = ContextHelper.getRequest(this.context).getSession();
  +        if ( data == null ) {
  +            session.removeAttribute( this.getKey( owner, aspectName) );
  +        } else {
  +            session.setAttribute( this.getKey( owner, aspectName), data );
  +        }
       }
   
       public boolean isPersistent() {
  
  
  

Mime
View raw message