Polish JDBC configuration (#608)
This commit is contained in:
@@ -130,7 +130,10 @@ import org.springframework.util.StringUtils;
|
||||
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";
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
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
|
||||
@@ -75,7 +77,7 @@ public @interface EnableJdbcHttpSession {
|
||||
* 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).
|
||||
@@ -83,6 +85,6 @@ public @interface EnableJdbcHttpSession {
|
||||
*
|
||||
* @return the seconds a session can be inactive before expiring
|
||||
*/
|
||||
int maxInactiveIntervalInSeconds() default 1800;
|
||||
int maxInactiveIntervalInSeconds() default MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS;
|
||||
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ import org.springframework.util.StringUtils;
|
||||
public class JdbcHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
implements ImportAware {
|
||||
|
||||
private String tableName = "";
|
||||
private String tableName;
|
||||
|
||||
private Integer maxInactiveIntervalInSeconds = 1800;
|
||||
private Integer maxInactiveIntervalInSeconds;
|
||||
|
||||
private LobHandler lobHandler;
|
||||
|
||||
@@ -116,10 +116,11 @@ public class JdbcHttpSessionConfiguration extends SpringHttpSessionConfiguration
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user