From 6e336bb879f07bc1a617e3139e54c72cb764c1eb Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Apr 2024 14:20:55 +0100 Subject: [PATCH] wow --- .../java/xyz/mcutils/backend/config/MongoConfig.java | 10 ++++++++++ .../java/xyz/mcutils/backend/config/RedisConfig.java | 2 ++ .../repository/{ => mongo}/MetricsRepository.java | 4 +++- .../{ => redis}/EndpointStatusRepository.java | 4 +++- .../{ => redis}/MinecraftServerCacheRepository.java | 4 +++- .../repository/{ => redis}/PlayerCacheRepository.java | 4 +++- .../{ => redis}/PlayerNameCacheRepository.java | 4 +++- .../{ => redis}/PlayerSkinPartCacheRepository.java | 4 +++- .../xyz/mcutils/backend/service/MetricService.java | 2 +- .../xyz/mcutils/backend/service/MojangService.java | 2 +- .../xyz/mcutils/backend/service/PlayerService.java | 6 +++--- .../xyz/mcutils/backend/service/ServerService.java | 2 +- 12 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 src/main/java/xyz/mcutils/backend/config/MongoConfig.java rename src/main/java/xyz/mcutils/backend/repository/{ => mongo}/MetricsRepository.java (68%) rename src/main/java/xyz/mcutils/backend/repository/{ => redis}/EndpointStatusRepository.java (69%) rename src/main/java/xyz/mcutils/backend/repository/{ => redis}/MinecraftServerCacheRepository.java (70%) rename src/main/java/xyz/mcutils/backend/repository/{ => redis}/PlayerCacheRepository.java (69%) rename src/main/java/xyz/mcutils/backend/repository/{ => redis}/PlayerNameCacheRepository.java (73%) rename src/main/java/xyz/mcutils/backend/repository/{ => redis}/PlayerSkinPartCacheRepository.java (72%) diff --git a/src/main/java/xyz/mcutils/backend/config/MongoConfig.java b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java new file mode 100644 index 0000000..8a93595 --- /dev/null +++ b/src/main/java/xyz/mcutils/backend/config/MongoConfig.java @@ -0,0 +1,10 @@ +package xyz.mcutils.backend.config; + +import lombok.extern.log4j.Log4j2; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +@Configuration +@EnableMongoRepositories(basePackages = "xyz.mcutils.backend.repository.mongo") +public class MongoConfig { +} diff --git a/src/main/java/xyz/mcutils/backend/config/RedisConfig.java b/src/main/java/xyz/mcutils/backend/config/RedisConfig.java index a71fa79..bfbefcb 100644 --- a/src/main/java/xyz/mcutils/backend/config/RedisConfig.java +++ b/src/main/java/xyz/mcutils/backend/config/RedisConfig.java @@ -8,12 +8,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; /** * @author Braydon */ @Configuration @Log4j2(topic = "Redis") +@EnableRedisRepositories(basePackages = "xyz.mcutils.backend.repository.redis") public class RedisConfig { /** * The Redis server host. diff --git a/src/main/java/xyz/mcutils/backend/repository/MetricsRepository.java b/src/main/java/xyz/mcutils/backend/repository/mongo/MetricsRepository.java similarity index 68% rename from src/main/java/xyz/mcutils/backend/repository/MetricsRepository.java rename to src/main/java/xyz/mcutils/backend/repository/mongo/MetricsRepository.java index d9f065d..7b142a0 100644 --- a/src/main/java/xyz/mcutils/backend/repository/MetricsRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/mongo/MetricsRepository.java @@ -1,6 +1,7 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.mongo; import org.springframework.data.mongodb.repository.MongoRepository; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.service.metric.Metric; @@ -9,5 +10,6 @@ import xyz.mcutils.backend.service.metric.Metric; * * @author Braydon */ +@EnableMongoRepositories @Repository public interface MetricsRepository extends MongoRepository, String> { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/repository/EndpointStatusRepository.java b/src/main/java/xyz/mcutils/backend/repository/redis/EndpointStatusRepository.java similarity index 69% rename from src/main/java/xyz/mcutils/backend/repository/EndpointStatusRepository.java rename to src/main/java/xyz/mcutils/backend/repository/redis/EndpointStatusRepository.java index 8293455..57c86e0 100644 --- a/src/main/java/xyz/mcutils/backend/repository/EndpointStatusRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/redis/EndpointStatusRepository.java @@ -1,5 +1,6 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.redis; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.model.cache.CachedEndpointStatus; @@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedEndpointStatus; * * @author Braydon */ +@EnableRedisRepositories @Repository public interface EndpointStatusRepository extends CrudRepository { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/repository/MinecraftServerCacheRepository.java b/src/main/java/xyz/mcutils/backend/repository/redis/MinecraftServerCacheRepository.java similarity index 70% rename from src/main/java/xyz/mcutils/backend/repository/MinecraftServerCacheRepository.java rename to src/main/java/xyz/mcutils/backend/repository/redis/MinecraftServerCacheRepository.java index 074cffa..2eff856 100644 --- a/src/main/java/xyz/mcutils/backend/repository/MinecraftServerCacheRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/redis/MinecraftServerCacheRepository.java @@ -1,5 +1,6 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.redis; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.model.cache.CachedMinecraftServer; @@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedMinecraftServer; * * @author Braydon */ +@EnableRedisRepositories @Repository public interface MinecraftServerCacheRepository extends CrudRepository { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/repository/PlayerCacheRepository.java b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerCacheRepository.java similarity index 69% rename from src/main/java/xyz/mcutils/backend/repository/PlayerCacheRepository.java rename to src/main/java/xyz/mcutils/backend/repository/redis/PlayerCacheRepository.java index 2b44f67..e3a996c 100644 --- a/src/main/java/xyz/mcutils/backend/repository/PlayerCacheRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerCacheRepository.java @@ -1,5 +1,6 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.redis; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.model.cache.CachedPlayer; @@ -11,5 +12,6 @@ import java.util.UUID; * * @author Braydon */ +@EnableRedisRepositories @Repository public interface PlayerCacheRepository extends CrudRepository { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/repository/PlayerNameCacheRepository.java b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerNameCacheRepository.java similarity index 73% rename from src/main/java/xyz/mcutils/backend/repository/PlayerNameCacheRepository.java rename to src/main/java/xyz/mcutils/backend/repository/redis/PlayerNameCacheRepository.java index d2a9399..cf93dcb 100644 --- a/src/main/java/xyz/mcutils/backend/repository/PlayerNameCacheRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerNameCacheRepository.java @@ -1,5 +1,6 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.redis; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.model.cache.CachedPlayerName; @@ -13,5 +14,6 @@ import xyz.mcutils.backend.model.cache.CachedPlayerName; * * @author Braydon */ +@EnableRedisRepositories @Repository public interface PlayerNameCacheRepository extends CrudRepository { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/repository/PlayerSkinPartCacheRepository.java b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerSkinPartCacheRepository.java similarity index 72% rename from src/main/java/xyz/mcutils/backend/repository/PlayerSkinPartCacheRepository.java rename to src/main/java/xyz/mcutils/backend/repository/redis/PlayerSkinPartCacheRepository.java index dcbde91..0efbefa 100644 --- a/src/main/java/xyz/mcutils/backend/repository/PlayerSkinPartCacheRepository.java +++ b/src/main/java/xyz/mcutils/backend/repository/redis/PlayerSkinPartCacheRepository.java @@ -1,5 +1,6 @@ -package xyz.mcutils.backend.repository; +package xyz.mcutils.backend.repository.redis; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart; @@ -11,5 +12,6 @@ import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart; * player skin part by it's id. *

*/ +@EnableRedisRepositories @Repository public interface PlayerSkinPartCacheRepository extends CrudRepository { } \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/backend/service/MetricService.java b/src/main/java/xyz/mcutils/backend/service/MetricService.java index c18cd51..d5c6ed6 100644 --- a/src/main/java/xyz/mcutils/backend/service/MetricService.java +++ b/src/main/java/xyz/mcutils/backend/service/MetricService.java @@ -7,7 +7,7 @@ import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import xyz.mcutils.backend.common.Timer; -import xyz.mcutils.backend.repository.MetricsRepository; +import xyz.mcutils.backend.repository.mongo.MetricsRepository; import xyz.mcutils.backend.service.metric.Metric; import xyz.mcutils.backend.service.metric.metrics.*; import xyz.mcutils.backend.service.metric.metrics.process.CpuUsageMetric; diff --git a/src/main/java/xyz/mcutils/backend/service/MojangService.java b/src/main/java/xyz/mcutils/backend/service/MojangService.java index e2e393e..2acaac5 100644 --- a/src/main/java/xyz/mcutils/backend/service/MojangService.java +++ b/src/main/java/xyz/mcutils/backend/service/MojangService.java @@ -22,7 +22,7 @@ import xyz.mcutils.backend.model.cache.CachedEndpointStatus; import xyz.mcutils.backend.model.mojang.EndpointStatus; import xyz.mcutils.backend.model.token.MojangProfileToken; import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken; -import xyz.mcutils.backend.repository.EndpointStatusRepository; +import xyz.mcutils.backend.repository.redis.EndpointStatusRepository; import java.io.InputStream; import java.net.URL; diff --git a/src/main/java/xyz/mcutils/backend/service/PlayerService.java b/src/main/java/xyz/mcutils/backend/service/PlayerService.java index 4fad2a6..d8b7db5 100644 --- a/src/main/java/xyz/mcutils/backend/service/PlayerService.java +++ b/src/main/java/xyz/mcutils/backend/service/PlayerService.java @@ -21,9 +21,9 @@ import xyz.mcutils.backend.model.skin.ISkinPart; import xyz.mcutils.backend.model.skin.Skin; import xyz.mcutils.backend.model.token.MojangProfileToken; import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken; -import xyz.mcutils.backend.repository.PlayerCacheRepository; -import xyz.mcutils.backend.repository.PlayerNameCacheRepository; -import xyz.mcutils.backend.repository.PlayerSkinPartCacheRepository; +import xyz.mcutils.backend.repository.redis.PlayerCacheRepository; +import xyz.mcutils.backend.repository.redis.PlayerNameCacheRepository; +import xyz.mcutils.backend.repository.redis.PlayerSkinPartCacheRepository; import xyz.mcutils.backend.service.metric.metrics.UniquePlayerLookupsMetric; import java.awt.image.BufferedImage; diff --git a/src/main/java/xyz/mcutils/backend/service/ServerService.java b/src/main/java/xyz/mcutils/backend/service/ServerService.java index e34cba1..2c9e767 100644 --- a/src/main/java/xyz/mcutils/backend/service/ServerService.java +++ b/src/main/java/xyz/mcutils/backend/service/ServerService.java @@ -14,7 +14,7 @@ import xyz.mcutils.backend.model.dns.impl.ARecord; import xyz.mcutils.backend.model.dns.impl.SRVRecord; import xyz.mcutils.backend.model.server.JavaMinecraftServer; import xyz.mcutils.backend.model.server.MinecraftServer; -import xyz.mcutils.backend.repository.MinecraftServerCacheRepository; +import xyz.mcutils.backend.repository.redis.MinecraftServerCacheRepository; import xyz.mcutils.backend.service.metric.metrics.UniqueServerLookupsMetric; import java.net.InetSocketAddress;