Harmonize naming of reactive components
Closes gh-897
This commit is contained in:
@@ -25,7 +25,7 @@ import org.springframework.session.events.SessionDeletedEvent;
|
||||
import org.springframework.session.events.SessionExpiredEvent;
|
||||
|
||||
/**
|
||||
* A {@link ReactorSessionRepository} backed by a {@link Map} and that uses a
|
||||
* A {@link ReactiveSessionRepository} backed by a {@link Map} and that uses a
|
||||
* {@link MapSession}. The injected {@link java.util.Map} can be backed by a distributed
|
||||
* NoSQL store like Hazelcast, for instance. Note that the supplied map itself is
|
||||
* responsible for purging the expired sessions.
|
||||
@@ -38,7 +38,7 @@ import org.springframework.session.events.SessionExpiredEvent;
|
||||
* @author Rob Winch
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MapReactorSessionRepository implements ReactorSessionRepository<MapSession> {
|
||||
public class MapReactiveSessionRepository implements ReactiveSessionRepository<MapSession> {
|
||||
|
||||
/**
|
||||
* If non-null, this value is used to override
|
||||
@@ -54,7 +54,7 @@ public class MapReactorSessionRepository implements ReactorSessionRepository<Map
|
||||
*
|
||||
* @param sessions the {@link Map} to use. Cannot be null.
|
||||
*/
|
||||
public MapReactorSessionRepository(Map<String, Session> sessions) {
|
||||
public MapReactiveSessionRepository(Map<String, Session> sessions) {
|
||||
if (sessions == null) {
|
||||
throw new IllegalArgumentException("sessions cannot be null");
|
||||
}
|
||||
@@ -25,11 +25,11 @@ import reactor.core.publisher.Mono;
|
||||
* @author Rob Winch
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface ReactorSessionRepository<S extends Session> {
|
||||
public interface ReactiveSessionRepository<S extends Session> {
|
||||
|
||||
/**
|
||||
* Creates a new {@link Session} that is capable of being persisted by this
|
||||
* {@link ReactorSessionRepository}.
|
||||
* {@link ReactiveSessionRepository}.
|
||||
*
|
||||
* <p>
|
||||
* This allows optimizations and customizations in how the {@link Session} is
|
||||
@@ -38,13 +38,13 @@ public interface ReactorSessionRepository<S extends Session> {
|
||||
* </p>
|
||||
*
|
||||
* @return a new {@link Session} that is capable of being persisted by this
|
||||
* {@link ReactorSessionRepository}
|
||||
* {@link ReactiveSessionRepository}
|
||||
*/
|
||||
Mono<S> createSession();
|
||||
|
||||
/**
|
||||
* Ensures the {@link Session} created by
|
||||
* {@link ReactorSessionRepository#createSession()} is saved.
|
||||
* {@link ReactiveSessionRepository#createSession()} is saved.
|
||||
*
|
||||
* <p>
|
||||
* Some implementations may choose to save as the {@link Session} is updated by
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Add this annotation to a {@code @Configuration} class to configure a {@code WebSessionManager} for a WebFlux
|
||||
* application. This annotation assumes a {@code ReactorSessionRepository} is defined somewhere in the application
|
||||
* application. This annotation assumes a {@code ReactiveSessionRepository} is defined somewhere in the application
|
||||
* context. If not, it will fail with a clear error messages. For example:
|
||||
*
|
||||
* <pre>
|
||||
@@ -34,8 +34,8 @@ import org.springframework.context.annotation.Import;
|
||||
* public class SpringWebFluxConfig {
|
||||
*
|
||||
* {@literal @Bean}
|
||||
* public ReactorSessionRepository sessionRepository() {
|
||||
* return new MapReactorSessionRepository();
|
||||
* public ReactiveSessionRepository sessionRepository() {
|
||||
* return new MapReactiveSessionRepository();
|
||||
* }
|
||||
*
|
||||
* }
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.session.config.annotation.web.server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.session.ReactorSessionRepository;
|
||||
import org.springframework.session.ReactiveSessionRepository;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.session.web.server.session.SpringSessionWebSessionStore;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
@@ -27,7 +27,7 @@ import org.springframework.web.server.session.WebSessionIdResolver;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
/**
|
||||
* Wire up a {@link WebSessionManager} using a Reactive {@link ReactorSessionRepository} from the application context.
|
||||
* Wire up a {@link WebSessionManager} using a Reactive {@link ReactiveSessionRepository} from the application context.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
* @author Rob Winch
|
||||
@@ -45,13 +45,13 @@ public class SpringWebSessionConfiguration {
|
||||
private WebSessionIdResolver webSessionIdResolver;
|
||||
|
||||
/**
|
||||
* Configure a {@link WebSessionManager} using a provided {@link ReactorSessionRepository}.
|
||||
* Configure a {@link WebSessionManager} using a provided {@link ReactiveSessionRepository}.
|
||||
*
|
||||
* @param repository - a bean that implements {@link ReactorSessionRepository}.
|
||||
* @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(ReactorSessionRepository<? extends Session> repository) {
|
||||
public WebSessionManager webSessionManager(ReactiveSessionRepository<? extends Session> repository) {
|
||||
SpringSessionWebSessionStore<? extends Session> sessionStore = new SpringSessionWebSessionStore<>(repository);
|
||||
DefaultWebSessionManager manager = new DefaultWebSessionManager();
|
||||
manager.setSessionStore(sessionStore);
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.session.ReactorSessionRepository;
|
||||
import org.springframework.session.ReactiveSessionRepository;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.server.WebSession;
|
||||
@@ -42,7 +42,7 @@ import org.springframework.web.server.session.WebSessionStore;
|
||||
/**
|
||||
* The {@link WebSessionStore} implementation that provides the {@link WebSession}
|
||||
* implementation backed by a {@link Session} returned by the
|
||||
* {@link ReactorSessionRepository}.
|
||||
* {@link ReactiveSessionRepository}.
|
||||
*
|
||||
* @param <S> the {@link Session} type
|
||||
* @author Rob Winch
|
||||
@@ -50,13 +50,13 @@ import org.springframework.web.server.session.WebSessionStore;
|
||||
*/
|
||||
public class SpringSessionWebSessionStore<S extends Session> implements WebSessionStore {
|
||||
|
||||
private final ReactorSessionRepository<S> sessions;
|
||||
private final ReactiveSessionRepository<S> sessions;
|
||||
|
||||
private Clock clock = Clock.system(ZoneOffset.UTC);
|
||||
|
||||
public SpringSessionWebSessionStore(ReactorSessionRepository<S> reactorSessionRepository) {
|
||||
Assert.notNull(reactorSessionRepository, "reactorSessionRepository cannot be null");
|
||||
this.sessions = reactorSessionRepository;
|
||||
public SpringSessionWebSessionStore(ReactiveSessionRepository<S> reactiveSessionRepository) {
|
||||
Assert.notNull(reactiveSessionRepository, "reactiveSessionRepository cannot be null");
|
||||
this.sessions = reactiveSessionRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,20 +29,20 @@ import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link MapReactorSessionRepository}.
|
||||
* Tests for {@link MapReactiveSessionRepository}.
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MapReactorSessionRepositoryTests {
|
||||
public class MapReactiveSessionRepositoryTests {
|
||||
|
||||
private MapReactorSessionRepository repository;
|
||||
private MapReactiveSessionRepository repository;
|
||||
|
||||
private MapSession session;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository = new MapReactorSessionRepository(new HashMap<>());
|
||||
this.repository = new MapReactiveSessionRepository(new HashMap<>());
|
||||
this.session = new MapSession("session-id");
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MapReactorSessionRepositoryTests {
|
||||
public void constructorMapThenFound() {
|
||||
Map<String, Session> sessions = new HashMap<>();
|
||||
sessions.put(this.session.getId(), this.session);
|
||||
this.repository = new MapReactorSessionRepository(sessions);
|
||||
this.repository = new MapReactiveSessionRepository(sessions);
|
||||
|
||||
Session findByIdSession = this.repository.findById(this.session.getId()).block();
|
||||
assertThat(findByIdSession).isNotNull();
|
||||
@@ -60,7 +60,7 @@ public class MapReactorSessionRepositoryTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void constructorMapWhenNullThenThrowsIllegalArgumentException() {
|
||||
Map<String, Session> sessions = null;
|
||||
new MapReactorSessionRepository(sessions);
|
||||
new MapReactiveSessionRepository(sessions);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ public class MapReactorSessionRepositoryTests {
|
||||
|
||||
Map<String, Session> sessions = new ConcurrentHashMap<>();
|
||||
sessions.put("session-id", this.session);
|
||||
this.repository = new MapReactorSessionRepository(sessions);
|
||||
this.repository = new MapReactiveSessionRepository(sessions);
|
||||
|
||||
assertThat(this.repository.findById(this.session.getId()).block()).isNull();
|
||||
assertThat(sessions).isEmpty();
|
||||
@@ -64,11 +64,11 @@ public class SpringWebSessionConfigurationTests {
|
||||
assertThat(webSessionManagerFoundByName).isNotNull();
|
||||
assertThat(webSessionManagerFoundByType).isEqualTo(webSessionManagerFoundByName);
|
||||
|
||||
assertThat(this.context.getBean(ReactorSessionRepository.class)).isNotNull();
|
||||
assertThat(this.context.getBean(ReactiveSessionRepository.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingReactorSessionRepositoryBreaksAppContext() {
|
||||
public void missingReactiveSessionRepositoryBreaksAppContext() {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(BadConfig.class);
|
||||
@@ -76,7 +76,7 @@ public class SpringWebSessionConfigurationTests {
|
||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class)
|
||||
.isThrownBy(this.context::refresh)
|
||||
.withMessageContaining("Error creating bean with name 'webSessionManager'")
|
||||
.withMessageContaining("No qualifying bean of type '" + ReactorSessionRepository.class.getCanonicalName());
|
||||
.withMessageContaining("No qualifying bean of type '" + ReactiveSessionRepository.class.getCanonicalName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,16 +108,16 @@ public class SpringWebSessionConfigurationTests {
|
||||
static class GoodConfig {
|
||||
|
||||
/**
|
||||
* Use Reactor-friendly, {@link java.util.Map}-backed {@link ReactorSessionRepository} for test purposes.
|
||||
* Use Reactor-friendly, {@link java.util.Map}-backed {@link ReactiveSessionRepository} for test purposes.
|
||||
*/
|
||||
@Bean
|
||||
ReactorSessionRepository<?> reactorSessionRepository() {
|
||||
return new MapReactorSessionRepository(new HashMap<>());
|
||||
ReactiveSessionRepository<?> reactiveSessionRepository() {
|
||||
return new MapReactiveSessionRepository(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A configuration where no {@link ReactorSessionRepository} is defined. It's BAD!
|
||||
* A configuration where no {@link ReactiveSessionRepository} is defined. It's BAD!
|
||||
*/
|
||||
@EnableSpringWebSession
|
||||
static class BadConfig {
|
||||
@@ -128,8 +128,8 @@ public class SpringWebSessionConfigurationTests {
|
||||
static class OverrideSessionIdResolver {
|
||||
|
||||
@Bean
|
||||
ReactorSessionRepository<?> reactorSessionRepository() {
|
||||
return new MapReactorSessionRepository(new HashMap<>());
|
||||
ReactiveSessionRepository<?> reactiveSessionRepository() {
|
||||
return new MapReactiveSessionRepository(new HashMap<>());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.session.ReactorSessionRepository;
|
||||
import org.springframework.session.ReactiveSessionRepository;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.web.server.WebSession;
|
||||
|
||||
@@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
|
||||
public class SpringSessionWebSessionStoreTests<S extends Session> {
|
||||
|
||||
@Mock
|
||||
private ReactorSessionRepository<S> sessionRepository;
|
||||
private ReactiveSessionRepository<S> sessionRepository;
|
||||
|
||||
@Mock
|
||||
private S createSession;
|
||||
|
||||
Reference in New Issue
Block a user