myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Uribe <lu4...@gmail.com>
Subject Re: [MyFaces 2.2] invoke @PreDestroy on (CDI) ViewScoped beans upon session expiration
Date Fri, 18 Oct 2013 02:14:19 GMT
Hi

I have committed a fix for the problem with the timeout. But I'm curious
about this problem, because I tested this scope and specifically the
@PreDestroy stuff. It should work. But maybe there is a bug somewhere....

regards,

Leonardo Uribe


2013/10/17 Howard W. Smith, Jr. <smithh032772@gmail.com>

> responses inline below,
>
>
> On Thu, Oct 17, 2013 at 9:32 PM, Leonardo Uribe <lu4242@gmail.com> wrote:
>
> >
> >     public void onSessionDestroyed()
> >     {
> >         // In CDI case, the best way to deal with this is use a method
> >         // with @PreDestroy annotation on a session scope bean
> >         // ( ViewScopeBeanHolder.destroyBeans() ). There is no need
> >         // to do anything else in this location, but it is advised
> >         // in CDI the beans are destroyed at the end of the request,
> >         // not when invalidateSession() is called.
> >         FacesContext facesContext = FacesContext.getCurrentInstance();
> >         if (facesContext != null)
> >         {
> >
> > I suppose what's going on there is in the context the session
> invalidation
> > is done, FacesContext is null and @PreDestroy is ignored.
> >
>
> I can agree with that.
>
>
> >
> > To be clear two questions:
> >
> > 1. Is manual session expiration working ? I suppose yes.
> >
>
> hmmm does manual session expiration == HttpSession.invalidate()?
>
> When user click Logout button, my app execute/triggers
> HttpSession.invalidate(), and @PreDestroy (on CDI @ViewScoped bean) is not
> executed.
>
>
>
> > 2. Is session invalidation by a timeout working ? I suppose no.
> >
>
> correct, I just verified that in my app. see below.
>
> - navigated to page that reference CDI @ViewScoped bean, @PostConstruct
> (below) executed
>
> Oct 17, 2013 9:45:18 PM jsf.orders.OrderDocumentBean init
> INFO: jsf.orders.OrderDocumentBean@a9faef9
>
> changed web.xml, session timeout = 1 minute, so tomee ended session
> via/after timeout, and @PreDestroy on CDI @SessionScoped (below) executed,
>
> Oct 17, 2013 9:45:53 PM jsf.users.pf_UsersController sessionTimeout
> INFO: administrator session ended at 10/17/2013 09:45 PM
>
> but @PreDestroy on CDI @ViewScoped bean was not executed
>
>
> I will try to provide an example to test.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message