cancel
Showing results for 
Search instead for 
Did you mean: 

More than one interceptor of one type

0 Kudos

Hi Experts,

Platform already has introduced InitDefaultsInterceptor for type. Now I need to populate one more property for type with default value, and going to introduce second InitDefaultsInterceptor for it.

Just want to confirm, that it is not bad practice to have two InitDefault interceptors. Or it is better to somehow extend(maybe even replace) existing one?

Accepted Solutions (0)

Answers (1)

Answers (1)

andyfletcher
Active Contributor
0 Kudos

It's not bad practice, in fact there is an example of using multiple InitDefaults interceptors in the cms2 extension. There is an InitDefaults interceptor on the CMSRelation type and then separate ones on the sub types ContentSlotForPage and ContentSlotForTemplate

If you need your new interceptor to fire before other ones then there is an order attribute, or use the replacedInterceptors to completely replace the existing one.

https://help.hybris.com/6.7.0/hcd/8bfbf43e8669101480d0f060d79b1baa.html#interceptors-registeraninter...

Also as has pointed out you can just override the default bean with your one but I wouldn't go as far as saying that this is better, it's just a different way of achieving the same result.