Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-alpha-2
-
Fix Version/s: None
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Environment:Today's CVS version
-
Number of attachments :
Description
sessionDestroyed in ServletContainerListener accesses the session when killing the container. According to the Servlet spec, sessionDestroyed is called after the session is invalidated.
To implement the desired behavior one must use HttpSessionBindingListener:
public void sessionCreated(HttpSessionEvent event) {
HttpSession session = event.getSession();
ServletContext context = session.getServletContext();
ContainerComposer assembler = getAssembler(context);
ObjectReference containerRef = new SessionScopeObjectReference(session, SESSION_CONTAINER);
ObjectReference parentContainerRef = new ApplicationScopeObjectReference(context, APPLICATION_CONTAINER);
ContainerBuilder containerBuilder = new DefaultLifecycleContainerBuilder(assembler);
containerBuilder.buildContainer(containerRef, parentContainerRef, session);
session.setAttribute("SESSION_CONTAINER_HELPER",
new HttpSessionBindingListener {
public void valueBound(HttpSessionBindingEvent event) {
}
public void valueUnbound(HttpSessionBindingEvent event)
{ HttpSession session = event.getSession(); ObjectReference containerRef = new SessionScopeObjectReference(session, SESSION_CONTAINER); killContainer(containerRef); }});
}
public void sessionDestroyed(HttpSessionEvent event) {
}
Even better would be to make SessionScopeObjectReference implement HttpSessionBindingListener.
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | servlet-fix-sessionlistener.diff [ 11331 ] |
Attachment | patch.1.9.diff [ 11359 ] |
Resolution | Fixed [ 1 ] | |
Assignee | Aslak Hellesoy [ rinkrank ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Could you please upload a patch as described here:
http://wiki.codehaus.org/picocontainer/HowToContribute
http://wiki.codehaus.org/picocontainer/UnifiedPatch
Aslak