Is it possible to configure the session-timeout Programmatically in JBOSS EAP 6.1? Using @PostConstruct on session scoped beans or is there any listeners for Session creation?

有帮助吗?

解决方案

You can use HttpSession#setMaxInactiveInterval. Then you can have a class which will implement HttpSessionListener interface so whenever new session is created, you can programatically set new timeout to it.

public class MyHttpSessionListener implements HttpSessionListener {

    @Override
    public void sessionCreated(HttpSessionEvent event) {
        event.getSession().setMaxInactiveInterval(yourInterval); 
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent event){
    }
}

As far as I know, there is now way how to do this in CDI but Servlets and CDI are compliant technologies so it should work together. Note that you can inject any CDI bean to this listener.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top