Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logging of cache type #38

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Optional;

@Slf4j
public class MongodbFactory implements StorageFactory {
public class MongodbFactory extends StorageFactory {

@Override
public String type() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Optional;

@Slf4j
public class RedisFactory implements StorageFactory {
public class RedisFactory extends StorageFactory {

@Override
public String type() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +18,8 @@
/**
* Interface for storage factories
*/
public interface StorageFactory {
@Slf4j
public abstract class StorageFactory {

static Optional<MutableConfiguration<String, BasicPoly>> fetchJCacheConfig(BasicPoly config) {
MutableConfiguration<String, BasicPoly> jcacheConfig = new MutableConfiguration<>();
Expand All @@ -28,12 +30,12 @@ static Optional<MutableConfiguration<String, BasicPoly>> fetchJCacheConfig(Basic
/**
* Fetch cache provider from configuration
*/
default Optional<Cache<String, BasicPoly>> fetchCache(BasicPoly config) {
public Optional<Cache<String, BasicPoly>> 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", "");
Expand Down Expand Up @@ -88,12 +90,12 @@ default Optional<Cache<String, BasicPoly>> fetchCache(BasicPoly config) {
/**
* Return supported storage type.
*/
String type();
public abstract String type();

/**
* Create polydata from configuration.
*/
Optional<Polydata> create(BasicPoly config);
public abstract Optional<Polydata> create(BasicPoly config);


}