Return-Path: X-Original-To: apmail-tuscany-commits-archive@www.apache.org Delivered-To: apmail-tuscany-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 180B6DBDE for ; Wed, 1 Aug 2012 23:18:27 +0000 (UTC) Received: (qmail 32900 invoked by uid 500); 1 Aug 2012 23:18:26 -0000 Delivered-To: apmail-tuscany-commits-archive@tuscany.apache.org Received: (qmail 32872 invoked by uid 500); 1 Aug 2012 23:18:26 -0000 Mailing-List: contact commits-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list commits@tuscany.apache.org Received: (qmail 32865 invoked by uid 99); 1 Aug 2012 23:18:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2012 23:18:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2012 23:18:25 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2A50D23888FE for ; Wed, 1 Aug 2012 23:17:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1368311 - /tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Date: Wed, 01 Aug 2012 23:17:42 -0000 To: commits@tuscany.apache.org From: rfeng@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120801231742.2A50D23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rfeng Date: Wed Aug 1 23:17:41 2012 New Revision: 1368311 URL: http://svn.apache.org/viewvc?rev=1368311&view=rev Log: Fix the Tuscany servlet filter so that it won't load Tuscany node twice if the TuscanyContextListener is also configured. Modified: tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Modified: tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java?rev=1368311&r1=1368310&r2=1368311&view=diff ============================================================================== --- tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java (original) +++ tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java Wed Aug 1 23:17:41 2012 @@ -330,8 +330,8 @@ public class WebAppHelper { } } configuration.setAttribute(ServletContext.class.getName(), servletContext); - if(configurator instanceof ServletConfigurator) { - configuration.setAttribute(Servlet.class.getName(), ((ServletConfigurator) configurator).servlet); + if (configurator instanceof ServletConfigurator) { + configuration.setAttribute(Servlet.class.getName(), ((ServletConfigurator)configurator).servlet); } return configuration; } @@ -381,11 +381,20 @@ public class WebAppHelper { public void setAttribute(String name, Object value) { String prefix = "filter:" + config.getFilterName() + ":"; getServletContext().setAttribute(prefix + name, value); + if (getServletContext().getAttribute(name) == null) { + // Set into the global name + getServletContext().setAttribute(name, value); + } } public T getAttribute(String name) { String prefix = "filter:" + config.getFilterName() + ":"; - return (T)getServletContext().getAttribute(prefix + name); + T value = (T)getServletContext().getAttribute(prefix + name); + if (value != null) { + return value; + } + // Not found in the local scope, trying the servlet context + return (T)getServletContext().getAttribute(name); } public String getName() {