Romain,

Since my TomEE/CDI-managed-bean web app is in production, as discussed
earlier, I need this functionality. I never did write the code that I
mentioned below, but I think I may need to try it out and see if it is a
workaround since HttpSessionListener seems not useful in a TomEE (or
OpenWebBeans) CDI-managed-bean app.

Howard


On Sun, Nov 25, 2012 at 2:35 AM, Howard W. Smith, Jr. <
smithh032...@gmail.com> wrote:

> Interesting. So, when server shutdown, sessions are not destroyed?
>
> If the answer is yes, I guess you are telling me that I should invoke
> session.invalidate() in a @PreDestroy of my CDI @SessionScoped UserBean?
>
> I have a sessionTimeout method on my UserBean already, it is usually
> called by HttpSessionListener on sessionDestroyed.
>
>
> On Sun, Nov 25, 2012 at 2:27 AM, Romain Manni-Bucau <rmannibu...@gmail.com
> > wrote:
>
>> Because the session is not destroyed, you need to destroy it or wait the
>> session timeout
>> Le 25 nov. 2012 07:21, "Howard W. Smith, Jr." <smithh032...@gmail.com> a
>> écrit :
>>
>> > I have the following defined for my HttpSessionListener, and I don't
>> see it
>> > being executed (or showing up in server log) when I undeploy or shutdown
>> > TomEE.
>> >
>> > /*
>> >  * To change this template, choose Tools | Templates
>> >  * and open the template in the editor.
>> >  */
>> > package pf;
>> >
>> > import java.util.Date;
>> >
>> > import javax.inject.Inject;
>> >
>> > import javax.servlet.annotation.WebListener;
>> > import javax.servlet.http.HttpSessionEvent;
>> > import javax.servlet.http.HttpSessionListener;
>> >
>> > import jsf.users.pf_UsersController;
>> >
>> > /**
>> >  *
>> >  * @author Administrator
>> >  */
>> > @WebListener
>> > public class UserHttpSessionListener implements HttpSessionListener {
>> >
>> >     @Inject
>> >     private pf_UsersController userBean;
>> >
>> >     @Override
>> >     public void sessionCreated(HttpSessionEvent event) {
>> >         // Do here the job.
>> >     }
>> >
>> >     @Override
>> >     public void sessionDestroyed(HttpSessionEvent event) {
>> >         /*
>> >          * JSF Managed Beans
>> >          *
>> >         pf_UsersController userBean = (pf_UsersController)
>> > event.getSession().
>> >
>> getAttribute("pf_usersController");
>> >          */
>> >         if (userBean != null && userBean.getUser() != null) {
>> >             String userName = userBean.getUser().getUserName();
>> >
>> System.out.println("UserHttpSessionListener.sessionDestroyed():
>> > " +
>> >                                userName + " session destroyed");
>> >             userBean.sessionTimeout();
>> >         }
>> >     }
>> >
>> > }
>> >
>>
>
>

Reply via email to