クラス SpringHttpSessionConfiguration
java.lang.ObjectSE
org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration
- 実装済みのインターフェース一覧:
org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationContextAware
@Configuration(proxyBeanMethods=false)
public class SpringHttpSessionConfiguration
extends ObjectSE
implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware
Web 環境で Spring Session をセットアップするための基本を構成します。使用するには、
SessionRepository を提供する必要があります。例:
@Configuration
@EnableSpringHttpSession
public class SpringHttpSessionConfig {
@Bean
public MapSessionRepository sessionRepository() {
return new MapSessionRepository(new ConcurrentHashMap<>());
}
}
セッションの有効期限のためのインフラストラクチャは、すぐに使用できるように構成されていないことに注意することが重要です。これは、セッションの有効期限などが実装に大きく依存するためです。つまり、期限切れのセッションをクリーンアップする必要がある場合は、期限切れのセッションをクリーンアップする責任があります。
基本構成では、以下が提供されます。
- SessionRepositoryFilter - SessionRepository による HttpSession の実装で HttpServletRequest をラップする責任があります
- SessionEventHttpSessionListenerAdapter-Spring Session イベントを HttpSessionEvent に変換するロールを果たします。それが機能するためには、提供する SessionRepository の実装が
SessionCreatedEventとSessionDestroyedEventをサポートしている必要があります。
- 導入:
- 1.1
- 関連事項:
コンストラクター概要
コンストラクター方法の概要
修飾子と型メソッド説明voidvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetCookieSerializer(CookieSerializer cookieSerializer) voidsetHttpSessionIdResolver(HttpSessionIdResolver httpSessionIdResolver) voidsetHttpSessionListeners(ListSE<jakarta.servlet.http.HttpSessionListener> listeners) voidsetServletContext(jakarta.servlet.ServletContext servletContext) <S extends Session>
SessionRepositoryFilter<? extends Session>springSessionRepositoryFilter(SessionRepository<S> sessionRepository)
コンストラクターの詳細
SpringHttpSessionConfiguration
public SpringHttpSessionConfiguration()
方法の詳細
afterPropertiesSet
public void afterPropertiesSet()- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean内のafterPropertiesSet
sessionEventHttpSessionListenerAdapter
springSessionRepositoryFilter
@Bean public <S extends Session> SessionRepositoryFilter<? extends Session> springSessionRepositoryFilter(SessionRepository<S> sessionRepository) setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - 次で指定:
- インターフェース
org.springframework.context.ApplicationContextAware内のsetApplicationContext - 例外:
org.springframework.beans.BeansException
setServletContext
@Autowired(required=false) public void setServletContext(jakarta.servlet.ServletContext servletContext) setCookieSerializer
setHttpSessionIdResolver
@Autowired(required=false) public void setHttpSessionIdResolver(HttpSessionIdResolver httpSessionIdResolver) setHttpSessionListeners
@Autowired(required=false) public void setHttpSessionListeners(ListSE<jakarta.servlet.http.HttpSessionListener> listeners)