Podcast
Questions and Answers
Which class serves as the base for all handlers in the given implementation?
Which class serves as the base for all handlers in the given implementation?
What must be specified in the ShowTaxAndShippingForBuyer3 class to associate it with a handler chain?
What must be specified in the ShowTaxAndShippingForBuyer3 class to associate it with a handler chain?
What attribute must be used to decorate the new handler class?
What attribute must be used to decorate the new handler class?
What type of methods does the HandlerBase class provide to facilitate error handling?
What type of methods does the HandlerBase class provide to facilitate error handling?
Signup and view all the answers
Which of the following is a mandatory prerequisite before adding a new handler?
Which of the following is a mandatory prerequisite before adding a new handler?
Signup and view all the answers
What does the last configuration for the new handler require in relation to the dependency locator?
What does the last configuration for the new handler require in relation to the dependency locator?
Signup and view all the answers
In the implementation, which positions the new handler within a specified chain?
In the implementation, which positions the new handler within a specified chain?
Signup and view all the answers
What should be specified for the 'Order' property in the new handler class?
What should be specified for the 'Order' property in the new handler class?
Signup and view all the answers
What is the primary requirement for a handler to be used within a handler chain?
What is the primary requirement for a handler to be used within a handler chain?
Signup and view all the answers
How does the Order property affect the execution of handlers in a chain?
How does the Order property affect the execution of handlers in a chain?
Signup and view all the answers
What is the default starting order for all handler chains?
What is the default starting order for all handler chains?
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?
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?
Signup and view all the answers
What must be specified in the Execute method of a handler?
What must be specified in the Execute method of a handler?
Signup and view all the answers
What is the default order value for handlers within a handler chain?
What is the default order value for handlers within a handler chain?
Signup and view all the answers
What happens if the result's cart is null within the Execute method?
What happens if the result's cart is null within the Execute method?
Signup and view all the answers
What is the purpose of the 'result.ShowTaxAndShipping' assignment in the Execute method?
What is the purpose of the 'result.ShowTaxAndShipping' assignment in the Execute method?
Signup and view all the answers
Which order value would allow a handler to be inserted into the second position of a handler chain?
Which order value would allow a handler to be inserted into the second position of a handler chain?
Signup and view all the answers
What does returning 'result' from the Execute method do?
What does returning 'result' from the Execute method do?
Signup and view all the answers
What determines the association of a handler with a handler chain?
What determines the association of a handler with a handler chain?
Signup and view all the answers
In the handler class definition, what does the method 'Execute' return if it processes correctly?
In the handler class definition, what does the method 'Execute' return if it processes correctly?
Signup and view all the answers
How are additional handlers typically ordered in a handler chain?
How are additional handlers typically ordered in a handler chain?
Signup and view all the answers
What must be true for handlers to execute in the same handler chain?
What must be true for handlers to execute in the same handler chain?
Signup and view all the answers
What is the Order property value in the ShowTaxAndShippingForBuyer3 handler class?
What is the Order property value in the ShowTaxAndShippingForBuyer3 handler class?
Signup and view all the answers
Which method is responsible for continuing the handler chain to the next handler?
Which method is responsible for continuing the handler chain to the next handler?
Signup and view all the answers
What is the role of handlers in Optimizely Configured Commerce?
What is the role of handlers in Optimizely Configured Commerce?
Signup and view all the answers
How can a developer remove or replace a handler in the Configured Commerce platform?
How can a developer remove or replace a handler in the Configured Commerce platform?
Signup and view all the answers
What happens when a handler chain is executed?
What happens when a handler chain is executed?
Signup and view all the answers
What is one way to create a custom handler in Configured Commerce?
What is one way to create a custom handler in Configured Commerce?
Signup and view all the answers
Which of the following chains is specifically mentioned for cart-related operations?
Which of the following chains is specifically mentioned for cart-related operations?
Signup and view all the answers
Why can't a handler be completely removed from Configured Commerce?
Why can't a handler be completely removed from Configured Commerce?
Signup and view all the answers
When is the GetCartHandler chain typically executed?
When is the GetCartHandler chain typically executed?
Signup and view all the answers
What are module handlers primarily used for in the Configured Commerce platform?
What are module handlers primarily used for in the Configured Commerce platform?
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.
-
GetCartHandler chain: Retrieves the cart object for the currently authenticated user.
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.
- Implement the
- The
IHandler
interface requires the handler to implement theExecute
method, specify handler order using theOrder
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
andTOut
).
Handler Implementation Example
- Handler classes can inherit from the
HandlerBase
class, which implements theIHandler
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.
- Returning
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.
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.