Hi there,

I'm picking up this thread after it's been sleeping for a while.

I have a javax.mail.Store object stored in temporary storage in my CustomTurbineUser 
object.  A screen sticks it in there upon login.  I've implemented my a new LogoutUser 
class (CustomLogoutUser) that has similar logic before it calls super.doPerform().  
This works well.  However, if a session times out, I still want the mail store 
connection to be closed.  

My CustomTurbineUser object (see below) implements HttpSessionListener and I know that 
the sessionDestroyed() method gets run upon session timeout.  However, by the time it 
gets run, the user no longer seems to have the temporary data in it.  In other words, 
the Store object that should be returned with this.getTemp("imapStore") is null.  
After the session is destroyed, my IMAP server still sees the connection.

Any idea how/where I can implement this code so that it will have my temporary data 
available to it?

Thanks much!
Philip

public class CustomTurbineUser extends TurbineUser implements HttpSessionListener {

        public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        //HttpSession httpSession = httpSessionEvent.getSession();
        //httpSession.
        log.debug("@@@@@@@@@@@@@@@@@@@@@@ Destroying a session! @@@@@@@@@@@@@@@@@@");

        if (this.getTemp("imapStore") != null && 
((Store)this.getTemp("imapStore")).isConnected()) {
            log.debug("User has an imap Store in his session.");
            Store store = (Store)this.getTemp("imapStore");
            try {
                store.close();
            } catch (MessagingException me) {
                log.info("Was not able to close imap connection: " + me.getMessage());
            }

        } else {
            log.debug("User did not have an imap Store in his session.");
        }
    
    }

}

----- Original Message ----- 
From: "Edgar Gonz�lez Gonz�lez" <[EMAIL PROTECTED]>
To: "Turbine Users List" <[EMAIL PROTECTED]>; "Philip S. Wachtel" <[EMAIL PROTECTED]>
Sent: Friday, July 11, 2003 10:15 AM
Subject: RE: Clean-up on Logout


> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Hi Philip,
> 
> I do something similar, my User has a db connection in temporary storage.
> 
> I close the connection when the session is unbound, this approach works
> either when the user logout or when the server close the session.
> 
> I do this implementing in the user the
> javax.servlet.http.HttpSessionBindingEvent interface
> 
> following an extract of my implementation:
> 
> ****************************************************************************
> *************
> 
>     /**
>      * Este m�todo es implementado si se desea ser notificado cuando el
> Usuario
>      * ha sido "Unbound" de la sesi�n, esta implementaci�n en particular
>      * hace logout y cierra la conexion usada por el Usuario
>      *
>      * @param event que indica un unbinding de un valor a la sesi�n.
>      */
>     public void valueUnbound(HttpSessionBindingEvent event)
>     {
>         try
>         {
>             // cerrar conexion si existe
> 
>             Connection conn = getConnectionForSession();
>             if (hasLoggedIn())
>             {
> 
>                 AtuinAuthentication.logout();
>             }
> 
>             if (conn != null)
>             {
> 
>                 conn.close();
>             }
>         }
>         catch (Exception e)
>         {
>             //Log.error("OracleUser.valueUnbobund(): " + e.getMessage(), e);
>             // Para prevenir que mensajes enviados al "logging system" se
>             // pierdan debido a un "shutdown" del contenedor de servlet
>             // imprimos el stacktrace a la consola del contenedor.
>             ByteArrayOutputStream ostr = new ByteArrayOutputStream();
>             e.printStackTrace(new PrintWriter(ostr, true));
>             String stackTrace = ostr.toString();
>             System.out.println(stackTrace);
>         }
>     }
> ****************************************************************************
> *************
> 
> Hope this help you
> 
> ----------------------------------------------------------------------------
> Edgar Gonz�lez Gonz�lez
> VALHALLA Project, s.a.
> Chief Technology Officer
> Web: www.valhallaproject.com <http://www.valhallaproject.com>
> E-mail: [EMAIL PROTECTED]
> Phone: +58-212-242.4379 / 6662 / 4055 / 6475
> Fax: +58-212-242.6809
> "The limits of my language mean the limits of my world."
> Ludwig Wittgenstein
> ----------------------------------------------------------------------------
> 
> 
> 
> -----Mensaje original-----
> De: Philip S. Wachtel [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 10 de julio de 2003 05:12 p.m.
> Para: Turbine Users List
> Asunto: Clean-up on Logout
> 
> 
> Hi there,
> 
> I need to do something simple, but I'm still trying to get used to how
> things should naturally work in Turbine.  I have an object in temporary
> storage (user.setTemp()) that I want to run a method on upon logout.  Where
> is the best place to do that?  The object I've stored has a connection
> opened and I'd like to run .close() on the object when the user logs out.
> 
> Thanks!
> Philip
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

Reply via email to