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); + } + +}