diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastFlushMode.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastFlushMode.java deleted file mode 100644 index eddd843c..00000000 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastFlushMode.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.session.hazelcast; - -import org.springframework.session.FlushMode; -import org.springframework.session.SessionRepository; - -/** - * Specifies when to write to the backing Hazelcast instance. - * - * @author Aleksandar Stojsavljevic - * @since 1.3.0 - * @deprecated since 2.2.0 in favor of {@link FlushMode} - */ -@Deprecated -public enum HazelcastFlushMode { - - /** - * Only writes to Hazelcast when - * {@link SessionRepository#save(org.springframework.session.Session)} is invoked. In - * a web environment this is typically done as soon as the HTTP response is committed. - */ - ON_SAVE(FlushMode.ON_SAVE), - - /** - * Writes to Hazelcast as soon as possible. For example - * {@link SessionRepository#createSession()} will write the session to Hazelcast. - * Another example is that setting an attribute on the session will also write to - * Hazelcast immediately. - */ - IMMEDIATE(FlushMode.IMMEDIATE); - - private final FlushMode flushMode; - - HazelcastFlushMode(FlushMode flushMode) { - this.flushMode = flushMode; - } - - public FlushMode getFlushMode() { - return this.flushMode; - } - -} diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java deleted file mode 100644 index 25809b7a..00000000 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2014-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.session.hazelcast; - -import com.hazelcast.core.HazelcastInstance; - -import org.springframework.session.FlushMode; -import org.springframework.session.SessionRepository; -import org.springframework.util.Assert; - -/** - * This {@link SessionRepository} implementation is kept in order to support migration to - * {@link HazelcastIndexedSessionRepository} in a backwards compatible manner. - * - * @author Vedran Pavic - * @author Tommy Ludwig - * @author Mark Anderson - * @author Aleksandar Stojsavljevic - * @since 1.3.0 - * @deprecated since 2.2.0 in favor of {@link HazelcastIndexedSessionRepository} - */ -@Deprecated -public class HazelcastSessionRepository extends HazelcastIndexedSessionRepository { - - /** - * Create a new {@link HazelcastSessionRepository} instance. - * @param hazelcastInstance the {@link HazelcastInstance} to use for managing sessions - * @see HazelcastIndexedSessionRepository#HazelcastIndexedSessionRepository(HazelcastInstance) - */ - public HazelcastSessionRepository(HazelcastInstance hazelcastInstance) { - super(hazelcastInstance); - } - - /** - * Sets the Hazelcast flush mode. Default flush mode is - * {@link HazelcastFlushMode#ON_SAVE}. - * @param hazelcastFlushMode the new Hazelcast flush mode - * @deprecated since 2.2.0 in favor of {@link #setFlushMode(FlushMode)} - */ - @Deprecated - public void setHazelcastFlushMode(HazelcastFlushMode hazelcastFlushMode) { - Assert.notNull(hazelcastFlushMode, "HazelcastFlushMode cannot be null"); - setFlushMode(hazelcastFlushMode.getFlushMode()); - } - -} diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSession.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSession.java index 77eedf29..9820ffb7 100644 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSession.java +++ b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,6 @@ import org.springframework.session.SaveMode; import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession; -import org.springframework.session.hazelcast.HazelcastFlushMode; import org.springframework.session.web.http.SessionRepositoryFilter; /** @@ -85,21 +84,6 @@ public @interface EnableHazelcastHttpSession { */ String sessionMapName() default "spring:session:sessions"; - /** - * Flush mode for the Hazelcast sessions. The default is {@code ON_SAVE} which only - * updates the backing Hazelcast when {@link SessionRepository#save(Session)} is - * invoked. In a web environment this happens just before the HTTP response is - * committed. - *

- * Setting the value to {@code IMMEDIATE} will ensure that the any updates to the - * Session are immediately written to the Hazelcast instance. - * @return the {@link HazelcastFlushMode} to use - * @since 1.3.0 - * @deprecated since 2.2.0 in favor of {@link #flushMode()} - */ - @Deprecated - HazelcastFlushMode hazelcastFlushMode() default HazelcastFlushMode.ON_SAVE; - /** * Flush mode for the Hazelcast sessions. The default is {@code ON_SAVE} which only * updates the backing Hazelcast when {@link SessionRepository#save(Session)} is diff --git a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfiguration.java b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfiguration.java index 2fc75598..4c5bf954 100644 --- a/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfiguration.java +++ b/spring-session-hazelcast/src/main/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,6 @@ import org.springframework.session.SaveMode; import org.springframework.session.Session; import org.springframework.session.config.SessionRepositoryCustomizer; import org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration; -import org.springframework.session.hazelcast.HazelcastFlushMode; import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; import org.springframework.session.hazelcast.config.annotation.SpringSessionHazelcastInstance; import org.springframework.session.web.http.SessionRepositoryFilter; @@ -86,11 +85,6 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur this.sessionMapName = sessionMapName; } - @Deprecated - public void setHazelcastFlushMode(HazelcastFlushMode hazelcastFlushMode) { - setFlushMode(hazelcastFlushMode.getFlushMode()); - } - public void setFlushMode(FlushMode flushMode) { this.flushMode = flushMode; } @@ -127,7 +121,6 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur } @Override - @SuppressWarnings("deprecation") public void setImportMetadata(AnnotationMetadata importMetadata) { Map attributeMap = importMetadata .getAnnotationAttributes(EnableHazelcastHttpSession.class.getName()); @@ -137,12 +130,7 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur if (StringUtils.hasText(sessionMapNameValue)) { this.sessionMapName = sessionMapNameValue; } - FlushMode flushMode = attributes.getEnum("flushMode"); - HazelcastFlushMode hazelcastFlushMode = attributes.getEnum("hazelcastFlushMode"); - if (flushMode == FlushMode.ON_SAVE && hazelcastFlushMode != HazelcastFlushMode.ON_SAVE) { - flushMode = hazelcastFlushMode.getFlushMode(); - } - this.flushMode = flushMode; + this.flushMode = attributes.getEnum("flushMode"); this.saveMode = attributes.getEnum("saveMode"); } diff --git a/spring-session-hazelcast/src/test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationTests.java b/spring-session-hazelcast/src/test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationTests.java index 96fc1803..09cc7483 100644 --- a/spring-session-hazelcast/src/test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationTests.java +++ b/spring-session-hazelcast/src/test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationTests.java @@ -34,7 +34,6 @@ import org.springframework.session.IndexResolver; import org.springframework.session.SaveMode; import org.springframework.session.Session; import org.springframework.session.config.SessionRepositoryCustomizer; -import org.springframework.session.hazelcast.HazelcastFlushMode; import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; import org.springframework.session.hazelcast.config.annotation.SpringSessionHazelcastInstance; import org.springframework.test.util.ReflectionTestUtils; @@ -130,15 +129,6 @@ class HazelcastHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(repository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void customFlushImmediatelyLegacy() { - registerAndRefresh(CustomFlushImmediatelyLegacyConfiguration.class); - - HazelcastIndexedSessionRepository repository = this.context.getBean(HazelcastIndexedSessionRepository.class); - assertThat(repository).isNotNull(); - assertThat(ReflectionTestUtils.getField(repository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void setCustomFlushImmediately() { registerAndRefresh(BaseConfiguration.class, CustomFlushImmediatelySetConfiguration.class); @@ -148,15 +138,6 @@ class HazelcastHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(repository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void setCustomFlushImmediatelyLegacy() { - registerAndRefresh(BaseConfiguration.class, CustomFlushImmediatelySetLegacyConfiguration.class); - - HazelcastIndexedSessionRepository repository = this.context.getBean(HazelcastIndexedSessionRepository.class); - assertThat(repository).isNotNull(); - assertThat(ReflectionTestUtils.getField(repository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void customSaveModeAnnotation() { registerAndRefresh(BaseConfiguration.class, CustomSaveModeExpressionAnnotationConfiguration.class); @@ -319,16 +300,6 @@ class HazelcastHttpSessionConfigurationTests { } - @Configuration - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelySetLegacyConfiguration extends HazelcastHttpSessionConfiguration { - - CustomFlushImmediatelySetLegacyConfiguration() { - setHazelcastFlushMode(HazelcastFlushMode.IMMEDIATE); - } - - } - @EnableHazelcastHttpSession(saveMode = SaveMode.ALWAYS) static class CustomSaveModeExpressionAnnotationConfiguration { @@ -349,13 +320,6 @@ class HazelcastHttpSessionConfigurationTests { } - @Configuration - @EnableHazelcastHttpSession(hazelcastFlushMode = HazelcastFlushMode.IMMEDIATE) - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelyLegacyConfiguration extends BaseConfiguration { - - } - @Configuration @EnableHazelcastHttpSession static class QualifiedHazelcastInstanceConfiguration extends BaseConfiguration {