tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
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 GMT
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> 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() {



Mime
View raw message