Skip to content

Commit 8d09507

Browse files
committed
Restore listener methods.
1 parent dfd7e1b commit 8d09507

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

app/src/main/java/org/apache/roller/weblogger/ui/core/RollerSession.java

+36
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,30 @@ public static RollerSession getRollerSession(HttpServletRequest request) {
127127
return rollerSession;
128128
}
129129

130+
/** Create session's Roller instance */
131+
@Override
132+
public void sessionCreated(HttpSessionEvent se) {
133+
RollerSession rollerSession = new RollerSession();
134+
se.getSession().setAttribute(ROLLER_SESSION, rollerSession);
135+
}
136+
137+
138+
@Override
139+
public void sessionDestroyed(HttpSessionEvent se) {
140+
clearSession(se);
141+
}
142+
143+
/**
144+
* Purge session before passivation. Because Roller currently does not
145+
* support session recovery, failover, migration, or whatever you want
146+
* to call it when sessions are saved and then restored at some later
147+
* point in time.
148+
*/
149+
@Override
150+
public void sessionWillPassivate(HttpSessionEvent se) {
151+
clearSession(se);
152+
}
153+
130154
/**
131155
* Authenticated user associated with this session.
132156
*/
@@ -153,4 +177,16 @@ public void setAuthenticatedUser(User authenticatedUser) {
153177
RollerSessionManager sessionManager = RollerSessionManager.getInstance();
154178
sessionManager.register(authenticatedUser.getUserName(), this);
155179
}
180+
181+
private void clearSession(HttpSessionEvent se) {
182+
HttpSession session = se.getSession();
183+
try {
184+
session.removeAttribute(ROLLER_SESSION);
185+
} catch (Exception e) {
186+
if (log.isDebugEnabled()) {
187+
// ignore purge exceptions
188+
log.debug("EXCEPTION PURGING session attributes",e);
189+
}
190+
}
191+
}
156192
}

0 commit comments

Comments
 (0)