You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2012/08/02 01:17:42 UTC
svn commit: r1368311 -
/tuscany/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
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() {