diff --git a/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoIndexedSessionRepository.java b/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoIndexedSessionRepository.java index 8a7b4ec4..301eacaf 100644 --- a/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoIndexedSessionRepository.java +++ b/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoIndexedSessionRepository.java @@ -193,6 +193,19 @@ public class MongoIndexedSessionRepository this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setMaxInactiveIntervalInSeconds(Integer defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + public void setCollectionName(final String collectionName) { this.collectionName = collectionName; } diff --git a/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/ReactiveMongoSessionRepository.java b/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/ReactiveMongoSessionRepository.java index fc6bf62f..71c06c35 100644 --- a/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/ReactiveMongoSessionRepository.java +++ b/spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/ReactiveMongoSessionRepository.java @@ -187,6 +187,19 @@ public class ReactiveMongoSessionRepository this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setMaxInactiveIntervalInSeconds(Integer defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + public String getCollectionName() { return this.collectionName; } diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisSessionRepository.java index f91015ca..0ffb43e3 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisSessionRepository.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisSessionRepository.java @@ -85,6 +85,19 @@ public class ReactiveRedisSessionRepository this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + /** * Set the save mode. * @param saveMode the save mode diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java index 3c03beb0..6456811d 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java @@ -379,6 +379,19 @@ public class RedisIndexedSessionRepository this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + /** * Set the {@link IndexResolver} to use. * @param indexResolver the index resolver diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastIndexedSessionRepository.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastIndexedSessionRepository.java index 851197d3..d9be431b 100644 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastIndexedSessionRepository.java +++ b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastIndexedSessionRepository.java @@ -194,6 +194,19 @@ public class HazelcastIndexedSessionRepository this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setDefaultMaxInactiveInterval(Integer defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + /** * Set the {@link IndexResolver} to use. * @param indexResolver the index resolver diff --git a/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java b/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java index 3a2e929e..1d12c160 100644 --- a/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java +++ b/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcIndexedSessionRepository.java @@ -390,6 +390,19 @@ public class JdbcIndexedSessionRepository implements this.defaultMaxInactiveInterval = defaultMaxInactiveInterval; } + /** + * Set the maximum inactive interval in seconds between requests before newly created + * sessions will be invalidated. A negative time indicates that the session will never + * time out. The default is 1800 (30 minutes). + * @param defaultMaxInactiveInterval the default maxInactiveInterval in seconds + * @deprecated since 3.0.0, in favor of + * {@link #setDefaultMaxInactiveInterval(Duration)} + */ + @Deprecated(since = "3.0.0") + public void setDefaultMaxInactiveInterval(Integer defaultMaxInactiveInterval) { + setDefaultMaxInactiveInterval(Duration.ofSeconds(defaultMaxInactiveInterval)); + } + /** * Set the {@link IndexResolver} to use. * @param indexResolver the index resolver