Skip to content

Commit 9f42ffb

Browse files
committed
Refactor the modules to be more like Spring Boot ecosystem part, separate properties from core modules to autoconfigure, divide testcontainers module, fix the main properties problem with no showing up at context help
1 parent 6634fd4 commit 9f42ffb

File tree

174 files changed

+1095
-1206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+1095
-1206
lines changed

.idea/compiler.xml

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/condition/AbstractCacheLevelCondition.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/AbstractCacheLevelCondition.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package io.w4t3rcs.python.condition;
1+
package io.w4t3rcs.python.autoconfigure;
22

3-
import io.w4t3rcs.python.config.PythonCacheAutoConfiguration;
4-
import io.w4t3rcs.python.properties.PythonCacheProperties;
53
import org.springframework.context.annotation.Condition;
64
import org.springframework.context.annotation.ConditionContext;
75
import org.springframework.core.env.Environment;

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/condition/ExecutorCacheLevelCondition.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/ExecutorCacheLevelCondition.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package io.w4t3rcs.python.condition;
1+
package io.w4t3rcs.python.autoconfigure;
22

3-
import io.w4t3rcs.python.config.PythonCacheAutoConfiguration;
4-
import io.w4t3rcs.python.properties.PythonCacheProperties;
53
import lombok.AccessLevel;
64
import lombok.Getter;
75

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/condition/FileCacheLevelCondition.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/FileCacheLevelCondition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package io.w4t3rcs.python.condition;
1+
package io.w4t3rcs.python.autoconfigure;
22

3-
import io.w4t3rcs.python.properties.PythonCacheProperties;
43
import lombok.AccessLevel;
54
import lombok.Getter;
65

@@ -16,7 +15,7 @@
1615
*
1716
* @see AbstractCacheLevelCondition
1817
* @see PythonCacheProperties.PythonCacheLevel#FILE
19-
* @see io.w4t3rcs.python.config.PythonCacheAutoConfiguration
18+
* @see PythonCacheAutoConfiguration
2019
* @author w4t3rcs
2120
* @since 1.0.0
2221
*/

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/condition/ProcessorCacheLevelCondition.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/ProcessorCacheLevelCondition.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package io.w4t3rcs.python.condition;
1+
package io.w4t3rcs.python.autoconfigure;
22

3-
import io.w4t3rcs.python.config.PythonCacheAutoConfiguration;
4-
import io.w4t3rcs.python.properties.PythonCacheProperties;
53
import lombok.AccessLevel;
64
import lombok.Getter;
75

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/config/PythonCacheAutoConfiguration.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/PythonCacheAutoConfiguration.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
package io.w4t3rcs.python.config;
1+
package io.w4t3rcs.python.autoconfigure;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import io.w4t3rcs.python.cache.CacheKeyGenerator;
55
import io.w4t3rcs.python.cache.HashCacheKeyGenerator;
6-
import io.w4t3rcs.python.condition.ExecutorCacheLevelCondition;
7-
import io.w4t3rcs.python.condition.FileCacheLevelCondition;
8-
import io.w4t3rcs.python.condition.ProcessorCacheLevelCondition;
9-
import io.w4t3rcs.python.condition.ResolverCacheLevelCondition;
106
import io.w4t3rcs.python.executor.CachingPythonExecutor;
117
import io.w4t3rcs.python.executor.PythonExecutor;
128
import io.w4t3rcs.python.file.CachingPythonFileReader;
139
import io.w4t3rcs.python.file.PythonFileReader;
1410
import io.w4t3rcs.python.processor.CachingPythonProcessor;
1511
import io.w4t3rcs.python.processor.PythonProcessor;
16-
import io.w4t3rcs.python.properties.PythonCacheProperties;
1712
import io.w4t3rcs.python.resolver.CachingPythonResolverHolder;
1813
import io.w4t3rcs.python.resolver.PythonResolverHolder;
14+
import org.springframework.boot.autoconfigure.AutoConfiguration;
1915
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
16+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
2017
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
21-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2218
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2319
import org.springframework.cache.CacheManager;
2420
import org.springframework.cache.annotation.EnableCaching;
25-
import org.springframework.context.annotation.*;
21+
import org.springframework.context.annotation.Bean;
22+
import org.springframework.context.annotation.Conditional;
23+
import org.springframework.context.annotation.Primary;
2624

