From 201086326cc1a643e383319b7671194096055a68 Mon Sep 17 00:00:00 2001 From: Zdenek Jonas Date: Tue, 29 Oct 2024 19:21:19 +0100 Subject: [PATCH 1/6] add custom initializer and remove some deprecated staff --- .../CustomStorageInitializerImpl.java | 38 ++++++++++++ .../boot/types/EclipseStoreSpringBoot.java | 5 +- .../EmbeddedStorageFoundationFactory.java | 15 ++++- .../legacy/EclipseStoreProviderImpl.java | 61 ------------------- .../CustomStorageInitializer.java | 20 ++++++ 5 files changed, 75 insertions(+), 64 deletions(-) create mode 100644 examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java delete mode 100644 integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java create mode 100644 integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java diff --git a/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java b/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java new file mode 100644 index 00000000..ddc97d43 --- /dev/null +++ b/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java @@ -0,0 +1,38 @@ +package org.microstream.spring.boot.example.simple.initializer; + +/*- + * #%L + * EclipseStore Integrations SpringBoot + * %% + * Copyright (C) 2023 - 2024 MicroStream Software + * %% + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * #L% + */ + +import org.eclipse.serializer.reference.Lazy; +import org.eclipse.serializer.reference.LazyReferenceManager; +import org.eclipse.store.integrations.spring.boot.types.initializers.CustomStorageInitializer; +import org.springframework.stereotype.Component; + +/** + * This class is for demonstration purposes only. It shows how to execute code before storage is initialized. + * ... + */ +@Component +public class CustomStorageInitializerImpl implements CustomStorageInitializer +{ + @Override + public void initialize() + { + LazyReferenceManager.set(LazyReferenceManager.New( + Lazy.Checker( + 1_000_000, // timeout of lazy access + 0.75 // memory quota + ))); + } +} diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java index 7a922834..be3a72ce 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java @@ -68,10 +68,11 @@ public ClassLoaderProvider classLoaderProvider(ApplicationContext applicationCon @Bean public EmbeddedStorageFoundationFactory embeddedStorageFoundationFactory( EclipseStoreConfigConverter eclipseStoreConfigConverter, - ClassLoaderProvider classLoaderProvider + ClassLoaderProvider classLoaderProvider, + ApplicationContext applicationContext ) { - return new EmbeddedStorageFoundationFactory(eclipseStoreConfigConverter, classLoaderProvider); + return new EmbeddedStorageFoundationFactory(eclipseStoreConfigConverter, classLoaderProvider, applicationContext); } /** diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java index 08ff159e..abfebf67 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java @@ -21,9 +21,12 @@ import org.eclipse.store.integrations.spring.boot.types.configuration.ConfigurationPair; import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; import org.eclipse.store.integrations.spring.boot.types.converter.EclipseStoreConfigConverter; +import org.eclipse.store.integrations.spring.boot.types.initializers.CustomStorageInitializer; import org.eclipse.store.storage.embedded.configuration.types.EmbeddedStorageConfigurationBuilder; import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; import org.slf4j.Logger; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.context.ApplicationContext; import java.util.Map; @@ -38,13 +41,15 @@ public class EmbeddedStorageFoundationFactory { private final EclipseStoreConfigConverter converter; private final ClassLoaderProvider classLoaderProvider; + private final ApplicationContext applicationContext; private final Logger logger = Logging.getLogger(EmbeddedStorageFoundationFactory.class); - public EmbeddedStorageFoundationFactory(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider) + public EmbeddedStorageFoundationFactory(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider, final ApplicationContext context) { this.converter = converter; this.classLoaderProvider = classLoaderProvider; + this.applicationContext = context; } /** @@ -56,6 +61,14 @@ public EmbeddedStorageFoundationFactory(final EclipseStoreConfigConverter conver */ public EmbeddedStorageFoundation createStorageFoundation(final EclipseStoreProperties eclipseStoreProperties, final ConfigurationPair... additionalConfiguration) { + // Call custom code if available + try { + CustomStorageInitializer customInitializer = applicationContext.getBean(CustomStorageInitializer.class); + customInitializer.initialize(); + } catch (NoSuchBeanDefinitionException e) { + this.logger.debug("No custom initializer found."); + } + final EmbeddedStorageConfigurationBuilder builder = EmbeddedStorageConfigurationBuilder.New(); final Map valueMap = this.converter.convertConfigurationToMap(eclipseStoreProperties); for (final ConfigurationPair pair : additionalConfiguration) diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java deleted file mode 100644 index 5374e99d..00000000 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.eclipse.store.integrations.spring.boot.types.factories.legacy; - -/*- - * #%L - * spring-boot3 - * %% - * Copyright (C) 2023 MicroStream Software - * %% - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * #L% - */ - -import org.eclipse.serializer.reflect.ClassLoaderProvider; -import org.eclipse.store.integrations.spring.boot.types.EclipseStoreProvider; -import org.eclipse.store.integrations.spring.boot.types.configuration.ConfigurationPair; -import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; -import org.eclipse.store.integrations.spring.boot.types.converter.EclipseStoreConfigConverter; -import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; -import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageManagerFactory; -import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; -import org.eclipse.store.storage.embedded.types.EmbeddedStorageManager; - - -@SuppressWarnings("removal") -@Deprecated -public class EclipseStoreProviderImpl implements EclipseStoreProvider -{ - - private final EmbeddedStorageFoundationFactory embeddedStorageFoundationFactory; - private final EmbeddedStorageManagerFactory embeddedStorageManagerFactory; - - public EclipseStoreProviderImpl(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider) - { - this.embeddedStorageFoundationFactory = new EmbeddedStorageFoundationFactory(converter, classLoaderProvider); - this.embeddedStorageManagerFactory = new EmbeddedStorageManagerFactory(); - } - - @Override - public EmbeddedStorageManager createStorage(final EclipseStoreProperties eclipseStoreProperties, final ConfigurationPair... additionalConfiguration) - { - final EmbeddedStorageFoundation storageFoundation = this.createStorageFoundation(eclipseStoreProperties, additionalConfiguration); - return this.createStorage(storageFoundation, eclipseStoreProperties.isAutoStart()); - } - - @Override - public EmbeddedStorageManager createStorage(final EmbeddedStorageFoundation foundation, final boolean autoStart) - { - return embeddedStorageManagerFactory.createStorage(foundation, autoStart); - } - - @Override - public EmbeddedStorageFoundation createStorageFoundation(final EclipseStoreProperties eclipseStoreProperties, final ConfigurationPair... additionalConfiguration) - { - return this.embeddedStorageFoundationFactory.createStorageFoundation(eclipseStoreProperties, additionalConfiguration); - } - -} diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java new file mode 100644 index 00000000..d1185c5c --- /dev/null +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java @@ -0,0 +1,20 @@ +package org.eclipse.store.integrations.spring.boot.types.initializers; + +/*- + * #%L + * EclipseStore Integrations SpringBoot + * %% + * Copyright (C) 2023 - 2024 MicroStream Software + * %% + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * #L% + */ + +public interface CustomStorageInitializer +{ + void initialize(); +} From e0397f9bb61b8d8f0074040b472eadb0d0d70ba5 Mon Sep 17 00:00:00 2001 From: Zdenek Jonas Date: Tue, 29 Oct 2024 20:15:31 +0100 Subject: [PATCH 2/6] use spring aware and leave deprecated stuff --- .../boot/types/EclipseStoreSpringBoot.java | 2 +- .../EmbeddedStorageFoundationFactory.java | 15 +++-- .../legacy/EclipseStoreProviderImpl.java | 61 +++++++++++++++++++ 3 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java index be3a72ce..ba8bfb38 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java @@ -72,7 +72,7 @@ public EmbeddedStorageFoundationFactory embeddedStorageFoundationFactory( ApplicationContext applicationContext ) { - return new EmbeddedStorageFoundationFactory(eclipseStoreConfigConverter, classLoaderProvider, applicationContext); + return new EmbeddedStorageFoundationFactory(eclipseStoreConfigConverter, classLoaderProvider); } /** diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java index abfebf67..93008906 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java @@ -25,8 +25,10 @@ import org.eclipse.store.storage.embedded.configuration.types.EmbeddedStorageConfigurationBuilder; import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; import org.slf4j.Logger; +import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import java.util.Map; @@ -37,21 +39,21 @@ * * @since 1.2.0 */ -public class EmbeddedStorageFoundationFactory +public class EmbeddedStorageFoundationFactory implements ApplicationContextAware { private final EclipseStoreConfigConverter converter; private final ClassLoaderProvider classLoaderProvider; - private final ApplicationContext applicationContext; + private ApplicationContext applicationContext; private final Logger logger = Logging.getLogger(EmbeddedStorageFoundationFactory.class); - public EmbeddedStorageFoundationFactory(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider, final ApplicationContext context) + public EmbeddedStorageFoundationFactory(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider) { this.converter = converter; this.classLoaderProvider = classLoaderProvider; - this.applicationContext = context; } + /** * Creates an {@code EmbeddedStorageFoundation} using the provided configuration. This method should be called when the additional configuration for the foundation is required. * @@ -129,4 +131,9 @@ protected Object createNewRootInstance(final EclipseStoreProperties properties) } } + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + this.applicationContext = applicationContext; + } } diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java new file mode 100644 index 00000000..5374e99d --- /dev/null +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/legacy/EclipseStoreProviderImpl.java @@ -0,0 +1,61 @@ +package org.eclipse.store.integrations.spring.boot.types.factories.legacy; + +/*- + * #%L + * spring-boot3 + * %% + * Copyright (C) 2023 MicroStream Software + * %% + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * #L% + */ + +import org.eclipse.serializer.reflect.ClassLoaderProvider; +import org.eclipse.store.integrations.spring.boot.types.EclipseStoreProvider; +import org.eclipse.store.integrations.spring.boot.types.configuration.ConfigurationPair; +import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; +import org.eclipse.store.integrations.spring.boot.types.converter.EclipseStoreConfigConverter; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageFoundationFactory; +import org.eclipse.store.integrations.spring.boot.types.factories.EmbeddedStorageManagerFactory; +import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; +import org.eclipse.store.storage.embedded.types.EmbeddedStorageManager; + + +@SuppressWarnings("removal") +@Deprecated +public class EclipseStoreProviderImpl implements EclipseStoreProvider +{ + + private final EmbeddedStorageFoundationFactory embeddedStorageFoundationFactory; + private final EmbeddedStorageManagerFactory embeddedStorageManagerFactory; + + public EclipseStoreProviderImpl(final EclipseStoreConfigConverter converter, final ClassLoaderProvider classLoaderProvider) + { + this.embeddedStorageFoundationFactory = new EmbeddedStorageFoundationFactory(converter, classLoaderProvider); + this.embeddedStorageManagerFactory = new EmbeddedStorageManagerFactory(); + } + + @Override + public EmbeddedStorageManager createStorage(final EclipseStoreProperties eclipseStoreProperties, final ConfigurationPair... additionalConfiguration) + { + final EmbeddedStorageFoundation storageFoundation = this.createStorageFoundation(eclipseStoreProperties, additionalConfiguration); + return this.createStorage(storageFoundation, eclipseStoreProperties.isAutoStart()); + } + + @Override + public EmbeddedStorageManager createStorage(final EmbeddedStorageFoundation foundation, final boolean autoStart) + { + return embeddedStorageManagerFactory.createStorage(foundation, autoStart); + } + + @Override + public EmbeddedStorageFoundation createStorageFoundation(final EclipseStoreProperties eclipseStoreProperties, final ConfigurationPair... additionalConfiguration) + { + return this.embeddedStorageFoundationFactory.createStorageFoundation(eclipseStoreProperties, additionalConfiguration); + } + +} From 278dd91764249d2183a3a7c6985d503188a63ec0 Mon Sep 17 00:00:00 2001 From: Zdenek Jonas Date: Wed, 30 Oct 2024 10:03:26 +0100 Subject: [PATCH 3/6] small improvements --- .../spring/boot/types/EclipseStoreSpringBoot.java | 3 +-- .../factories/EmbeddedStorageFoundationFactory.java | 2 +- .../types/initializers/CustomStorageInitializer.java | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java index ba8bfb38..7a922834 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/EclipseStoreSpringBoot.java @@ -68,8 +68,7 @@ public ClassLoaderProvider classLoaderProvider(ApplicationContext applicationCon @Bean public EmbeddedStorageFoundationFactory embeddedStorageFoundationFactory( EclipseStoreConfigConverter eclipseStoreConfigConverter, - ClassLoaderProvider classLoaderProvider, - ApplicationContext applicationContext + ClassLoaderProvider classLoaderProvider ) { return new EmbeddedStorageFoundationFactory(eclipseStoreConfigConverter, classLoaderProvider); diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java index 93008906..561d6409 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java @@ -68,7 +68,7 @@ public EmbeddedStorageFoundation createStorageFoundation(final EclipseStorePr CustomStorageInitializer customInitializer = applicationContext.getBean(CustomStorageInitializer.class); customInitializer.initialize(); } catch (NoSuchBeanDefinitionException e) { - this.logger.debug("No custom initializer found."); + this.logger.debug("No custom storage initializer found."); } final EmbeddedStorageConfigurationBuilder builder = EmbeddedStorageConfigurationBuilder.New(); diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java index d1185c5c..07e04e4c 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java @@ -14,7 +14,16 @@ * #L% */ +/** + * Interface for custom storage initializers. + * Implementations of this interface can provide custom initialization logic + * that will be executed before the creation of the storage foundation. + */ public interface CustomStorageInitializer { + /** + * Method to be implemented with custom initialization logic. + * This method will be called immediately before the storage foundation creation process. + */ void initialize(); } From d00f8cf4e51143d46f338984ea27de3ea6eae319 Mon Sep 17 00:00:00 2001 From: Zdenek Jonas Date: Wed, 30 Oct 2024 11:15:40 +0100 Subject: [PATCH 4/6] add code configuration docu --- .../misc/pages/integrations/spring-boot.adoc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/modules/misc/pages/integrations/spring-boot.adoc b/docs/modules/misc/pages/integrations/spring-boot.adoc index e37bf8f3..21d28cf0 100644 --- a/docs/modules/misc/pages/integrations/spring-boot.adoc +++ b/docs/modules/misc/pages/integrations/spring-boot.adoc @@ -288,3 +288,26 @@ and click connect. If you are using Spring Dev Tools, it is recommended to exclude the {product-name} classes from the classpath. Spring Dev Tools use their own restart classloader, which dynamically reloads classes. This can cause issues with the {product-name} classes, as they are not designed to be reloaded on the fly. Spring documentation: https://docs.spring.io/spring-boot/reference/using/devtools.html + +== Code Configuration Before Storage Creation + +There are some use cases where it is necessary to configure storage before it is created. For this purpose, you can use the `CustomStorageInitializer` to create a custom storage configuration in your application. + +Example for configuring `LazyReferenceManager`: + +[source,java] +---- +@Component +public class CustomStorageInitializerImpl implements CustomStorageInitializer +{ + @Override + public void initialize() + { + LazyReferenceManager.set(LazyReferenceManager.New( + Lazy.Checker( + 1_000_000, // timeout of lazy access + 0.75 // memory quota + ))); + } +} +---- From e96f277c17b8d229554a0299abad3fd4d7732197 Mon Sep 17 00:00:00 2001 From: Zdenek Jonas Date: Mon, 4 Nov 2024 15:07:21 +0100 Subject: [PATCH 5/6] change naming --- docs/modules/misc/pages/integrations/spring-boot.adoc | 2 +- ...tializerImpl.java => StorageContextInitializerImpl.java} | 6 +++--- .../types/factories/EmbeddedStorageFoundationFactory.java | 6 +++--- ...orageInitializer.java => StorageContextInitializer.java} | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/{CustomStorageInitializerImpl.java => StorageContextInitializerImpl.java} (85%) rename integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/{CustomStorageInitializer.java => StorageContextInitializer.java} (89%) diff --git a/docs/modules/misc/pages/integrations/spring-boot.adoc b/docs/modules/misc/pages/integrations/spring-boot.adoc index 21d28cf0..bc7258af 100644 --- a/docs/modules/misc/pages/integrations/spring-boot.adoc +++ b/docs/modules/misc/pages/integrations/spring-boot.adoc @@ -291,7 +291,7 @@ Spring documentation: https://docs.spring.io/spring-boot/reference/using/devtool == Code Configuration Before Storage Creation -There are some use cases where it is necessary to configure storage before it is created. For this purpose, you can use the `CustomStorageInitializer` to create a custom storage configuration in your application. +There are some use cases where it is necessary to configure storage before it is created. For this purpose, you can use the `StorageContextInitializer` to create a custom storage configuration in your application. Example for configuring `LazyReferenceManager`: diff --git a/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java b/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/StorageContextInitializerImpl.java similarity index 85% rename from examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java rename to examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/StorageContextInitializerImpl.java index ddc97d43..5d5f1159 100644 --- a/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/CustomStorageInitializerImpl.java +++ b/examples/spring-boot3-simple/src/main/java/org/microstream/spring/boot/example/simple/initializer/StorageContextInitializerImpl.java @@ -16,7 +16,7 @@ import org.eclipse.serializer.reference.Lazy; import org.eclipse.serializer.reference.LazyReferenceManager; -import org.eclipse.store.integrations.spring.boot.types.initializers.CustomStorageInitializer; +import org.eclipse.store.integrations.spring.boot.types.initializers.StorageContextInitializer; import org.springframework.stereotype.Component; /** @@ -24,7 +24,7 @@ * ... */ @Component -public class CustomStorageInitializerImpl implements CustomStorageInitializer +public class StorageContextInitializerImpl implements StorageContextInitializer { @Override public void initialize() @@ -32,7 +32,7 @@ public void initialize() LazyReferenceManager.set(LazyReferenceManager.New( Lazy.Checker( 1_000_000, // timeout of lazy access - 0.75 // memory quota + 0.75 // memory quota ))); } } diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java index 561d6409..6a9272c6 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/factories/EmbeddedStorageFoundationFactory.java @@ -21,7 +21,7 @@ import org.eclipse.store.integrations.spring.boot.types.configuration.ConfigurationPair; import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties; import org.eclipse.store.integrations.spring.boot.types.converter.EclipseStoreConfigConverter; -import org.eclipse.store.integrations.spring.boot.types.initializers.CustomStorageInitializer; +import org.eclipse.store.integrations.spring.boot.types.initializers.StorageContextInitializer; import org.eclipse.store.storage.embedded.configuration.types.EmbeddedStorageConfigurationBuilder; import org.eclipse.store.storage.embedded.types.EmbeddedStorageFoundation; import org.slf4j.Logger; @@ -65,8 +65,8 @@ public EmbeddedStorageFoundation createStorageFoundation(final EclipseStorePr { // Call custom code if available try { - CustomStorageInitializer customInitializer = applicationContext.getBean(CustomStorageInitializer.class); - customInitializer.initialize(); + StorageContextInitializer storageContextInitializer = applicationContext.getBean(StorageContextInitializer.class); + storageContextInitializer.initialize(); } catch (NoSuchBeanDefinitionException e) { this.logger.debug("No custom storage initializer found."); } diff --git a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/StorageContextInitializer.java similarity index 89% rename from integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java rename to integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/StorageContextInitializer.java index 07e04e4c..9682fb15 100644 --- a/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/CustomStorageInitializer.java +++ b/integrations/spring-boot3/src/main/java/org/eclipse/store/integrations/spring/boot/types/initializers/StorageContextInitializer.java @@ -15,11 +15,11 @@ */ /** - * Interface for custom storage initializers. + * Interface for storage context initializers. * Implementations of this interface can provide custom initialization logic * that will be executed before the creation of the storage foundation. */ -public interface CustomStorageInitializer +public interface StorageContextInitializer { /** * Method to be implemented with custom initialization logic. From c26dcea97dfd9156f298feaed9870586b6328928 Mon Sep 17 00:00:00 2001 From: Florian Habermann Date: Mon, 4 Nov 2024 15:46:33 +0100 Subject: [PATCH 6/6] Update spring-boot.adoc (#327) --- docs/modules/misc/pages/integrations/spring-boot.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/modules/misc/pages/integrations/spring-boot.adoc b/docs/modules/misc/pages/integrations/spring-boot.adoc index bc7258af..5f708d38 100644 --- a/docs/modules/misc/pages/integrations/spring-boot.adoc +++ b/docs/modules/misc/pages/integrations/spring-boot.adoc @@ -291,14 +291,14 @@ Spring documentation: https://docs.spring.io/spring-boot/reference/using/devtool == Code Configuration Before Storage Creation -There are some use cases where it is necessary to configure storage before it is created. For this purpose, you can use the `StorageContextInitializer` to create a custom storage configuration in your application. +There are some use cases where it is necessary to configure the storage's context before it is created. For this purpose, you can use the `StorageContextInitializer` to create a custom storage configuration in your application. Example for configuring `LazyReferenceManager`: [source,java] ---- @Component -public class CustomStorageInitializerImpl implements CustomStorageInitializer +public class StorageContextInitializerImpl implements StorageContextInitializer { @Override public void initialize()