Skip to content

Commit

Permalink
Polish JDBC configuration (spring-projects#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavic authored and rwinch committed Sep 2, 2016
1 parent de7bb05 commit 3e293e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@
public class JdbcOperationsSessionRepository implements
FindByIndexNameSessionRepository<JdbcOperationsSessionRepository.JdbcSession> {

private static final String DEFAULT_TABLE_NAME = "SPRING_SESSION";
/**
* The default name of database table used by Spring Session to store sessions.
*/
public static final String DEFAULT_TABLE_NAME = "SPRING_SESSION";

private static final String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.session.MapSession;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
import org.springframework.session.jdbc.JdbcOperationsSessionRepository;

/**
* Add this annotation to an {@code @Configuration} class to expose the
Expand Down Expand Up @@ -75,14 +77,14 @@
* The name of database table used by Spring Session to store sessions.
* @return the database table name
*/
String tableName() default "";
String tableName() default JdbcOperationsSessionRepository.DEFAULT_TABLE_NAME;

/**
* The session timeout in seconds. By default, it is set to 1800 seconds (30 minutes).
* This should be a non-negative integer.
*
* @return the seconds a session can be inactive before expiring
*/
int maxInactiveIntervalInSeconds() default 1800;
int maxInactiveIntervalInSeconds() default MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS;

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
public class JdbcHttpSessionConfiguration extends SpringHttpSessionConfiguration
implements ImportAware {

private String tableName = "";
private String tableName;

private Integer maxInactiveIntervalInSeconds = 1800;
private Integer maxInactiveIntervalInSeconds;

private LobHandler lobHandler;

Expand Down Expand Up @@ -116,10 +116,11 @@ public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds
}

private String getTableName() {
if (StringUtils.hasText(this.tableName)) {
return this.tableName;
String systemProperty = System.getProperty("spring.session.jdbc.tableName", "");
if (StringUtils.hasText(systemProperty)) {
return systemProperty;
}
return System.getProperty("spring.session.jdbc.tableName", "");
return this.tableName;
}

public void setImportMetadata(AnnotationMetadata importMetadata) {
Expand Down

0 comments on commit 3e293e8

Please sign in to comment.