Skip to content

Commit c6b215c

Browse files
committed
Reformatting the code.. spring-projects#96
1 parent 09822b5 commit c6b215c

File tree

3 files changed

+319
-343
lines changed

3 files changed

+319
-343
lines changed

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

+81-81
Original file line numberDiff line numberDiff line change
@@ -46,86 +46,86 @@
4646
*/
4747
@Configuration
4848
public class MongoHttpSessionConfiguration extends SpringHttpSessionConfiguration
49-
implements BeanClassLoaderAware, EmbeddedValueResolverAware, ImportAware {
50-
51-
private AbstractMongoSessionConverter mongoSessionConverter;
52-
private Integer maxInactiveIntervalInSeconds;
53-
private String collectionName;
54-
private StringValueResolver embeddedValueResolver;
55-
private ClassLoader classLoader;
56-
private MongoOperations mongoOperations;
57-
58-
@Autowired
59-
public void setMongoOperations(
60-
@SpringSessionMongoOperations ObjectProvider<MongoOperations> springSessionMongoOperations,
61-
ObjectProvider<MongoOperations> mongoOperations) {
62-
MongoOperations mongoOperationsToUse = springSessionMongoOperations.getIfAvailable();
63-
if (mongoOperationsToUse == null) {
64-
mongoOperationsToUse = mongoOperations.getObject();
65-
}
66-
this.mongoOperations = mongoOperationsToUse;
67-
}
68-
69-
@Bean
70-
public MongoOperationsSessionRepository mongoSessionRepository() {
71-
72-
MongoOperationsSessionRepository repository = new MongoOperationsSessionRepository(mongoOperations);
73-
repository.setMaxInactiveIntervalInSeconds(this.maxInactiveIntervalInSeconds);
74-
75-
if (this.mongoSessionConverter != null) {
76-
repository.setMongoSessionConverter(this.mongoSessionConverter);
77-
} else {
78-
JdkMongoSessionConverter mongoSessionConverter = new JdkMongoSessionConverter(new SerializingConverter(),
79-
new DeserializingConverter(this.classLoader),
80-
Duration.ofSeconds(MongoOperationsSessionRepository.DEFAULT_INACTIVE_INTERVAL));
81-
repository.setMongoSessionConverter(mongoSessionConverter);
82-
}
83-
84-
if (StringUtils.hasText(this.collectionName)) {
85-
repository.setCollectionName(this.collectionName);
86-
}
87-
88-
return repository;
89-
}
90-
91-
public void setCollectionName(String collectionName) {
92-
this.collectionName = collectionName;
93-
}
94-
95-
public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds) {
96-
this.maxInactiveIntervalInSeconds = maxInactiveIntervalInSeconds;
97-
}
98-
99-
public void setImportMetadata(AnnotationMetadata importMetadata) {
100-
101-
AnnotationAttributes attributes = AnnotationAttributes
102-
.fromMap(importMetadata.getAnnotationAttributes(EnableMongoHttpSession.class.getName()));
103-
104-
if (attributes != null) {
105-
this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
106-
} else {
107-
this.maxInactiveIntervalInSeconds = MongoOperationsSessionRepository.DEFAULT_INACTIVE_INTERVAL;
108-
}
109-
110-
String collectionNameValue = attributes != null ? attributes.getString("collectionName") : "";
111-
if (StringUtils.hasText(collectionNameValue)) {
112-
this.collectionName = this.embeddedValueResolver.resolveStringValue(collectionNameValue);
113-
}
114-
}
115-
116-
@Autowired(required = false)
117-
public void setMongoSessionConverter(AbstractMongoSessionConverter mongoSessionConverter) {
118-
this.mongoSessionConverter = mongoSessionConverter;
119-
}
120-
121-
@Override
122-
public void setBeanClassLoader(ClassLoader classLoader) {
123-
this.classLoader = classLoader;
124-
}
125-
126-
@Override
127-
public void setEmbeddedValueResolver(StringValueResolver resolver) {
128-
this.embeddedValueResolver = resolver;
129-
}
49+
implements BeanClassLoaderAware, EmbeddedValueResolverAware, ImportAware {
50+
51+
private AbstractMongoSessionConverter mongoSessionConverter;
52+
private Integer maxInactiveIntervalInSeconds;
53+
private String collectionName;
54+
private StringValueResolver embeddedValueResolver;
55+
private ClassLoader classLoader;
56+
private MongoOperations mongoOperations;
57+
58+
@Autowired
59+
public void setMongoOperations(
60+
@SpringSessionMongoOperations ObjectProvider<MongoOperations> springSessionMongoOperations,
61+
ObjectProvider<MongoOperations> mongoOperations) {
62+
MongoOperations mongoOperationsToUse = springSessionMongoOperations.getIfAvailable();
63+
if (mongoOperationsToUse == null) {
64+
mongoOperationsToUse = mongoOperations.getObject();
65+
}
66+
this.mongoOperations = mongoOperationsToUse;
67+
}
68+
69+
@Bean
70+
public MongoOperationsSessionRepository mongoSessionRepository() {
71+
72+
MongoOperationsSessionRepository repository = new MongoOperationsSessionRepository(mongoOperations);
73+
repository.setMaxInactiveIntervalInSeconds(this.maxInactiveIntervalInSeconds);
74+
75+
if (this.mongoSessionConverter != null) {
76+
repository.setMongoSessionConverter(this.mongoSessionConverter);
77+
} else {
78+
JdkMongoSessionConverter mongoSessionConverter = new JdkMongoSessionConverter(new SerializingConverter(),
79+
new DeserializingConverter(this.classLoader),
80+
Duration.ofSeconds(MongoOperationsSessionRepository.DEFAULT_INACTIVE_INTERVAL));
81+
repository.setMongoSessionConverter(mongoSessionConverter);
82+
}
83+
84+
if (StringUtils.hasText(this.collectionName)) {
85+
repository.setCollectionName(this.collectionName);
86+
}
87+
88+
return repository;
89+
}
90+
91+
public void setCollectionName(String collectionName) {
92+
this.collectionName = collectionName;
93+
}
94+
95+
public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds) {
96+
this.maxInactiveIntervalInSeconds = maxInactiveIntervalInSeconds;
97+
}
98+
99+
public void setImportMetadata(AnnotationMetadata importMetadata) {
100+
101+
AnnotationAttributes attributes = AnnotationAttributes.fromMap(
102+
importMetadata.getAnnotationAttributes(EnableMongoHttpSession.class.getName()));
103+
104+
if (attributes != null) {
105+
this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
106+
} else {
107+
this.maxInactiveIntervalInSeconds = MongoOperationsSessionRepository.DEFAULT_INACTIVE_INTERVAL;
108+
}
109+
110+
String collectionNameValue = attributes != null ? attributes.getString("collectionName") : "";
111+
if (StringUtils.hasText(collectionNameValue)) {
112+
this.collectionName = this.embeddedValueResolver.resolveStringValue(collectionNameValue);
113+
}
114+
}
115+
116+
@Autowired(required = false)
117+
public void setMongoSessionConverter(AbstractMongoSessionConverter mongoSessionConverter) {
118+
this.mongoSessionConverter = mongoSessionConverter;
119+
}
120+
121+
@Override
122+
public void setBeanClassLoader(ClassLoader classLoader) {
123+
this.classLoader = classLoader;
124+
}
125+
126+
@Override
127+
public void setEmbeddedValueResolver(StringValueResolver resolver) {
128+
this.embeddedValueResolver = resolver;
129+
}
130130

131131
}

src/main/java/org/springframework/session/data/mongo/config/annotation/web/http/SpringSessionMongoOperations.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
* See the License for the specific language governing permissions and
2020
* limitations under the License.
2121
*/
22+
2223
/**
2324
* Qualifier annotation for a {@link org.springframework.data.mongodb.core.MongoOperations} to be injected in
2425
* {@link org.springframework.session.data.mongo.MongoOperationsSessionRepository}.
25-
*
26+
* <p>
2627
* This will enable us to have multiple MongoOperations in the application.
2728
*
2829
* @author Visweshwar Ganesh
2930
* @since 2.2.0
3031
*/
31-
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE,
32-
ElementType.ANNOTATION_TYPE })
32+
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
3333
@Retention(RetentionPolicy.RUNTIME)
3434
@Documented
3535
@Qualifier

0 commit comments

Comments
 (0)