Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 35360 invoked from network); 24 Mar 2005 13:45:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Mar 2005 13:45:55 -0000 Received: (qmail 89882 invoked by uid 500); 24 Mar 2005 13:45:54 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 89822 invoked by uid 500); 24 Mar 2005 13:45:54 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 89799 invoked by uid 99); 24 Mar 2005 13:45:54 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 24 Mar 2005 05:45:54 -0800 Received: (qmail 35275 invoked by uid 65534); 24 Mar 2005 13:45:52 -0000 Message-ID: <20050324134552.35274.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Thu, 24 Mar 2005 13:45:52 -0000 Subject: svn commit: r158916 - cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/SpringComponentLocator.java To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cziegeler Date: Thu Mar 24 05:45:52 2005 New Revision: 158916 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D158916 Log: Add constant and restore request attribute when sitemap is left Modified: cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/SpringComp= onentLocator.java Modified: cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/Spri= ngComponentLocator.java URL: http://svn.apache.org/viewcvs/cocoon/blocks/spring-app/trunk/java/org/= apache/cocoon/spring/SpringComponentLocator.java?view=3Ddiff&r1=3D158915&r2= =3D158916 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/SpringComp= onentLocator.java (original) +++ cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/SpringComp= onentLocator.java Thu Mar 24 05:45:52 2005 @@ -16,6 +16,7 @@ package org.apache.cocoon.spring; =20 import java.util.Map; +import java.util.Stack; =20 import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -74,6 +75,8 @@ EnterSitemapEventListener, LeaveSitemapEventListener { =20 + public static final String APPLICATION_CONTEXT_REQUEST_ATTRIBUTE =3D "= application-context"; + protected Context context; protected ServletContext servletContext; protected EnvironmentHelper environmentHelper; @@ -253,7 +256,7 @@ protected ApplicationContext getParentContext() { final Map objectModel =3D ContextHelper.getObjectModel(this.contex= t); final Request request =3D ObjectModelHelper.getRequest(objectModel= ); - ApplicationContext parentContext =3D (ApplicationContext)request.g= etAttribute("application-context"); + ApplicationContext parentContext =3D (ApplicationContext)request.g= etAttribute(APPLICATION_CONTEXT_REQUEST_ATTRIBUTE); =20 if ( parentContext =3D=3D null ) { // there is no parent sitemap with an application context @@ -269,15 +272,32 @@ */ public void enteredSitemap(EnterSitemapEvent event) { final Request request =3D ObjectModelHelper.getRequest(event.getEn= vironment().getObjectModel()); - request.setAttribute("application-context", this.wac); + final Object oldContext =3D request.getAttribute(APPLICATION_CONTE= XT_REQUEST_ATTRIBUTE); + if ( oldContext !=3D null ) { + Stack stack =3D (Stack)request.getAttribute("ac-stack"); + if ( stack =3D=3D null ) { + stack =3D new Stack(); + request.setAttribute("ac-stack", stack); + } + stack.push(oldContext); + } + request.setAttribute(APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, this.w= ac); } =20 /** * @see org.apache.cocoon.sitemap.LeaveSitemapEventListener#leftSitema= p(org.apache.cocoon.sitemap.LeaveSitemapEvent) */ public void leftSitemap(LeaveSitemapEvent event) { - // TODO We have to restore the old value! final Request request =3D ObjectModelHelper.getRequest(event.getEn= vironment().getObjectModel()); - request.removeAttribute("application-context"); + final Stack stack =3D (Stack)request.getAttribute("ac-stack"); + if ( stack =3D=3D null ) { + request.removeAttribute(APPLICATION_CONTEXT_REQUEST_ATTRIBUTE); + } else { + final Object oldContext =3D stack.pop(); + request.setAttribute(APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, ol= dContext); + if ( stack.size() =3D=3D 0 ) { + request.removeAttribute("ac-stack"); + } + } } }