1 Reply Latest reply on Apr 9, 2011 8:53 PM by Rocky S

    a4j:push and session timeout

    Hima Kos Newbie

      Hi All,

       

      I am using a4j:push in my application.

       

      My session scoped managed bean has the following:

       

      public class MyBean{

      public MyBean(){

           DiscoveryTask.addListener(this);

      }

       

      public void addCommandListener(EventListener listener) {
              synchronized (listener)
              {
                  commandEventListener = (PushEventListener) listener;
              }
          }

       

          public void push() { //DiscoveryTask calls push
              if (commandEventListener != null)
              {
                  loadData();
                  synchronized (commandEventListener)
                  {
                      commandEventListener.onEvent(new EventObject(this));
                  }
              }
          }

       

      private PushEventListener commandEventListener;

      ....

      }

       

      When the session times out or when then user closes the browser, I want to remove the listener(MyBean instance) from DiscoveryTask. How do I detect these events and remove the listener? I don't want the DiscoveryTask to hold on to all the session beans that are not in use.

       

      Thanks,

      Bindu