You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/04/02 15:51:45 UTC

cvs commit: cocoon-2.1/src/blocks/portal/conf portal.xconf

cziegeler    2004/04/02 05:51:45

  Modified:    src/blocks/portal/conf portal.xconf
  Added:       src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl
                        NoClientCachingEventAspect.java
  Log:
  Disable action-counter for the demo portal; add new aspect implementation that should disable the client cache
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl/NoClientCachingEventAspect.java
  
  Index: NoClientCachingEventAspect.java
  ===================================================================
  /*
   * Copyright 1999-2002,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.cocoon.portal.event.aspect.impl;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Response;
  import org.apache.cocoon.portal.PortalService;
  import org.apache.cocoon.portal.event.aspect.EventAspect;
  import org.apache.cocoon.portal.event.aspect.EventAspectContext;
  
  /**
   * This aspect implementation sets some headers on the response that tell
   * clients/proxies to not cache. This "disables" the back button on the
   * client.
   * 
   * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
   * 
   * @version CVS $Id: NoClientCachingEventAspect.java,v 1.1 2004/04/02 13:51:45 cziegeler Exp $
   */
  public class NoClientCachingEventAspect
  	extends AbstractLogEnabled
  	implements EventAspect, 
                  ThreadSafe {
  
      /* (non-Javadoc)
  	 * @see org.apache.cocoon.portal.event.aspect.EventAspect#process(org.apache.cocoon.portal.event.aspect.EventAspectContext, org.apache.cocoon.portal.PortalService)
  	 */
  	public void process(EventAspectContext context, PortalService service) {
  
          final Response response = ObjectModelHelper.getResponse( context.getObjectModel() );
          response.setHeader("Cache-Control", "no-cache");
          response.setHeader("Pragma", "no-cache");
          response.setHeader("Expires", "Thu, 01 Jan 2000 00:00:00 GMT");
          
          context.invokeNext(service);
  	}
  
  
  }
  
  
  
  1.38      +6 -2      cocoon-2.1/src/blocks/portal/conf/portal.xconf
  
  Index: portal.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- portal.xconf	6 Mar 2004 02:26:02 -0000	1.37
  +++ portal.xconf	2 Apr 2004 13:51:45 -0000	1.38
  @@ -22,12 +22,16 @@
       <aspect name="action-counter" class="org.apache.cocoon.portal.event.aspect.impl.ActionCounterEventAspect"/>
       <aspect name="request-parameter" class="org.apache.cocoon.portal.event.aspect.impl.RequestParameterEventAspect"/>
       <aspect name="frame" class="org.apache.cocoon.portal.event.aspect.impl.FrameEventAspect"/>
  -    <aspect name="link"  class="org.apache.cocoon.portal.event.aspect.impl.LinkEventAspect" />    <aspect name="full-screen-coplet" class="org.apache.cocoon.portal.event.aspect.impl.FullScreenCopletEventAspect"/>
  +    <aspect name="link"  class="org.apache.cocoon.portal.event.aspect.impl.LinkEventAspect" />    
  +    <aspect name="full-screen-coplet" class="org.apache.cocoon.portal.event.aspect.impl.FullScreenCopletEventAspect"/>
  +
  +    <!-- This aspect sets headers on the response that tell the client to not cache the response: -->
  +    <aspect name="no-client-caching" class="org.apache.cocoon.portal.event.aspect.impl.NoClientCachingEventAspect"/>
    </component>
   
    <component class="org.apache.cocoon.portal.event.impl.DefaultEventManager" logger="portal" role="org.apache.cocoon.portal.event.EventManager">
       <event-aspects>
  -        <aspect type="action-counter"/>
  +        <aspect type="no-client-caching"/>
           <aspect type="frame"/>
           <aspect type="link"/>
           <aspect type="full-screen-coplet"/>