@@ -127,6 +127,30 @@ public static RollerSession getRollerSession(HttpServletRequest request) {
127
127
return rollerSession ;
128
128
}
129
129
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
+
130
154
/**
131
155
* Authenticated user associated with this session.
132
156
*/
@@ -153,4 +177,16 @@ public void setAuthenticatedUser(User authenticatedUser) {
153
177
RollerSessionManager sessionManager = RollerSessionManager .getInstance ();
154
178
sessionManager .register (authenticatedUser .getUserName (), this );
155
179
}
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
+ }
156
192
}
0 commit comments