on ‎2019 Jun 28 4:10 PM
Hi,
Our application requires to have <lastmod></lastmod> tag in sitemap.xml for which I need to extend class de.hybris.platform.acceleratorservices.sitemap.renderer.SiteMapContext and override init() method. But going through the code I found that SiteMapContext.java class bean does not have an alias in acceleratorservices-spring.xml and only a bean id.
Question - How can we override this class methods if there is no alias provided in spring.xml?
This bean id siteMapContext is being called in AbstractSiteMapGenerator as below
(SiteMapContext) applicationContext.getBean("siteMapContext");
So even if I create a class by extending SiteMapContext and give a different bean id I will have to modify AbstractSiteMapGenerator class to use the new bean id.
What is the solution to this?
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hi - the following method will work for you:
<bean id="yourCustomSiteMapContext" class="your.package.YourCustomSiteMapContext">
...
...
...
</bean>
<alias name="yourCustomSiteMapContext" alias="siteMapContext"/>
Please try it and let me know your feedback.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Zahid, you just need to create a new bean with the same bean id as OTB. eg:
<bean id="siteMapContext"
class="your custom class"
scope="prototype">
<property name="baseSiteService" ref="baseSiteService"/>
<property name="siteBaseUrlResolutionService" ref="siteBaseUrlResolutionService"/>
<property name="urlEncoderService" ref="urlEncoderService"/>
</bean>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While it is possible to do so, it is an error-prone approach. A quick google search will point you to hundreds of links discussing the problem with this approach. A couple of them are as follows:
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.