Java Code Examples for org.springframework.web.server.session.WebSessionManager

The following examples show how to use org.springframework.web.server.session.WebSessionManager. 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-analysis-note   Source File: DefaultServerWebExchange.java    License: MIT License 6 votes vote down vote up
DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver, @Nullable ApplicationContext applicationContext) {

	Assert.notNull(request, "'request' is required");
	Assert.notNull(response, "'response' is required");
	Assert.notNull(sessionManager, "'sessionManager' is required");
	Assert.notNull(codecConfigurer, "'codecConfigurer' is required");
	Assert.notNull(localeContextResolver, "'localeContextResolver' is required");

	// Initialize before first call to getLogPrefix()
	this.attributes.put(ServerWebExchange.LOG_ID_ATTRIBUTE, request.getId());

	this.request = request;
	this.response = response;
	this.sessionMono = sessionManager.getSession(this).cache();
	this.localeContextResolver = localeContextResolver;
	this.formDataMono = initFormData(request, codecConfigurer, getLogPrefix());
	this.multipartDataMono = initMultipartData(request, codecConfigurer, getLogPrefix());
	this.applicationContext = applicationContext;
}
 
Example 2
Source Project: java-technology-stack   Source File: DefaultServerWebExchange.java    License: MIT License 6 votes vote down vote up
DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver, @Nullable ApplicationContext applicationContext) {

	Assert.notNull(request, "'request' is required");
	Assert.notNull(response, "'response' is required");
	Assert.notNull(sessionManager, "'sessionManager' is required");
	Assert.notNull(codecConfigurer, "'codecConfigurer' is required");
	Assert.notNull(localeContextResolver, "'localeContextResolver' is required");

	// Initialize before first call to getLogPrefix()
	this.attributes.put(ServerWebExchange.LOG_ID_ATTRIBUTE, request.getId());

	this.request = request;
	this.response = response;
	this.sessionMono = sessionManager.getSession(this).cache();
	this.localeContextResolver = localeContextResolver;
	this.formDataMono = initFormData(request, codecConfigurer, getLogPrefix());
	this.multipartDataMono = initMultipartData(request, codecConfigurer, getLogPrefix());
	this.applicationContext = applicationContext;
}
 
Example 3
@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 4
/**
 * 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 5
Source Project: spring-analysis-note   Source File: HttpWebHandlerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * Return the configured {@link WebSessionManager}.
 */
public WebSessionManager getSessionManager() {
	return this.sessionManager;
}
 
Example 6
Source Project: spring-analysis-note   Source File: DefaultServerWebExchange.java    License: MIT License 4 votes vote down vote up
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver) {

	this(request, response, sessionManager, codecConfigurer, localeContextResolver, null);
}
 
