Handlers & Pipelines	Extending a handler chain
32 Questions
4 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which class serves as the base for all handlers in the given implementation?

  • HandlerBase (correct)
  • IHandler
  • GetCart
  • ApplyPromotion
  • What must be specified in the ShowTaxAndShippingForBuyer3 class to associate it with a handler chain?

  • When to execute the handler
  • Result type as GetCartResult and Parameter type as GetCartParameter (correct)
  • A method for handling errors
  • The constructor of the class
  • What attribute must be used to decorate the new handler class?

  • ServiceLocator
  • HandlerMapping
  • HandlerChain
  • DependencyName (correct)
  • What type of methods does the HandlerBase class provide to facilitate error handling?

    <p>Utility methods</p> Signup and view all the answers

    Which of the following is a mandatory prerequisite before adding a new handler?

    <p>ISC SDK installed</p> Signup and view all the answers

    What does the last configuration for the new handler require in relation to the dependency locator?

    <p>Providing a dependency name</p> Signup and view all the answers

    In the implementation, which positions the new handler within a specified chain?

    <p>Correct association of types</p> Signup and view all the answers

    What should be specified for the 'Order' property in the new handler class?

    <p>Its data type</p> Signup and view all the answers

    What is the primary requirement for a handler to be used within a handler chain?

    <p>It must implement the IHandler interface.</p> Signup and view all the answers

    How does the Order property affect the execution of handlers in a chain?

    <p>Handlers are executed in ascending order based on the Order property.</p> Signup and view all the answers

    What is the default starting order for all handler chains?

    <p>100</p> Signup and view all the answers

    What value must the 'Order Management > Cart > Show Tax & Shipping Amount in Cart' setting be set to in order for the specific handler logic to function?

    <p>Yes</p> Signup and view all the answers

    What must be specified in the Execute method of a handler?

    <p>All business logic used by the handler.</p> Signup and view all the answers

    What is the default order value for handlers within a handler chain?

    <p>500</p> Signup and view all the answers

    What happens if the result's cart is null within the Execute method?

    <p>An error result will be created and returned.</p> Signup and view all the answers

    What is the purpose of the 'result.ShowTaxAndShipping' assignment in the Execute method?

    <p>To determine if tax and shipping details should be displayed to the user.</p> Signup and view all the answers

    Which order value would allow a handler to be inserted into the second position of a handler chain?

    <p>150</p> Signup and view all the answers

    What does returning 'result' from the Execute method do?

    <p>Breaks the handler chain.</p> Signup and view all the answers

    What determines the association of a handler with a handler chain?

    <p>The parameter and result object types (TIn and TOut).</p> Signup and view all the answers

    In the handler class definition, what does the method 'Execute' return if it processes correctly?

    <p>The modified 'result' object.</p> Signup and view all the answers

    How are additional handlers typically ordered in a handler chain?

    <p>In increments of 100 from the base order value.</p> Signup and view all the answers

    What must be true for handlers to execute in the same handler chain?

    <p>They must declare the same parameter and result object types.</p> Signup and view all the answers

    What is the Order property value in the ShowTaxAndShippingForBuyer3 handler class?

    <p>3000</p> Signup and view all the answers

    Which method is responsible for continuing the handler chain to the next handler?

    <p>this.NextHandler.Execute</p> Signup and view all the answers

    What is the role of handlers in Optimizely Configured Commerce?

    <p>They handle processing of business logic and objects.</p> Signup and view all the answers

    How can a developer remove or replace a handler in the Configured Commerce platform?

    <p>By giving their custom implementation the same dependency name as the existing handler.</p> Signup and view all the answers

    What happens when a handler chain is executed?

    <p>Handlers execute in a configured order until no more handlers are available.</p> Signup and view all the answers

    What is one way to create a custom handler in Configured Commerce?

    <p>By implementing HandlerBase and defining custom methods.</p> Signup and view all the answers

    Which of the following chains is specifically mentioned for cart-related operations?

    <p>GetCartHandler chain</p> Signup and view all the answers

    Why can't a handler be completely removed from Configured Commerce?

    <p>You can create an implementation of it that does nothing instead.</p> Signup and view all the answers

    When is the GetCartHandler chain typically executed?

    <p>When a user navigates to the Cart page or Checkout Address page.</p> Signup and view all the answers

    What are module handlers primarily used for in the Configured Commerce platform?

    <p>Adding business logic and providing data to interface objects.</p> Signup and view all the answers

    Study Notes

    Handlers

    • Handlers are objects that process business logic in Optimizely Configured Commerce.
    • They are part of handler chains, which are executed in a specific order.
    • Each handler in the chain is executed until no more handlers are available.
    • Example handler chains:
      • GetCartHandler chain: Retrieves the cart object for the currently authenticated user.
        • It also gets cart-related data like lines, shipping costs, taxes, and carriers..
      • GetProductHandler chain: Retrieves a product given a product identifier.

    Adding Handlers

    • To add a new handler to an existing handler chain, the handler must:
      • Implement the IHandler interface.
      • Be decorated with the DependencyName attribute.
      • Return a result from the Execute method.
      • Specify an order via the Order property.
    • The IHandler interface requires the handler to implement the Execute method, specify handler order using the Order property, and associate the handler with a handler chain.
    • The Execute method is the sole entry point into a handler and contains the business logic.
    • The Order property determines the order of the handler within the chain.
      • Handlers are ordered in ascending order.
      • By default, all handler chains have at least one handler with an order value of 500.
      • Additional handlers usually increment the order by 100.
    • A handler is associated with a handler chain based on the parameter and result object types (TIn and TOut).

    Handler Implementation Example

    • Handler classes can inherit from the HandlerBase class, which implements the IHandler interface and provides utility methods for returning error results and passing execution to the next handler.
    • All handlers should inherit from the HandlerBase class as a best practice.
    • The DependencyName attribute allows the handler to be retrieved by name via the dependency locator.
    • The Order property specifies the order in which the handler will be executed within the handler chain.
    • The Execute method can either continue the handler chain or break it.
      • Returning this.NextHandler.Execute(unitOfWork, parameter, result) continues the chain.
      • Returning result breaks the chain.

    Removing or Replacing Handlers

    • In Configured Commerce 4.0, handlers are the primary extension point for adding business logic and providing additional data.
    • To remove or replace a handler, give it the same dependency name as an existing handler and implement a custom class that derives from HandlerBase.
    • The custom class will override the standard Configured Commerce handler.
    • This approach avoids the need to use the Order property since the custom class replaces the existing handler.
    • You cannot directly remove a handler, but you can create an implementation that does nothing.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz covers the concept of handlers in Optimizely Configured Commerce, focusing on their role in processing business logic and the execution sequence of handler chains. It also explains how to add new handlers to existing chains by implementing the IHandler interface and using specific attributes.

    More Like This

    Use Quizgecko on...
    Browser
    Browser