Day 1: Disabling Interceptors in Hybris

Priyanka Manikkoth
2 min readNov 5, 2021

--

I came across this question in one of my gloriously screwed up technical interviews. It was a position that I so much wanted and life never goes as per our wishes. But what matters is that I got another thing to learn.

We can disable interceptors programmatically and through impex.

Disable through programming :

To disable interceptors in code, use the sessionService.executeInLocalViewWithParams method.

sessionService.executeInLocalViewWithParams(params, new SessionExecutionBody()
{

//Add code here

}

There are three attributes that allow you to disable specific interceptors during execution of callback:

  • Disabling specific interceptor beans through property
final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_INTERCEPTOR_BEANS, ImmutableSet.of("validateCurrencyDataInterceptor"));
  • Disabling specific interreceptor types
final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_INTERCEPTOR_TYPES,
ImmutableSet.of(InterceptorExecutionPolicy.InterceptorType.VALIDATE));
  • Disabling unique attributes validator
final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_UNIQUE_ATTRIBUTE_VALIDATOR_FOR_ITEM_TYPES, ImmutableSet.of("Currency"));

Disable through Impex

  • Disabling specific interceptor beans
INSERT_UPDATE Currency[disable.interceptor.beans='validateCurrencyDataInterceptor'];isocode[unique=true];symbol;digits;
;EUR_Test;$;-2;
  • Disabling specific interreceptor types
INSERT_UPDATE Currency[disable.interceptor.types=validate];isocode[unique=true];symbol;digits;
;EUR_Test2;$;-2;
  • Disabling unique attributes validator for specific types
INSERT_UPDATE Currency[disable.UniqueAttributesValidator.for.types='Currency'];isocode[unique=true];symbol;digits;
;EUR_Test;$;-2;

The above things are penned down just for my understanding. If anyone wants to dig deep, this is the proper SAP documentation.

Cool things I learned when I wandered off from the topic:

  1. By default Hybris follows lazy loading. It means all the primitive values will be loaded initially and the relations and objects are loaded as and when required. But there is a way to load everything at once even though it might impact performance. It is just a cool thing to know and never to be applied. :D

Change servicelayer.prefetch in local.properties to all from literal.By default it is literal(loading only primitive values)

2. We can disable getters and setters generation for an item type by adding the below line under item type declaration. Specific attribute getters and setters can be disabled by adding the same under attribute declaration.

<model generate="false"/>

I would like to hear about the cool things you have learned so far. :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Priyanka Manikkoth
Priyanka Manikkoth

Written by Priyanka Manikkoth

Coder by occupation, dreamer by choice

No responses yet

Write a response