2024 Jan 30 8:20 AM - edited 2024 Jan 30 8:24 AM
I am currently performing an upgrade from the OCC addon to the OCC extension (https://help.sap.com/docs/SAP_COMMERCE/e5d7cec9064f453b84235dc582b886da/d46d19516961438f8939718e87ed...
Before the upgrade, the web context sits on our custom addon. Hence, we can freely add custom mvc interceptors as we want. After the upgrade (with the new OCC extension), we no longer have the web context as we are supposed to rely on the OOTB 'commmercewebservices' web context now. Hence, I am trying to include a custom interceptor to via my custom occ extension's dummyocc-web-spring.xml (I have verified, it is in a correct location). However, my custom interceptor isn't picked up at all..
dummyocc-web-spring.xml
<mvc:interceptors>
<ref bean="dummyCatalogVersionInterceptor" />
</mvc:interceptors>
May I ask is it even possible to add a custom mvc interceptor with the new architecture of the OCC extension? Is this the right approach?
Request clarification before answering.
In your custom occ extension , you can use a HandlerInterceptor :
@Component
public class CustomHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//your logic here
}
}
And then add your HandlerInterceptor to the InterceptorRegistry using a WebMvcConfigurer (always in your occ extension) :
@Configuration
public class OccWebConfig implements WebMvcConfigurer {
@Autowired
private CustomHandlerInterceptor customHandlerInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(customHandlerInterceptor)
.addPathPatterns("/**");
}
}
Make sure that your customocc-web-spring.xml is scanning the HandlerInterceptor and the WebMvcConfigurer packages (<context:component-scan base-package="com.project.occ"/>)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
22 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.