Expand my Community achievements bar.

Override SearchConfig Sling Model in Asset Share Commons

Avatar

Level 1

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/a.... 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/a...) 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

Avatar

Community Advisor

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

Avatar

Level 1

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