Java Code Examples for org.springframework.session.ReactiveSessionRepository

The following examples show how to use org.springframework.session.ReactiveSessionRepository. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-session   Source File: IndexDocTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unused")
void newReactiveRedisSessionRepository() {
	LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
	RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext
			.<String, Object>newSerializationContext(new JdkSerializationRedisSerializer()).build();

	// tag::new-reactiveredissessionrepository[]
	// ... create and configure connectionFactory and serializationContext ...

	ReactiveRedisTemplate<String, Object> redisTemplate = new ReactiveRedisTemplate<>(connectionFactory,
			serializationContext);

	ReactiveSessionRepository<? extends Session> repository = new ReactiveRedisSessionRepository(redisTemplate);
	// end::new-reactiveredissessionrepository[]
}
 
Example 2
@Test
void enableSpringWebSessionConfiguresThings() {

	this.context = new AnnotationConfigApplicationContext();
	this.context.register(GoodConfig.class);
	this.context.refresh();

	WebSessionManager webSessionManagerFoundByType = this.context.getBean(WebSessionManager.class);
	Object webSessionManagerFoundByName = this.context.getBean(WebHttpHandlerBuilder.WEB_SESSION_MANAGER_BEAN_NAME);

	assertThat(webSessionManagerFoundByType).isNotNull();
	assertThat(webSessionManagerFoundByName).isNotNull();
	assertThat(webSessionManagerFoundByType).isEqualTo(webSessionManagerFoundByName);

	assertThat(this.context.getBean(ReactiveSessionRepository.class)).isNotNull();
}
 
Example 3
/**
 * Configure a {@link WebSessionManager} using a provided
 * {@link ReactiveSessionRepository}.
 * @param repository a bean that implements {@link ReactiveSessionRepository}.
 * @return a configured {@link WebSessionManager} registered with a preconfigured
 * name.
 */
@Bean(WebHttpHandlerBuilder.WEB_SESSION_MANAGER_BEAN_NAME)
public WebSessionManager webSessionManager(ReactiveSessionRepository<? extends Session> repository) {
	SpringSessionWebSessionStore<? extends Session> sessionStore = new SpringSessionWebSessionStore<>(repository);
	DefaultWebSessionManager manager = new DefaultWebSessionManager();
	manager.setSessionStore(sessionStore);

	if (this.webSessionIdResolver != null) {
		manager.setSessionIdResolver(this.webSessionIdResolver);
	}

	return manager;
}
 
Example 4
@Test
void missingReactiveSessionRepositoryBreaksAppContext() {

	this.context = new AnnotationConfigApplicationContext();
	this.context.register(BadConfig.class);

	assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(this.context::refresh)
			.withMessageContaining("Error creating bean with name 'webSessionManager'").withMessageContaining(
					"No qualifying bean of type '" + ReactiveSessionRepository.class.getCanonicalName());
}
 
Example 5
@Bean
public ReactiveSessionRepository sessionRepository() {
    return new ReactiveMapSessionRepository( new ConcurrentHashMap<>());
}
 
Example 6
@Bean
public ReactiveSessionRepository sessionRepository() {
    return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}
 
Example 7
Source Project: spring-session   Source File: SpringWebSessionConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public ReactiveSessionRepository reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}
 
Example 8
public SpringSessionWebSessionStore(ReactiveSessionRepository<S> reactiveSessionRepository) {
	Assert.notNull(reactiveSessionRepository, "reactiveSessionRepository cannot be null");
	this.sessions = reactiveSessionRepository;
}
 
Example 9
/**
 * Use Reactor-friendly, {@link java.util.Map}-backed
 * {@link ReactiveSessionRepository} for test purposes.
 */
@Bean
ReactiveSessionRepository<?> reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new HashMap<>());
}
 
Example 10
@Bean
ReactiveSessionRepository<?> reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new HashMap<>());
}
 
Example 11
Source Project: syncope   Source File: SessionConfig.java    License: Apache License 2.0 4 votes vote down vote up
@ConditionalOnMissingBean
@Bean
public ReactiveSessionRepository<MapSession> reactiveSessionRepository() {
    return new CacheManagerReactiveSessionRepository();
}
 
Example 12
Source Project: tutorials   Source File: SessionConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public ReactiveSessionRepository reactiveSessionRepository() {
    return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}