From 8d6d62585025fb12dc5f640f7eabc89295ac15ab Mon Sep 17 00:00:00 2001 From: "denis256.dev-desktop" Date: Wed, 17 Apr 2024 22:05:12 +0100 Subject: [PATCH] Updated factory --- .../polydata4/factory/FlatFileJsonFactory.java | 2 +- .../polydata4/factory/FlatFileYamlFactory.java | 2 +- .../com/unidev/polydata4/factory/MongodbFactory.java | 2 +- .../com/unidev/polydata4/factory/RedisFactory.java | 2 +- .../com/unidev/polydata4/factory/SQLiteFactory.java | 2 +- .../com/unidev/polydata4/factory/StorageFactory.java | 12 +++++++----- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileJsonFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileJsonFactory.java index fcc6684..1aee7ad 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileJsonFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileJsonFactory.java @@ -9,7 +9,7 @@ import java.util.Optional; @Slf4j -public class FlatFileJsonFactory implements StorageFactory { +public class FlatFileJsonFactory extends StorageFactory { @Override public String type() { return "flat-file-json"; diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileYamlFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileYamlFactory.java index 61e271f..564a966 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileYamlFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/FlatFileYamlFactory.java @@ -9,7 +9,7 @@ import java.util.Optional; @Slf4j -public class FlatFileYamlFactory implements StorageFactory { +public class FlatFileYamlFactory extends StorageFactory { @Override public String type() { return "flat-file-yaml"; diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/MongodbFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/MongodbFactory.java index e7c328f..27165cf 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/MongodbFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/MongodbFactory.java @@ -8,7 +8,7 @@ import java.util.Optional; @Slf4j -public class MongodbFactory implements StorageFactory { +public class MongodbFactory extends StorageFactory { @Override public String type() { diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/RedisFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/RedisFactory.java index 3405991..656101f 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/RedisFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/RedisFactory.java @@ -13,7 +13,7 @@ import java.util.Optional; @Slf4j -public class RedisFactory implements StorageFactory { +public class RedisFactory extends StorageFactory { @Override public String type() { diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/SQLiteFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/SQLiteFactory.java index 82ea49e..1d7e905 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/SQLiteFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/SQLiteFactory.java @@ -10,7 +10,7 @@ import java.util.Optional; @Slf4j -public class SQLiteFactory implements StorageFactory { +public class SQLiteFactory extends StorageFactory { @Override public String type() { return "sqlite"; diff --git a/polydata-factory/src/main/java/com/unidev/polydata4/factory/StorageFactory.java b/polydata-factory/src/main/java/com/unidev/polydata4/factory/StorageFactory.java index 545f9f1..2661c8a 100644 --- a/polydata-factory/src/main/java/com/unidev/polydata4/factory/StorageFactory.java +++ b/polydata-factory/src/main/java/com/unidev/polydata4/factory/StorageFactory.java @@ -2,6 +2,7 @@ import com.unidev.polydata4.api.Polydata; import com.unidev.polydata4.domain.BasicPoly; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import javax.cache.Cache; @@ -17,7 +18,8 @@ /** * Interface for storage factories */ -public interface StorageFactory { +@Slf4j +public abstract class StorageFactory { static Optional> fetchJCacheConfig(BasicPoly config) { MutableConfiguration jcacheConfig = new MutableConfiguration<>(); @@ -28,12 +30,12 @@ static Optional> fetchJCacheConfig(Basic /** * Fetch cache provider from configuration */ - default Optional> fetchCache(BasicPoly config) { + public Optional> fetchCache(BasicPoly config) { if (config == null) { return Optional.empty(); } String cacheType = config.fetch("type", ""); - + log.info("Fetching cache for type {}", cacheType); if (cacheType.equals("jcache")) { String cacheProvider = config.fetch("provider", ""); String cacheName = config.fetch("name", ""); @@ -88,12 +90,12 @@ default Optional> fetchCache(BasicPoly config) { /** * Return supported storage type. */ - String type(); + public abstract String type(); /** * Create polydata from configuration. */ - Optional create(BasicPoly config); + public abstract Optional create(BasicPoly config); }