Permalink
Browse files

Expose the session() API to application as discussed with Pierre

  • Loading branch information...
1 parent 25f2eb0 commit 6259774bb5328af85c2a138de4aa091f468db019 @jfarcand jfarcand committed Jun 27, 2012
View
4 modules/cpr/src/main/java/org/atmosphere/cache/SessionBroadcasterCache.java
@@ -76,7 +76,7 @@ public SessionBroadcasterCache() {
*/
public void cache(final AtmosphereResource r, CachedMessage cm) {
if (r != null) {
- HttpSession session = AtmosphereResourceImpl.class.cast(r).session();
+ HttpSession session = r.session();
if (session == null) {
logger.error(ERROR_MESSAGE);
return;
@@ -89,7 +89,7 @@ public void cache(final AtmosphereResource r, CachedMessage cm) {
* {@inheritDoc}
*/
public CachedMessage retrieveLastMessage(final AtmosphereResource r) {
- HttpSession session = AtmosphereResourceImpl.class.cast(r).session();
+ HttpSession session = r.session();
if (session == null) {
logger.error(ERROR_MESSAGE);
return null;
View
7 modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResource.java
@@ -53,6 +53,7 @@
package org.atmosphere.cpr;
+import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.TimeUnit;
@@ -344,4 +345,10 @@
* Notify All {@link AtmosphereResourceEventListener}.
*/
AtmosphereResource notifyListeners();
+
+ /**
+ * Return the {@link HttpSession} is supported, null if not
+ * @return the {@link HttpSession} is supported, null if not
+ */
+ HttpSession session();
}
View
1 modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereResourceImpl.java
@@ -894,6 +894,7 @@ public AtmosphereResourceImpl disableSuspend(boolean disableSuspend) {
* Return the {@link HttpSession} if session support is enabled, or null.
* @return the {@link HttpSession} if session support is enabled, or null.
*/
+ @Override
public HttpSession session(){
return session;
}

0 comments on commit 6259774

Please sign in to comment.