Handlers & Pipelines	Extending a handler chain
32 Questions
7 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 (B)</p> Signup and view all the answers

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

<p>ISC SDK installed (A)</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 (A)</p> Signup and view all the answers

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

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

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

<p>Its data type (B)</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. (D)</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. (B)</p> Signup and view all the answers

What is the default starting order for all handler chains?

<p>100 (A)</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 (B)</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. (C)</p> Signup and view all the answers

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

<p>500 (A)</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. (A)</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. (A)</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 (D)</p> Signup and view all the answers

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

<p>Breaks the handler chain. (D)</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). (A)</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. (B)</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. (D)</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. (C)</p> Signup and view all the answers

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

<p>3000 (A)</p> Signup and view all the answers

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

<p>this.NextHandler.Execute (D)</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. (B)</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. (B)</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. (B)</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. (B)</p> Signup and view all the answers

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

<p>GetCartHandler chain (C)</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. (C)</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. (B)</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. (C)</p> Signup and view all the answers

Flashcards

Handler

An object that processes business logic in Optimizely Configured Commerce, part of a handler chain.

Handler Chain

A sequence of handlers executed in a specific order.

GetCartHandler chain

Retrieves the cart, cart lines, shipping data, taxes and carriers for the logged-in user.

GetProductHandler chain

Retrieves a product by its identifier.

Signup and view all the flashcards

IHandler interface

Defines the contract for handler implementations.

Signup and view all the flashcards

Execute method

The entry point for a handler's business logic.

Signup and view all the flashcards

Order property

Specifies the order in which the handler executes.

Signup and view all the flashcards

DependencyName attribute

Identifies the handler for retrieval.

Signup and view all the flashcards

HandlerBase class

A base class implementing IHandler providing utility methods.

Signup and view all the flashcards

TIn/TOut

Parameter and Result object types associated with a handler chain.

Signup and view all the flashcards

Handler chain order

Handlers are executed in ascending order of order values.

Signup and view all the flashcards

Default handler order

Handler chains usually have at least one handler with an order of 500.

Signup and view all the flashcards

Adding a handler

Implement IHandler interface, use DependencyName, define Order, and implement the Execute method.

Signup and view all the flashcards

Replacing a handler

Create a custom HandlerBase class with the same DependencyName.

Signup and view all the flashcards

handler chain execution

Handlers in sequence perform related actions on data until the last one is reached.

Signup and view all the flashcards

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

General Architecture	Hosting Environments
29 questions
Search	search settings config
40 questions

Search search settings config

SupportedAstatine4145 avatar
SupportedAstatine4145
Optimizely One Products Quiz
45 questions
Use Quizgecko on...
Browser
Browser