‎2021 Sep 01 4:23 PM - edited ‎2024 Feb 04 1:12 AM
I have created a custom interceptor and added the mapping in *spring.xml file as below,
1. Created the bean id for the customInterceptor class
<bean id="myValidateInterceptor" class ="*.MyValidateInterceptor">
</bean>
2.Then we will register the above customInterceptor class as a property into InterceptorMapping class as below
<bean id="MyValidateInterceptorMapping"
class ="de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping">
<property name="interceptor" ref="myValidateInterceptor"/>
<property name="typeCode" value="MyType"/>
</bean>
My question is how the "InterceptorMapping" works internally and which spring concept behind this kind of approach?
Kindly explain.
Thanks
Request clarification before answering.
All these Interceptor Mappings (Interceptor mapped to typeCode) are in a way stored in a registry in the form of Mapped Interceptors.
Platform internally fetches the correct interceptors if any for the typeCode and interceptorType in context and executes them.
As said, for more details, debug into Registry Class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is achieved with autowire="byType" property defined for defaultInterceptorRegistry bean. This property autowires the missing properties of the class. In the class DefaultInterceptorRegistry, all attributes are defined initially except interceptorExecutionPolicy, applicationContext and configuredMappings. When the bean initialized, these properties are autowired according to their type.
You can see this operation in action by debugging into the following code in DefaultInterceptorRegistry.
public void setInterceptorMappings(Collection<InterceptorMapping> configuredMappings) {
this.configuredMappings = configuredMappings;
}You should see it during startup.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.