Example 7
Source Project: spring-analysis-note   Source File: MockServerWebExchange.java    License: MIT License 4 votes vote down vote up
private MockServerWebExchange(MockServerHttpRequest request, WebSessionManager sessionManager) {
	super(request, new MockServerHttpResponse(), sessionManager,
			ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
}
 
Example 8
Source Project: spring-analysis-note   Source File: MockServerWebExchange.java    License: MIT License 4 votes vote down vote up
private MockServerWebExchange(MockServerHttpRequest request, WebSessionManager sessionManager) {
	super(request, new MockServerHttpResponse(), sessionManager,
			ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
}
 
Example 9
Source Project: spring-analysis-note   Source File: AbstractMockServerSpec.java    License: MIT License 4 votes vote down vote up
@Override
public <T extends B> T webSessionManager(WebSessionManager sessionManager) {
	this.sessionManager = sessionManager;
	return self();
}
 
Example 10
Source Project: spring-analysis-note   Source File: ApplicationContextSpecTests.java    License: MIT License 4 votes vote down vote up
@Bean
public WebSessionManager webSessionManager() {
	MockWebSession session = new MockWebSession();
	return exchange -> Mono.just(session);
}
 
Example 11
Source Project: java-technology-stack   Source File: HttpWebHandlerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * Return the configured {@link WebSessionManager}.
 */
public WebSessionManager getSessionManager() {
	return this.sessionManager;
}
 
Example 12
Source Project: java-technology-stack   Source File: DefaultServerWebExchange.java    License: MIT License 4 votes vote down vote up
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver) {

	this(request, response, sessionManager, codecConfigurer, localeContextResolver, null);
}
 
Example 13
Source Project: java-technology-stack   Source File: MockServerWebExchange.java    License: MIT License 4 votes vote down vote up
private MockServerWebExchange(MockServerHttpRequest request, WebSessionManager sessionManager) {
	super(request, new MockServerHttpResponse(), sessionManager,
			ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
}
 
Example 14
Source Project: java-technology-stack   Source File: MockServerWebExchange.java    License: MIT License 4 votes vote down vote up
private MockServerWebExchange(MockServerHttpRequest request, WebSessionManager sessionManager) {
	super(request, new MockServerHttpResponse(), sessionManager,
			ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
}
 
Example 15
Source Project: java-technology-stack   Source File: AbstractMockServerSpec.java    License: MIT License 4 votes vote down vote up
@Override
public <T extends B> T webSessionManager(WebSessionManager sessionManager) {
	this.sessionManager = sessionManager;
	return self();
}
 
Example 16
@Bean
public WebSessionManager webSessionManager() {
	MockWebSession session = new MockWebSession();
	return exchange -> Mono.just(session);
}
 
Example 17
@Bean
WebSessionManager webSessionManager() {
	return exchange -> Mono.just(mockWebSession);
}
 
Example 18
Source Project: spring-analysis-note   Source File: WebHttpHandlerBuilder.java    License: MIT License 2 votes vote down vote up
/**
 * Configure the {@link WebSessionManager} to set on the
 * {@link ServerWebExchange WebServerExchange}.
 * <p>By default {@link DefaultWebSessionManager} is used.
 * @param manager the session manager
 * @see HttpWebHandlerAdapter#setSessionManager(WebSessionManager)
 */
public WebHttpHandlerBuilder sessionManager(WebSessionManager manager) {
	this.sessionManager = manager;
	return this;
}
 
Example 19
Source Project: spring-analysis-note   Source File: HttpWebHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * Configure a custom {@link WebSessionManager} to use for managing web
 * sessions. The provided instance is set on each created
 * {@link DefaultServerWebExchange}.
 * <p>By default this is set to {@link DefaultWebSessionManager}.
 * @param sessionManager the session manager to use
 */
public void setSessionManager(WebSessionManager sessionManager) {
	Assert.notNull(sessionManager, "WebSessionManager must not be null");
	this.sessionManager = sessionManager;
}
 
Example 20
Source Project: spring-analysis-note   Source File: WebTestClient.java    License: MIT License 2 votes vote down vote up
/**
 * Provide a session manager instance for the mock server.
 * <p>By default an instance of
 * {@link org.springframework.web.server.session.DefaultWebSessionManager
 * DefaultWebSessionManager} is used.
 * @param sessionManager the session manager to use
 */
<T extends B> T webSessionManager(WebSessionManager sessionManager);
 
Example 21
Source Project: java-technology-stack   Source File: WebHttpHandlerBuilder.java    License: MIT License 2 votes vote down vote up
/**
 * Configure the {@link WebSessionManager} to set on the
 * {@link ServerWebExchange WebServerExchange}.
 * <p>By default {@link DefaultWebSessionManager} is used.
 * @param manager the session manager
 * @see HttpWebHandlerAdapter#setSessionManager(WebSessionManager)
 */
public WebHttpHandlerBuilder sessionManager(WebSessionManager manager) {
	this.sessionManager = manager;
	return this;
}
 
Example 22
Source Project: java-technology-stack   Source File: HttpWebHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * Configure a custom {@link WebSessionManager} to use for managing web
 * sessions. The provided instance is set on each created
 * {@link DefaultServerWebExchange}.
 * <p>By default this is set to {@link DefaultWebSessionManager}.
 * @param sessionManager the session manager to use
 */
public void setSessionManager(WebSessionManager sessionManager) {
	Assert.notNull(sessionManager, "WebSessionManager must not be null");
	this.sessionManager = sessionManager;
}
 
Example 23
Source Project: java-technology-stack   Source File: WebTestClient.java    License: MIT License 2 votes vote down vote up
/**
 * Provide a session manager instance for the mock server.
 * <p>By default an instance of
 * {@link org.springframework.web.server.session.DefaultWebSessionManager
 * DefaultWebSessionManager} is used.
 * @param sessionManager the session manager to use
 */
<T extends B> T webSessionManager(WebSessionManager sessionManager);