/FileExtraction/Java_unseen/asarkar_spring/daily-update-microservices/auth-service/src/main/java/name/abhijitsarkar/javaee/auth/HttpSessionConfig.java
package name.abhijitsarkar.javaee.auth;

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionStrategy;
import org.springframework.session.web.http.HttpSessionStrategy;

/**
 * @author Abhijit Sarkar
 */
@EnableHazelcastHttpSession(maxInactiveIntervalInSeconds = "180")
public class HttpSessionConfig {
    @Autowired
    private Config hazelcastConfig;

    @Bean
    public HttpSessionStrategy httpSessionStrategy() {
        return new HeaderHttpSessionStrategy();
    }

    @Bean(destroyMethod = "shutdown")
    public HazelcastInstance hazelcastInstance() {
        return Hazelcast.newHazelcastInstance(hazelcastConfig);
    }
}
