summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java15
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() {