on 10-15-2015 10:10 AM
I defined a custom CockpitThreadContextCreator in mybackoffice-backoffice-spring.xml to add some additional session attributes to a newly created context:
<alias name="myThreadContextCreator" alias="cockpitThreadContextCreator"/>
<bean id="myThreadContextCreator" parent="backofficeCockpitThreadContextCreator" class="com.mybackoffice.MyThreadContextCreator">
</bean>
The bean gets instantiated successfully but is never used at runtime. Instead the default backofficeCockpitThreadContextCreator is used. How can i override the default implementation?
I just wan't to add that you don't need to modify the Web.xml of the backoffice extension to load new spring configurations from your backoffice extension as in or soluntions.
Yo can use the HybrisBackoffice.additionalWebSpringConfigs.mybackoffice property in the proyect properties on your backoffice extension to load an additional spring file to the backoffice web context. for example:
HybrisBackoffice.additionalWebSpringConfigs.mybackoffice=classpath:/mybackoffice/spring/import.xml
this will search for import.xml at
/mybackoffice/resources/mybackoffice/spring/import.xml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please use Bean Extenders Mechanism. https://help.hybris.com/6.6.0/hcd/94ac56a0aa9f486490bbe1251d994457.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've experienced the same problem, and indeed there does not seem to be an OOTB Hybris solution to adapt the logic of the backoffice-web defined beans. I've seen the solution of , but there is quite some modifications to the buildcallbacks, moving files around, so I've implement a different (and easier?) strategy. What I've done:
I've created a custom web spring xml file in the custom backoffice extension: mybackoffice/resources/mybackoffice-web-spring.xml
In this file, I override/change/... beans defined in the backoffice extensions web-spring xml
The trick that I've applied is to update the buildcallbacks.xml to include this custom web context in the web-app-context of the backoffice application (this means including the custom web xml file in the contextConfigLocation list)
Compile and run
The modifications to the buildcallbacks.xml are the following:
<macrodef name="mybackoffice_after_build">
<sequential>
...
<replaceregexp
file="${ext.backoffice.path}/web/webroot/WEB-INF/web.xml"
match="backoffice-web-spring.xml(?!,)"
replace="backoffice-web-spring.xml,classpath:mybackoffice-web-spring.xml"/>
</sequential>
</macrodef>
The result of those modifications can be seen in the backoffice extensions web.xml file:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/backoffice-web-spring.xml,classpath:mybackoffice-web-spring.xml
</param-value>
</context-param>
For me those adaptions work, and seem to be quite easy to achieve what I need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So this can be done! I've done it, but it does take some setup, configuration, and leveraging the 'customize' ant target. It's a simple process, but takes a few minutes to setup. I have documented it here: http://www.daharveyjr.com/hybris-how-to-override-a-bean-in-backoffice-web-spring-xml/
If this link isn't allowed, let me know and I'll re-adjust. It just took a longer write-up than easily done here!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Has anyone resolved this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Has anyone resolved this? I've got the same issue with overriding another bean located in backoffice-web-spring.xml.
Thanks, Dimitar
Thanks, Dimitar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you define your bean with the same ID then it's a matter of sequence of instantiation if your bean is used or the default one. Make sure to set up a dependency to the standard extension to make sure yours is loaded after.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My backoffice extension already has a dependency to the standard backoffice extension. The backofficeCockpitThreadContextCreator is defined in backoffice-web-spring.xml and aliased with cockpitThreadContextCreator like my bean. The context of my bean does not seem to affect the backoffice web context.
User | Count |
---|---|
7 | |
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.