Skip to content
Permalink
Browse files
Fix Per Comments
  • Loading branch information
atris committed Jun 21, 2021
1 parent 70645fe commit 625d287afb799d7bbc0b8a169622c5d1a61efdd9
Showing 9 changed files with 292 additions and 191 deletions.
@@ -23,13 +23,13 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.8</version>
<version>${spring.version.for.sessions}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.3.8</version>
<version>${spring.version.for.sessions}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.8</version>
<version>${spring.version.for.sessions}</version>
</dependency>

<dependency>
@@ -62,7 +62,7 @@
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>2.11.0-SNAPSHOT</version>
<version>2.10.0</version>
<scope>compile</scope>
</dependency>

@@ -86,7 +86,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.8</version>
<version>${spring.version.for.sessions}</version>
<scope>test</scope>
</dependency>

@@ -109,7 +109,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.8</version>
<version>${spring.version.for.sessions}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.ignite/ignite-indexing -->
@@ -131,4 +131,4 @@
</dependencies>


</project>
</project>
@@ -96,4 +96,4 @@
*/
SaveMode saveMode() default SaveMode.ON_SET_ATTRIBUTE;

}
}
@@ -49,99 +49,154 @@
@Configuration(proxyBeanMethods = false)
public class IgniteHttpSessionConfiguration extends SpringHttpSessionConfiguration implements ImportAware {

/**
*
*/
private Integer maxInactiveIntervalInSeconds = MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS;

/**
*
*/
private String sessionMapName = IgniteIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME;

/**
*
*/
private FlushMode flushMode = FlushMode.ON_SAVE;

/**
*
*/
private SaveMode saveMode = SaveMode.ON_SET_ATTRIBUTE;

/**
*
*/
private Ignite ignite;

/**
*
*/
private ApplicationEventPublisher applicationEventPublisher;

/**
*
*/
private IndexResolver<Session> indexResolver;

/**
*
*/
private List<SessionRepositoryCustomizer<IgniteIndexedSessionRepository>> sessionRepositoryCustomizers;

/**
*
*/
@Bean
public SessionRepository<?> sessionRepository() {
return createIgniteIndexedSessionRepository();
}

/**
*
*/
public void setMaxInactiveIntervalInSeconds(int maxInactiveIntervalInSeconds) {
this.maxInactiveIntervalInSeconds = maxInactiveIntervalInSeconds;
}

/**
*
*/
public void setSessionMapName(String sessionMapName) {
this.sessionMapName = sessionMapName;
}

/**
*
*/
public void setFlushMode(FlushMode flushMode) {
this.flushMode = flushMode;
}

/**
*
*/
public void setSaveMode(SaveMode saveMode) {
this.saveMode = saveMode;
}

/**
*
*/
@Autowired
public void setIgnite(@SpringSessionIgnite ObjectProvider<Ignite> springSessionIgnite,
ObjectProvider<Ignite> ignite) {
Ignite igniteToUse = springSessionIgnite.getIfAvailable();
if (igniteToUse == null) {
if (igniteToUse == null)
igniteToUse = ignite.getObject();
}

this.ignite = igniteToUse;
}

/**
*
*/
@Autowired
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}

/**
*
*/
@Autowired(required = false)
public void setIndexResolver(IndexResolver<Session> indexResolver) {
this.indexResolver = indexResolver;
}

/**
*
*/
@Autowired(required = false)
public void setSessionRepositoryCustomizer(
ObjectProvider<SessionRepositoryCustomizer<IgniteIndexedSessionRepository>> sessionRepositoryCustomizers) {
this.sessionRepositoryCustomizers = sessionRepositoryCustomizers.orderedStream().collect(Collectors.toList());
}

@Override
@SuppressWarnings("deprecation")
public void setImportMetadata(AnnotationMetadata importMetadata) {
/**
*
*/
@Override @SuppressWarnings("deprecation") public void setImportMetadata(AnnotationMetadata importMetadata) {
Map<String, Object> attributeMap = importMetadata
.getAnnotationAttributes(EnableIgniteHttpSession.class.getName());
AnnotationAttributes attributes = AnnotationAttributes.fromMap(attributeMap);
this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
String sessionMapNameValue = attributes.getString("sessionMapName");
if (StringUtils.hasText(sessionMapNameValue)) {
if (StringUtils.hasText(sessionMapNameValue))
this.sessionMapName = sessionMapNameValue;
}

this.flushMode = attributes.getEnum("flushMode");
this.saveMode = attributes.getEnum("saveMode");
}

/**
*
*/
private IgniteIndexedSessionRepository createIgniteIndexedSessionRepository() {
IgniteIndexedSessionRepository sessionRepository = new IgniteIndexedSessionRepository(this.ignite);
sessionRepository.setApplicationEventPublisher(this.applicationEventPublisher);
if (this.indexResolver != null) {
if (this.indexResolver != null)
sessionRepository.setIndexResolver(this.indexResolver);
}
if (StringUtils.hasText(this.sessionMapName)) {

if (StringUtils.hasText(this.sessionMapName))
sessionRepository.setSessionMapName(this.sessionMapName);
}

sessionRepository.setDefaultMaxInactiveInterval(this.maxInactiveIntervalInSeconds);
sessionRepository.setFlushMode(this.flushMode);
sessionRepository.setSaveMode(this.saveMode);
this.sessionRepositoryCustomizers
.forEach((sessionRepositoryCustomizer) -> sessionRepositoryCustomizer.customize(sessionRepository));
return sessionRepository;
}

}

0 comments on commit 625d287

Please sign in to comment.