diff --git a/org.springframework.web/.classpath b/org.springframework.web/.classpath
index 10498b97232..58ab15a9a68 100644
--- a/org.springframework.web/.classpath
+++ b/org.springframework.web/.classpath
@@ -22,6 +22,7 @@
+
diff --git a/org.springframework.web/ivy.xml b/org.springframework.web/ivy.xml
index 1263b0dd3d5..b2bf5513f13 100644
--- a/org.springframework.web/ivy.xml
+++ b/org.springframework.web/ivy.xml
@@ -34,6 +34,7 @@
+
diff --git a/org.springframework.web/pom.xml b/org.springframework.web/pom.xml
index 9f1042f687a..1c194f93ff9 100644
--- a/org.springframework.web/pom.xml
+++ b/org.springframework.web/pom.xml
@@ -35,6 +35,12 @@
1.2_08
true
+
+ javax.portlet
+ portlet-api
+ 2.0
+ provided
+
javax.servlet
servlet-api
@@ -45,7 +51,7 @@
javax.servlet.jsp
jsp-api
2.1
- provided
+ provided
javax.xml
diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java b/org.springframework.web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java
index 1cf58cfa0e5..dcf13fc0af2 100644
--- a/org.springframework.web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java
+++ b/org.springframework.web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@ import java.lang.reflect.Method;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.portlet.PortletSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.util.WebUtils;
@@ -48,6 +50,9 @@ import org.springframework.web.util.WebUtils;
*/
public class FacesRequestAttributes implements RequestAttributes {
+ private static final boolean portletApiPresent =
+ ClassUtils.isPresent("javax.portlet.PortletSession", FacesRequestAttributes.class.getClassLoader());
+
/**
* We'll create a lot of these objects, so we don't want a new logger every time.
*/
@@ -93,6 +98,9 @@ public class FacesRequestAttributes implements RequestAttributes {
if (scope == SCOPE_REQUEST) {
return getExternalContext().getRequestMap();
}
+ else if (scope == SCOPE_GLOBAL_SESSION && portletApiPresent) {
+ return PortletSessionAccessor.getGlobalSessionMapIfPossible(getExternalContext());
+ }
else {
return getExternalContext().getSessionMap();
}
@@ -193,4 +201,21 @@ public class FacesRequestAttributes implements RequestAttributes {
return mutex;
}
+
+ /**
+ * Inner class to avoid hard-coded Portlet API dependency.
+ */
+ private static class PortletSessionAccessor {
+
+ public static Map getGlobalSessionMapIfPossible(ExternalContext externalContext) {
+ Object session = externalContext.getSession(true);
+ if (session instanceof PortletSession) {
+ return ((PortletSession) session).getAttributeMap(PortletSession.APPLICATION_SCOPE);
+ }
+ else {
+ return externalContext.getSessionMap();
+ }
+ }
+ }
+
}
diff --git a/org.springframework.web/template.mf b/org.springframework.web/template.mf
index feabcf7d6b1..f3985d20ead 100644
--- a/org.springframework.web/template.mf
+++ b/org.springframework.web/template.mf
@@ -8,6 +8,7 @@ Import-Template:
javax.el.*;version="[1.0.0, 2.0.0)";resolution:=optional,
javax.faces.*;version="[1.1.0, 3.0.0)";resolution:=optional,
javax.jws.*;resolution:=optional,
+ javax.portlet.*;version="[2.0.0, 3.0.0)";resolution:=optional,
javax.servlet;version="[2.4.0, 4.0.0)",
javax.servlet.http;version="[2.4.0, 4.0.0)",
javax.servlet.jsp.*;version="[2.0.0, 3.0.0)";resolution:=optional,
diff --git a/org.springframework.web/web.iml b/org.springframework.web/web.iml
index 981138940e6..3f4fd40eff5 100644
--- a/org.springframework.web/web.iml
+++ b/org.springframework.web/web.iml
@@ -146,6 +146,17 @@
+
+
+
+
+
+
+
+
+
+
+