This is an automated email from the ASF dual-hosted git repository. reschke pushed a commit to branch SLING-12912 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 7b6b1ecc0eba49e10c5d198b62717e5532f9c377 Author: Julian Reschke <resc...@apache.org> AuthorDate: Tue Aug 26 10:27:49 2025 +0100 SLING-12912: alias handling: wire alias bg cache init to OSGi --- .../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..e44bc94d 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 vanity path cache will be initialized immediately or later as a background task.") + 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