Skip to content

Commit 1fae9b7

Browse files
committed
Polishing.
Rename store-specific property to spring.aot.%s.repositories.enabled. See #3322 Original pull request: #3323
1 parent def98bc commit 1fae9b7

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@
325325
<version>${jmolecules-integration}</version>
326326
<optional>true</optional>
327327
</dependency>
328+
328329
<dependency>
329330
<groupId>org.junit.platform</groupId>
330331
<artifactId>junit-platform-launcher</artifactId>

src/main/java/org/springframework/data/aot/AotContext.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,32 @@ static AotContext from(BeanFactory beanFactory, Environment environment) {
8787

8888
/**
8989
* Checks if repository code generation is enabled for a given module by checking environment variables for general
90-
* enablement ({@link #GENERATED_REPOSITORIES_ENABLED}) and store specific ones following the pattern
91-
* {@literal spring.aot.repositories.&lt;module-name&gt;.enabled}.
90+
* enablement ({@link #GENERATED_REPOSITORIES_ENABLED}) and store-specific ones following the pattern
91+
* {@literal spring.aot.&lt;module-name&gt;.repositories.enabled}.
9292
* <p>
93-
* {@link #GENERATED_REPOSITORIES_ENABLED} acts as a kill switch, if disabled, store specific flags have no effect.
93+
* {@link #GENERATED_REPOSITORIES_ENABLED} acts as a main switch, if disabled, store specific flags have no effect.
9494
* <p>
95-
* Missing properties are interpreted as {@literal true}.
95+
* Unset properties are considered being {@literal true}.
9696
*
97-
* @param moduleName The name of the module. Can be {@literal null} or {@literal empty}, in which case it will only
98-
* check the general {@link #GENERATED_REPOSITORIES_ENABLED} flag.
97+
* @param moduleName name of the module. Can be {@literal null} or {@literal empty}, in which case it will only check
98+
* the general {@link #GENERATED_REPOSITORIES_ENABLED} flag.
9999
* @return indicator if repository code generation is enabled.
100100
* @since 5.0
101101
*/
102102
default boolean isGeneratedRepositoriesEnabled(@Nullable String moduleName) {
103103

104104
Environment environment = getEnvironment();
105-
Boolean codeGenerationEnabled = environment.getProperty(GENERATED_REPOSITORIES_ENABLED, Boolean.class, true);
106-
if (!codeGenerationEnabled) {
105+
106+
if (!environment.getProperty(GENERATED_REPOSITORIES_ENABLED, Boolean.class, true)) {
107107
return false;
108108
}
109109

110110
if (!StringUtils.hasText(moduleName)) {
111111
return true;
112112
}
113113

114-
String modulePropertyName = GENERATED_REPOSITORIES_ENABLED.replace("enabled",
115-
"%s.enabled".formatted(moduleName.toLowerCase(Locale.US)));
114+
String modulePropertyName = GENERATED_REPOSITORIES_ENABLED.replace("repositories",
115+
"%s.repositories".formatted(moduleName.toLowerCase(Locale.ROOT)));
116116
return environment.getProperty(modulePropertyName, Boolean.class, true);
117117
}
118118

src/main/java/org/springframework/data/repository/config/RepositoryConfigurationDelegate.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ public List<BeanComponentDefinition> registerRepositoriesIn(BeanDefinitionRegist
216216
configurations.size() == 1 ? "" : "s"));
217217
}
218218

219-
// TODO: AOT Processing -> guard this one with a flag so it's not always present
220-
// TODO: With regard to AOT Processing, perhaps we need to be smart and detect whether "core" AOT components are
221-
// (or rather configuration is) present on the classpath to enable Spring Data AOT component registration.
222219
registerAotComponents(registry, extension, metadataByRepositoryBeanName);
223220

224221
return definitions;

src/main/java/org/springframework/data/repository/config/RepositoryConfigurationExtension.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public interface RepositoryConfigurationExtension {
4343
* @since 3.0
4444
*/
4545
default String getModuleIdentifier() {
46-
47-
return getModuleName().toLowerCase(Locale.ENGLISH).replace(' ', '-');
46+
return getModuleName().toLowerCase(Locale.ROOT).replace(' ', '-');
4847
}
4948

5049
/**

src/test/java/org/springframework/data/aot/AotContextUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ void considersEnvironmentSettingsForGeneratedRepositories(String generalFlag, St
4949
ctx.withProperty(generalFlag, generalValue);
5050
}
5151
if (StringUtils.hasText(storeName) && StringUtils.hasText(storeValue)) {
52-
ctx.withProperty("spring.aot.repositories.%s.enabled".formatted(storeName), storeValue);
52+
ctx.withProperty("spring.aot.%s.repositories.enabled".formatted(storeName), storeValue);
5353
}
5454

5555
Assertions.assertThat(ctx.isGeneratedRepositoriesEnabled(storeName)).isEqualTo(enabled);
5656
}
5757

58-
class MockAotContext implements AotContext {
58+
static class MockAotContext implements AotContext {
5959

6060
private final MockEnvironment environment;
6161

0 commit comments

Comments
 (0)