2725
/**
2826
* Autoconfiguration class for Python caching support.
@@ -57,10 +55,9 @@
5755
* @author w4t3rcs
5856
* @since 1.0.0
5957
*/
60-
@Configuration
58+
@AutoConfiguration
6159
@EnableConfigurationProperties(PythonCacheProperties.class)
62-
@ConditionalOnProperty(name = "spring.python.cache.enabled", havingValue = "true")
63-
@PropertySource("classpath:python-cache-default.properties")
60+
@ConditionalOnBooleanProperty(name = "spring.python.cache.enabled", matchIfMissing = true)
6461
public class PythonCacheAutoConfiguration {
6562
/**
6663
* Creates the default {@link CacheKeyGenerator} bean if none is present.
@@ -72,7 +69,8 @@ public class PythonCacheAutoConfiguration {
7269
@Bean
7370
@ConditionalOnMissingBean(CacheKeyGenerator.class)
7471
public CacheKeyGenerator cacheKeyGenerator(PythonCacheProperties cacheProperties) {
75-
return new HashCacheKeyGenerator(cacheProperties);
72+
var keyProperties = cacheProperties.getKey();
73+
return new HashCacheKeyGenerator(keyProperties.getHashAlgorithm(), keyProperties.getCharset(), keyProperties.getDelimiter());
7674
}
7775

7876
/**
@@ -91,7 +89,8 @@ public CacheKeyGenerator cacheKeyGenerator(PythonCacheProperties cacheProperties
9189
public PythonFileReader cachingPythonFileHandler(PythonCacheProperties cacheProperties,
9290
PythonFileReader pythonFileReader,
9391
CacheManager cacheManager) {
94-
return new CachingPythonFileReader(cacheProperties, pythonFileReader, cacheManager);
92+
var nameProperties = cacheProperties.getName();
93+
return new CachingPythonFileReader(nameProperties.getFileBodies(), nameProperties.getFilePaths(), pythonFileReader, cacheManager);
9594
}
9695

9796
/**
@@ -114,7 +113,8 @@ public PythonResolverHolder cachingPythonResolverHolder(PythonCacheProperties ca
114113
CacheManager cacheManager,
115114
CacheKeyGenerator keyGenerator,
116115
ObjectMapper objectMapper) {
117-
return new CachingPythonResolverHolder(cacheProperties, pythonResolverHolder, cacheManager, keyGenerator, objectMapper);
116+
var nameProperties = cacheProperties.getName();
117+
return new CachingPythonResolverHolder(nameProperties.getResolver(), pythonResolverHolder, cacheManager, keyGenerator, objectMapper);
118118
}
119119

120120
/**
@@ -135,7 +135,8 @@ public PythonExecutor cachingPythonExecutor(PythonCacheProperties cachePropertie
135135
PythonExecutor pythonExecutor,
136136
CacheManager cacheManager,
137137
CacheKeyGenerator keyGenerator) {
138-
return new CachingPythonExecutor(cacheProperties, pythonExecutor, cacheManager, keyGenerator);
138+
var nameProperties = cacheProperties.getName();
139+
return new CachingPythonExecutor(nameProperties.getExecutor(), pythonExecutor, cacheManager, keyGenerator);
139140
}
140141

141142
/**
@@ -158,6 +159,7 @@ public PythonProcessor cachingPythonProcessor(PythonCacheProperties cachePropert
158159
CacheManager cacheManager,
159160
CacheKeyGenerator keyGenerator,
160161
ObjectMapper objectMapper) {
161-
return new CachingPythonProcessor(cacheProperties, pythonProcessor, cacheManager, keyGenerator, objectMapper);
162+
var nameProperties = cacheProperties.getName();
163+
return new CachingPythonProcessor(nameProperties.getProcessor(), pythonProcessor, cacheManager, keyGenerator, objectMapper);
162164
}
163165
}

cache/spring-boot-python-executor-cache/src/main/java/io/w4t3rcs/python/properties/PythonCacheProperties.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/PythonCacheProperties.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
package io.w4t3rcs.python.properties;
1+
package io.w4t3rcs.python.autoconfigure;
22

33
import io.w4t3rcs.python.cache.HashCacheKeyGenerator;
44
import io.w4t3rcs.python.executor.CachingPythonExecutor;
55
import io.w4t3rcs.python.file.CachingPythonFileReader;
66
import io.w4t3rcs.python.processor.CachingPythonProcessor;
77
import io.w4t3rcs.python.resolver.CachingPythonResolverHolder;
8+
import lombok.Getter;
9+
import lombok.Setter;
810
import org.springframework.boot.context.properties.ConfigurationProperties;
911

1012
/**
@@ -42,8 +44,14 @@
4244
* @author w4t3rcs
4345
* @since 1.0.0
4446
*/
47+
@Getter @Setter
4548
@ConfigurationProperties(prefix = "spring.python.cache")
46-
public record PythonCacheProperties(boolean enabled, PythonCacheLevel[] levels, NameProperties name, KeyProperties key) {
49+
public class PythonCacheProperties {
50+
private boolean enabled = true;
51+
private PythonCacheLevel[] levels = new PythonCacheLevel[]{PythonCacheLevel.FILE, PythonCacheLevel.PROCESSOR};
52+
private NameProperties name = new NameProperties();
53+
private KeyProperties key = new KeyProperties();
54+
4755
/**
4856
* Enumeration of available caching levels.
4957
* <p>
@@ -59,26 +67,26 @@ public enum PythonCacheLevel {
5967
* <p>
6068
* Used to resolve cache instances by name in cache manager.
6169
* </p>
62-
*
63-
* @param filePaths cache name for cached file paths
64-
* @param fileBodies cache name for cached file bodies
65-
* @param resolver cache name for cached resolver results
66-
* @param executor cache name for cached executor results
67-
* @param processor cache name for cached processor results
6870
*/
69-
public record NameProperties(String filePaths, String fileBodies, String resolver, String executor, String processor) {
71+
@Getter @Setter
72+
public static class NameProperties {
73+
private String filePaths = "pythonFilePathsCache";
74+
private String fileBodies = "pythonFileBodiesCache";
75+
private String resolver = "pythonResolverCache";
76+
private String executor = "pythonExecutorCache";
77+
private String processor = "pythonProcessorCache";
7078
}
7179

7280
/**
7381
* Properties related to cache key generation.
7482
* <p>
7583
* Defines hash algorithm, charset, and delimiter used to generate cache keys.
7684
* </p>
77-
*
78-
* @param hashAlgorithm name of the hashing algorithm (e.g. "SHA-256")
79-
* @param charset charset name used to encode strings before hashing (e.g. "UTF-8")
80-
* @param delimiter delimiter string used to separate key parts
8185
*/
82-
public record KeyProperties(String hashAlgorithm, String charset, String delimiter) {
86+
@Getter @Setter
87+
public static class KeyProperties {
88+
private String hashAlgorithm = "SHA-256";
89+
private String charset = "UTF-8";
90+
private String delimiter = "_";
8391
}
8492
}

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/condition/ResolverCacheLevelCondition.java renamed to cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/ResolverCacheLevelCondition.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package io.w4t3rcs.python.condition;
1+
package io.w4t3rcs.python.autoconfigure;
22

3-
import io.w4t3rcs.python.config.PythonCacheAutoConfiguration;
4-
import io.w4t3rcs.python.properties.PythonCacheProperties;
53
import lombok.AccessLevel;
64
import lombok.Getter;
75

0 commit comments

Comments
 (0)