This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/master by this push:
new 898f6dc3 SLING-12912: alias handling: wire alias bg cache init to OSGi
(#200)
898f6dc3 is described below
commit 898f6dc300323abb8cf6947ccb045ed6f6cf67b5
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Aug 26 17:18:51 2025 +0200
SLING-12912: alias handling: wire alias bg cache init to OSGi (#200)
---
.../impl/CommonResourceResolverFactoryImpl.java | 11 +++++------
.../impl/ResourceResolverFactoryActivator.java | 4 ++++
.../resourceresolver/impl/ResourceResolverFactoryConfig.java | 9 +++++++--
.../resourceresolver/impl/MockedResourceResolverImplTest.java | 5 +++++
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git
a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
index 3428e8c6..1ba90732 100644
---
a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
+++
b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java
@@ -397,12 +397,6 @@ public class CommonResourceResolverFactoryImpl implements
MapConfigurationProvid
return
this.activator.getVanityPathConfigurer().isVanityPathCacheInitInBackground();
}
- @Override
- public boolean isAliasCacheInitInBackground() {
- // wiring to config will be added later
- return false;
- }
-
/**
* get's the ServiceTracker of the ResourceAccessSecurity service
*/
@@ -445,6 +439,11 @@ public class CommonResourceResolverFactoryImpl implements
MapConfigurationProvid
return this.activator.isOptimizeAliasResolutionEnabled();
}
+ @Override
+ public boolean isAliasCacheInitInBackground() {
+ return this.activator.isAliasCacheInitInBackground();
+ }
+
@Override
public boolean hasVanityPathPrecedence() {
return
this.activator.getVanityPathConfigurer().hasVanityPathPrecedence();
diff --git
a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
index 3b285591..f8bdaee4 100644
---
a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
+++
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
@@ -192,6 +192,10 @@ public class ResourceResolverFactoryActivator {
return this.config.resource_resolver_optimize_alias_resolution();
}
+ public boolean isAliasCacheInitInBackground() {
+ return this.config.resource_resolver_alias_cache_in_background();
+ }
+
public Set<String> getAllowedAliasLocations() {
return this.allowedAliasLocations;
}
diff --git
a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryConfig.java
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryConfig.java
index 5b5b31b6..f1359695 100644
---
a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryConfig.java
+++
b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryConfig.java
@@ -168,10 +168,15 @@ public @interface ResourceResolverFactoryConfig {
@AttributeDefinition(
name = "Optimize alias resolution",
description = "This flag controls whether to optimize"
- + " the alias resolution by creating an internal cache of
aliases. NOTE: this setting will be removed "
- + " with the optimized resolution being the default (see
SLING-12025).")
+ + " the alias resolution by creating an internal cache of
aliases.")
boolean resource_resolver_optimize_alias_resolution() default true;
+ @AttributeDefinition(
+ name = "Alias Cache Init In Background",
+ description =
+ "This flag controls whether the alias cache will be
initialized synchronously or as a background thread, not blocking the startup.")
+ boolean resource_resolver_alias_cache_in_background() default true;
+
@AttributeDefinition(
name = "Allowed Optimized Alias Locations",
description = "This setting can contain a list of path prefixes,
e.g. /libs/, /content/. If "
diff --git
a/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
index 57aad76e..83f3bf1c 100644
---
a/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
+++
b/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
@@ -271,6 +271,11 @@ public class MockedResourceResolverImplTest {
return true;
}
+ @Override
+ public boolean
resource_resolver_alias_cache_in_background() {
+ return false;
+ }
+
@Override
public String[]
resource_resolver_allowed_alias_locations() {
// deliberately put a mixture of paths with and
without ending slash in here - both should be