org.springframework.session.ReactiveSessionRepository Java Examples

The following examples show how to use org.springframework.session.ReactiveSessionRepository. 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 File: IndexDocTests.java    From spring-session with 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
Source File: SpringWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@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
Source File: SpringWebSessionConfiguration.java    From spring-session with Apache License 2.0 5 votes vote down vote up
/**
 * 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
Source File: SpringWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@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
Source File: SessionConfig.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public ReactiveSessionRepository sessionRepository() {
    return new ReactiveMapSessionRepository( new ConcurrentHashMap<>());
}
 
Example #6
Source File: SessionConfig.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public ReactiveSessionRepository sessionRepository() {
    return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}
 
Example #7
Source File: SpringWebSessionConfig.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Bean
public ReactiveSessionRepository reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}
 
Example #8
Source File: SpringSessionWebSessionStore.java    From spring-session with Apache License 2.0 4 votes vote down vote up
public SpringSessionWebSessionStore(ReactiveSessionRepository<S> reactiveSessionRepository) {
	Assert.notNull(reactiveSessionRepository, "reactiveSessionRepository cannot be null");
	this.sessions = reactiveSessionRepository;
}
 
Example #9
Source File: SpringWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 4 votes vote down vote up
/**
 * Use Reactor-friendly, {@link java.util.Map}-backed
 * {@link ReactiveSessionRepository} for test purposes.
 */
@Bean
ReactiveSessionRepository<?> reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new HashMap<>());
}
 
Example #10
Source File: SpringWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Bean
ReactiveSessionRepository<?> reactiveSessionRepository() {
	return new ReactiveMapSessionRepository(new HashMap<>());
}
 
Example #11
Source File: SessionConfig.java    From syncope with Apache License 2.0 4 votes vote down vote up
@ConditionalOnMissingBean
@Bean
public ReactiveSessionRepository<MapSession> reactiveSessionRepository() {
    return new CacheManagerReactiveSessionRepository();
}
 
Example #12
Source File: SessionConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public ReactiveSessionRepository reactiveSessionRepository() {
    return new ReactiveMapSessionRepository(new ConcurrentHashMap<>());
}