diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-01 23:17:41 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-01 23:17:41 +0000 |
commit | acced4480912a750221e4f11067d3fc83dbf2f0e (patch) | |
tree | 2ee58db77b26ffc15f11bf53e9dd7c571295aaf9 /sca-java-2.x/trunk | |
parent | 1dffd32ebad2d6c390be7a74530f9f86880139cc (diff) |
Fix the Tuscany servlet filter so that it won't load Tuscany node twice if the TuscanyContextListener is also configured.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1368311 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java index 231108bea2..1720dbc180 100644 --- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java +++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java @@ -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() { |