Expose attributes in MongoHttpSessionConfiguration
Attributes collectionName and maxInactiveIntervalInSeconds can be set now. Fixes gh-489
This commit is contained in:
@@ -31,10 +31,11 @@ import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
|
||||
* configuration use {@link EnableMongoHttpSession} annotation.
|
||||
*
|
||||
* @author Jakub Kubrynski
|
||||
* @author Eddú Meléndez
|
||||
* @since 1.2
|
||||
*/
|
||||
@Configuration
|
||||
class MongoHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
public class MongoHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
implements ImportAware {
|
||||
|
||||
private AbstractMongoSessionConverter mongoSessionConverter;
|
||||
@@ -43,11 +44,10 @@ class MongoHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
private String collectionName;
|
||||
|
||||
@Bean
|
||||
MongoOperationsSessionRepository mongoSessionRepository(
|
||||
public MongoOperationsSessionRepository mongoSessionRepository(
|
||||
MongoOperations mongoOperations) {
|
||||
MongoOperationsSessionRepository repository = new MongoOperationsSessionRepository(
|
||||
mongoOperations);
|
||||
repository.setCollectionName(this.collectionName);
|
||||
repository.setMaxInactiveIntervalInSeconds(this.maxInactiveIntervalInSeconds);
|
||||
if (this.mongoSessionConverter != null) {
|
||||
repository.setMongoSessionConverter(this.mongoSessionConverter);
|
||||
@@ -55,6 +55,14 @@ class MongoHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setCollectionName(String collectionName) {
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
|
||||
public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds) {
|
||||
this.maxInactiveIntervalInSeconds = maxInactiveIntervalInSeconds;
|
||||
}
|
||||
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(importMetadata
|
||||
.getAnnotationAttributes(EnableMongoHttpSession.class.getName()));
|
||||
|
||||
Reference in New Issue
Block a user