문제

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