Skip to Content
author's profile photo Former Member
Former Member

how can configure interceptor for custom item type

I have created one item type in items.xml. after build model generated.how can i configure interceptor for generated model.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 29, 2016 at 07:44 AM

    First, you have to implement an interceptor. For e.g. lets create a prepare interceptor for item type "xyz"

     package my.package;
     public class XYZPrepareInterceptor implements PrepareInterceptor {
     
     @Override
         public void onPrepare(Object model, InterceptorContext ctx) throws InterceptorException {
             //Add you logic.
      }
     }
    
    

    Then, register the interceptor, add it to the Spring application context XML

     <bean id="xyzPrepareInterceptor" class="my.package.XYZPrepareInterceptor"/>
    
    

    Then, Add a de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping to the XML file

     <bean id="xyzPrepareInterceptorMapping" 
           class="de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping">
         <property name="interceptor" ref="xyzPrepareInterceptor"/>
         <property name="typeCode" value="xyz"/>
     </bean>
    
    

    Then, build and start the server.

    For more info refer https://wiki.hybris.com/display/release5/Interceptors

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 29, 2016 at 07:23 AM

    Hi Devendra,

    You will have to write interceptor code depending on what you want to achieve through the interceptors. For understanding the concept of interceptor and an example, please refer https://wiki.hybris.com/display/release5/Models and https://wiki.hybris.com/display/R5T/Trail+~+Events

    Thanks,

    Arvind

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 29, 2016 at 10:14 AM

    Hello Davendra,

    There are different interceptors available each targeted at a different phase of the model's lifecycle. This link explains the different types of interceptors and their Interfaces that need to be implemented. You can choose the ones that suit your requirement.

    Here is a link to hybris trail about Interceptors. In this trail, you will not only create interceptors and the required spring configuration but also learn about events. If you are only looking at creating Interceptors, I would suggest that you through the steps: Create an Interceptor and Register the interceptor for the stadium type from the above mentioned hybris trail.

    Hope this helps.

    Br, Shwetha

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.