Matt,

Thanks for your pointer. I am not familiar with HttpSessionActivationListener so i write one filter to test it. I notice that contextInitialized is called. I expected that sessionDidActivate() method will be called when there is a request from a client. However, it is not what i expected so I cannot stuff the menu to the session. Any idea?

Best regards,
Jonathan

p.s. : Attached please find the code of this test filter

public class TestListener implements ServletContextListener, HttpSessionActivationListener {
   private final transient Log log = LogFactory.getLog(TestListener.class);
   private transient ServletContext servletContext;


   public synchronized void contextInitialized(ServletContextEvent sce) {
       log.debug("test listenereerqewr initialized");
       servletContext = sce.getServletContext();

       try {
           ApplicationContext ctx =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
           if (ctx != null) {
           }
       } catch (NoSuchBeanDefinitionException n) {
           // ignore, should only happen when testing
       }

   }

   public synchronized void contextDestroyed(ServletContextEvent event) {
       servletContext = null;
   }

   public void sessionWillPassivate(HttpSessionEvent se) {
       log.debug("test 2");
   }

   public void sessionDidActivate(HttpSessionEvent se) {
       log.debug("test 1");
   }
}


Matt Raible wrote:
You could use an HttpSessionActivationListener and do it that way -
stuff the menu repository in the session of each new user.

Matt

On 4/27/07, Jonathan Tse <[EMAIL PROTECTED]> wrote:
Hi all,

    I am using Spring 1.9.4 and Spring MVC. I want to make a strut menu
from database. According to the Database Driven Menu example, it
suggests using filter to preload the data to the menu repository. I have
written my data loading logic in service manager already, so how i can
inject the service manager to this filter?

    Please help. Thanks.

Best regards,
Jonathan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





public class TestListener implements  ServletContextListener, 
HttpSessionActivationListener {
    private final transient Log log = LogFactory.getLog(TestListener.class);
    private transient ServletContext servletContext;


    public synchronized void contextInitialized(ServletContextEvent sce) {
        log.debug("test listenereerqewr initialized");
        servletContext = sce.getServletContext();

        try {
            ApplicationContext ctx =
                
WebApplicationContextUtils.getWebApplicationContext(servletContext);
            if (ctx != null) {
                // ProviderManager authenticationManager = (ProviderManager) 
ctx.getBean("authenticationManager");
            }
        } catch (NoSuchBeanDefinitionException n) {
            // ignore, should only happen when testing
        }

    }

    public synchronized void contextDestroyed(ServletContextEvent event) {
        servletContext = null;
    }

    public void sessionWillPassivate(HttpSessionEvent se) {
        log.debug("test listenereerqewr 2222");
    }

    public void sessionDidActivate(HttpSessionEvent se) {
        log.debug("test listenereerqewr 1111");
    }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to