Skip to content

Commit bcbe53c

Browse files
vpavicrwinch
authored andcommitted
Make MongoSession package private
See gh-2170
1 parent 72742b5 commit bcbe53c

File tree

13 files changed

+36
-48
lines changed

13 files changed

+36
-48
lines changed
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.lang.reflect.Field;
2020

@@ -25,8 +25,6 @@
2525
import org.springframework.context.ApplicationContext;
2626
import org.springframework.core.serializer.DefaultDeserializer;
2727
import org.springframework.core.serializer.support.DeserializingConverter;
28-
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
29-
import org.springframework.session.data.mongo.JdkMongoSessionConverter;
3028
import org.springframework.util.ReflectionUtils;
3129

3230
/**
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.util.UUID;
2020

Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.time.Duration;
2020
import java.time.Instant;
@@ -37,8 +37,6 @@
3737
import org.springframework.security.core.context.SecurityContextHolder;
3838
import org.springframework.session.FindByIndexNameSessionRepository;
3939
import org.springframework.session.Session;
40-
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
41-
import org.springframework.session.data.mongo.MongoSession;
4240

4341
import static org.assertj.core.api.Assertions.assertThat;
4442

Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.net.URI;
2020

@@ -41,8 +41,6 @@
4141
import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
4242
import org.springframework.security.core.userdetails.User;
4343
import org.springframework.security.web.server.SecurityWebFilterChain;
44-
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
45-
import org.springframework.session.data.mongo.JacksonMongoSessionConverter;
4644
import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession;
4745
import org.springframework.test.context.ContextConfiguration;
4846
import org.springframework.test.context.junit.jupiter.SpringExtension;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.net.URI;
2020

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.util.Collections;
2020
import java.util.Map;
@@ -25,9 +25,6 @@
2525
import org.springframework.context.annotation.Bean;
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.data.geo.GeoModule;
28-
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
29-
import org.springframework.session.data.mongo.JacksonMongoSessionConverter;
30-
import org.springframework.session.data.mongo.MongoSession;
3128
import org.springframework.session.data.mongo.config.annotation.web.http.EnableMongoHttpSession;
3229
import org.springframework.test.context.ContextConfiguration;
3330

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.session.data.mongo.integration;
17+
package org.springframework.session.data.mongo;
1818

1919
import java.time.Duration;
2020
import java.util.Map;
@@ -23,9 +23,6 @@
2323

2424
import org.springframework.context.annotation.Bean;
2525
import org.springframework.context.annotation.Configuration;
26-
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
27-
import org.springframework.session.data.mongo.JdkMongoSessionConverter;
28-
import org.springframework.session.data.mongo.MongoSession;
2926
import org.springframework.session.data.mongo.config.annotation.web.http.EnableMongoHttpSession;
3027
import org.springframework.test.context.ContextConfiguration;
3128

spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/AbstractMongoSessionConverter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.session.FindByIndexNameSessionRepository;
3737
import org.springframework.session.IndexResolver;
3838
import org.springframework.session.PrincipalNameIndexResolver;
39+
import org.springframework.session.Session;
3940
import org.springframework.util.Assert;
4041

4142
/**
@@ -55,8 +56,7 @@ public abstract class AbstractMongoSessionConverter implements GenericConverter
5556

5657
private static final String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
5758

58-
private IndexResolver<MongoSession> indexResolver = new DelegatingIndexResolver<>(
59-
new PrincipalNameIndexResolver<>());
59+
private IndexResolver<Session> indexResolver = new DelegatingIndexResolver<>(new PrincipalNameIndexResolver<>());
6060

6161
/**
6262
* Returns query to be executed to return sessions based on a particular index.
@@ -123,7 +123,7 @@ else if (Document.class.isAssignableFrom(sourceType.getType())) {
123123

124124
protected abstract MongoSession convert(Document sessionWrapper);
125125

126-
public void setIndexResolver(IndexResolver<MongoSession> indexResolver) {
126+
public void setIndexResolver(IndexResolver<Session> indexResolver) {
127127
Assert.notNull(indexResolver, "indexResolver must not be null");
128128
this.indexResolver = indexResolver;
129129
}

spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoSession.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* @author Greg Turnquist
3838
* @since 1.2
3939
*/
40-
public class MongoSession implements Session {
40+
class MongoSession implements Session {
4141

4242
/**
4343
* Mongo doesn't support {@literal dot} in field names. We replace it with a unicode
@@ -66,15 +66,15 @@ public class MongoSession implements Session {
6666

6767
private Map<String, Object> attrs = new HashMap<>();
6868

69-
public MongoSession() {
69+
MongoSession() {
7070
this(MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS);
7171
}
7272

73-
public MongoSession(long maxInactiveIntervalInSeconds) {
73+
MongoSession(long maxInactiveIntervalInSeconds) {
7474
this(UUID.randomUUID().toString(), maxInactiveIntervalInSeconds);
7575
}
7676

77-
public MongoSession(String id, long maxInactiveIntervalInSeconds) {
77+
MongoSession(String id, long maxInactiveIntervalInSeconds) {
7878

7979
this.id = id;
8080
this.originalSessionId = id;
@@ -130,7 +130,7 @@ public Instant getCreationTime() {
130130
return Instant.ofEpochMilli(this.createdMillis);
131131
}
132132

133-
public void setCreationTime(long created) {
133+
void setCreationTime(long created) {
134134
this.createdMillis = created;
135135
}
136136

@@ -184,11 +184,11 @@ public String getId() {
184184
return this.id;
185185
}
186186

187-
public Date getExpireAt() {
187+
Date getExpireAt() {
188188
return this.expireAt;
189189
}
190190

191-
public void setExpireAt(final Date expireAt) {
191+
void setExpireAt(final Date expireAt) {
192192
this.expireAt = expireAt;
193193
}
194194

spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/config/annotation/web/http/MongoHttpSessionConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
import org.springframework.data.mongodb.core.MongoOperations;
3636
import org.springframework.session.IndexResolver;
3737
import org.springframework.session.MapSession;
38+
import org.springframework.session.Session;
3839
import org.springframework.session.config.SessionRepositoryCustomizer;
3940
import org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration;
4041
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
4142
import org.springframework.session.data.mongo.JdkMongoSessionConverter;
4243
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
43-
import org.springframework.session.data.mongo.MongoSession;
4444
import org.springframework.util.StringUtils;
4545
import org.springframework.util.StringValueResolver;
4646

@@ -68,7 +68,7 @@ public class MongoHttpSessionConfiguration implements BeanClassLoaderAware, Embe
6868

6969
private ClassLoader classLoader;
7070

71-
private IndexResolver<MongoSession> indexResolver;
71+
private IndexResolver<Session> indexResolver;
7272

7373
@Bean
7474
public MongoIndexedSessionRepository mongoSessionRepository(MongoOperations mongoOperations) {
@@ -156,7 +156,7 @@ public void setEmbeddedValueResolver(StringValueResolver resolver) {
156156
}
157157

158158
@Autowired(required = false)
159-
public void setIndexResolver(IndexResolver<MongoSession> indexResolver) {
159+
public void setIndexResolver(IndexResolver<Session> indexResolver) {
160160
this.indexResolver = indexResolver;
161161
}
162162

spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/config/annotation/web/reactive/ReactiveMongoWebSessionConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
3737
import org.springframework.session.IndexResolver;
3838
import org.springframework.session.MapSession;
39+
import org.springframework.session.Session;
3940
import org.springframework.session.config.ReactiveSessionRepositoryCustomizer;
4041
import org.springframework.session.config.annotation.web.server.SpringWebSessionConfiguration;
4142
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
4243
import org.springframework.session.data.mongo.JdkMongoSessionConverter;
43-
import org.springframework.session.data.mongo.MongoSession;
4444
import org.springframework.session.data.mongo.ReactiveMongoSessionRepository;
4545
import org.springframework.util.StringUtils;
4646
import org.springframework.util.StringValueResolver;
@@ -72,7 +72,7 @@ public class ReactiveMongoWebSessionConfiguration
7272

7373
private ClassLoader classLoader;
7474

75-
private IndexResolver<MongoSession> indexResolver;
75+
private IndexResolver<Session> indexResolver;
7676

7777
@Bean
7878
public ReactiveMongoSessionRepository reactiveMongoSessionRepository(ReactiveMongoOperations operations) {
@@ -176,7 +176,7 @@ public void setSessionRepositoryCustomizers(
176176
}
177177

178178
@Autowired(required = false)
179-
public void setIndexResolver(IndexResolver<MongoSession> indexResolver) {
179+
public void setIndexResolver(IndexResolver<Session> indexResolver) {
180180
this.indexResolver = indexResolver;
181181
}
182182

spring-session-data-mongodb/src/test/java/org/springframework/session/data/mongo/config/annotation/web/http/MongoHttpSessionConfigurationTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
import org.springframework.data.mongodb.core.index.IndexOperations;
3434
import org.springframework.mock.env.MockEnvironment;
3535
import org.springframework.session.IndexResolver;
36+
import org.springframework.session.Session;
3637
import org.springframework.session.config.SessionRepositoryCustomizer;
3738
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
3839
import org.springframework.session.data.mongo.JacksonMongoSessionConverter;
3940
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
40-
import org.springframework.session.data.mongo.MongoSession;
4141
import org.springframework.test.util.ReflectionTestUtils;
4242

4343
import static org.assertj.core.api.Assertions.assertThat;
@@ -170,7 +170,7 @@ void customIndexResolverConfigurationWithDefaultMongoSessionConverter() {
170170
CustomIndexResolverConfigurationWithDefaultMongoSessionConverter.class);
171171

172172
MongoIndexedSessionRepository repository = this.context.getBean(MongoIndexedSessionRepository.class);
173-
IndexResolver<MongoSession> indexResolver = this.context.getBean(IndexResolver.class);
173+
IndexResolver<Session> indexResolver = this.context.getBean(IndexResolver.class);
174174

175175
assertThat(repository).isNotNull();
176176
assertThat(indexResolver).isNotNull();
@@ -185,7 +185,7 @@ void customIndexResolverConfigurationWithProvidedMongoSessionConverter() {
185185
CustomIndexResolverConfigurationWithProvidedMongoSessionConverter.class);
186186

187187
MongoIndexedSessionRepository repository = this.context.getBean(MongoIndexedSessionRepository.class);
188-
IndexResolver<MongoSession> indexResolver = this.context.getBean(IndexResolver.class);
188+
IndexResolver<Session> indexResolver = this.context.getBean(IndexResolver.class);
189189

190190
assertThat(repository).isNotNull();
191191
assertThat(indexResolver).isNotNull();
@@ -316,7 +316,7 @@ static class CustomIndexResolverConfigurationWithDefaultMongoSessionConverter {
316316

317317
@Bean
318318
@SuppressWarnings("unchecked")
319-
IndexResolver<MongoSession> indexResolver() {
319+
IndexResolver<Session> indexResolver() {
320320
return mock(IndexResolver.class);
321321
}
322322

@@ -333,7 +333,7 @@ AbstractMongoSessionConverter mongoSessionConverter() {
333333

334334
@Bean
335335
@SuppressWarnings("unchecked")
336-
IndexResolver<MongoSession> indexResolver() {
336+
IndexResolver<Session> indexResolver() {
337337
return mock(IndexResolver.class);
338338
}
339339

spring-session-data-mongodb/src/test/java/org/springframework/session/data/mongo/config/annotation/web/reactive/ReactiveMongoWebSessionConfigurationTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
import org.springframework.data.mongodb.core.index.IndexOperations;
3535
import org.springframework.session.IndexResolver;
3636
import org.springframework.session.ReactiveSessionRepository;
37+
import org.springframework.session.Session;
3738
import org.springframework.session.config.ReactiveSessionRepositoryCustomizer;
3839
import org.springframework.session.config.annotation.web.server.EnableSpringWebSession;
3940
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
4041
import org.springframework.session.data.mongo.JacksonMongoSessionConverter;
4142
import org.springframework.session.data.mongo.JdkMongoSessionConverter;
42-
import org.springframework.session.data.mongo.MongoSession;
4343
import org.springframework.session.data.mongo.ReactiveMongoSessionRepository;
4444
import org.springframework.util.ReflectionUtils;
4545
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
@@ -189,7 +189,7 @@ void customIndexResolverConfigurationWithDefaultMongoSessionConverter() {
189189
this.context.refresh();
190190

191191
ReactiveMongoSessionRepository repository = this.context.getBean(ReactiveMongoSessionRepository.class);
192-
IndexResolver<MongoSession> indexResolver = this.context.getBean(IndexResolver.class);
192+
IndexResolver<Session> indexResolver = this.context.getBean(IndexResolver.class);
193193

194194
assertThat(repository).isNotNull();
195195
assertThat(indexResolver).isNotNull();
@@ -205,7 +205,7 @@ void customIndexResolverConfigurationWithProvidedMongoSessionConverter() {
205205
this.context.refresh();
206206

207207
ReactiveMongoSessionRepository repository = this.context.getBean(ReactiveMongoSessionRepository.class);
208-
IndexResolver<MongoSession> indexResolver = this.context.getBean(IndexResolver.class);
208+
IndexResolver<Session> indexResolver = this.context.getBean(IndexResolver.class);
209209

210210
assertThat(repository).isNotNull();
211211
assertThat(indexResolver).isNotNull();
@@ -367,7 +367,7 @@ ReactiveMongoOperations operations() {
367367

368368
@Bean
369369
@SuppressWarnings("unchecked")
370-
IndexResolver<MongoSession> indexResolver() {
370+
IndexResolver<Session> indexResolver() {
371371
return mock(IndexResolver.class);
372372
}
373373

@@ -389,7 +389,7 @@ JacksonMongoSessionConverter jacksonMongoSessionConverter() {
389389

390390
@Bean
391391
@SuppressWarnings("unchecked")
392-
IndexResolver<MongoSession> indexResolver() {
392+
IndexResolver<Session> indexResolver() {
393393
return mock(IndexResolver.class);
394394
}
395395

0 commit comments

Comments
 (0)