Override SearchConfig Sling Model in Asset Share Commons | Community
Skip to main content
Level 2
February 27, 2025

Override SearchConfig Sling Model in Asset Share Commons

  • February 27, 2025
  • 2 replies
  • 650 views

Hi All,

 

I want to override the Asset Share Commons SearchConfig https://github.com/adobe/asset-share-commons/blob/develop/core/src/main/java/com/adobe/aem/commons/assetshare/components/search/SearchConfig.java. It already has an implementation class in AssetShareCommons (https://github.com/adobe/asset-share-commons/blob/develop/core/src/main/java/com/adobe/aem/commons/assetshare/components/search/impl/SearchConfigImpl.java) and is being referred in other sling models using 

@Self
@Required
 private SearchConfig searchConfig;
 
I have a custom requirement to override one of the methods of the SearchConfig and make sure this gets used. I have already implemented the delegate pattern but that is not working out.

Can anyone help me on this ? What would be the right approach of doing overriding the Sling Model ?
 

2 replies

VeenaVikraman
Community Advisor
Community Advisor
February 27, 2025

Hi @ayushag3 

 

Normally, when you need to override methods in a delegated service, you can use the following format:

 

@Delegates(excludes=DelegationExclusion.class)

I’ve briefly explained this concept in my article: AEM: Avoiding Delegation Pattern Pitfalls with Core Components.

 

I'm not sure if this approach will work in your case, but if you haven’t tried it yet, it might be worth exploring.

 

Thanks

Veena

AyushAg3Author
Level 2
March 1, 2025

@veenavikraman I have gone through the article. But this solution does not work in this case. Any other help would be appreciated.

kautuk_sahni
Community Manager
Community Manager
June 23, 2025

@ayushag3 Did you find the suggestion helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.

Kautuk Sahni