cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How the "InterceptorMapping" works internally and what spring concept behind this kind approach?

1,104

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member506
Participant
0 Likes

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.

mansurarisoy
Contributor
0 Likes

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.