Operation Service Interpretation of the Operation Sequence

The operation service is called by a ProcessRequest or AuthorizeRequest to retrieve and execute the appropriate operation sequence in order to process a request and generate an operation response.

A ProcessRequest calls the operation service to carry out the request (Go do this!), whereas an AuthorizeRequest calls the operation service to find out what an identity is allowed to do for the specified channel, entity, operation, and properties (What can I do?).

This topic covers the following:

  • Operation Service Interpretation of a ProcessRequest

  • Operation Service Interpretation of an AuthorizeRequest

Operation Service Interpretation of a ProcessRequest

The operation service performs the following actions to interpret a ProcessRequest:

  1. The operation service inspects the incoming request context to determine the appropriate channel to retrieve from Channel Configuration.

  2. The operation service checks the type of the request object and the type of the model contained in this object to determine the name of the message handler operation responsible for handling this request.

  3. The operation service creates the OperationCacheDictionary object. For more information about how the operation components can use the OperationCacheDictionary, see Commerce Foundation OperationCacheDictionary.

  4. The operation service creates a CommerceOperationResponse based on the configuration of the operation sequence.

  5. If this is the first time the operation is to be executed, the operation service loads the operation sequence component type information from the configuration file and stores it in the internal cache. For more information about the operation configuration, see Commerce Foundation Operation Sequences. Dependency checking is performed at this point. Otherwise, on the subsequent calls to the operation, the operation service retrieves the operation component type information from the internal cache.

  6. Using the type information obtained in the previous step, the operation service instantiates all the configured operation sequence components using reflection.

  7. The operation service first looks for any components in the operation sequence that implement the IPreprocessSequenceComponent.Preprocess interface method and executes those components in the order in which they appear in the configuration file.

  8. Next, if Authorization is enabled, the operation service looks for any components in the operation sequence that implement the ICommerceAuthorizableSequenceComponent.CanExecute interface method and executes those components in the order in which they appear in the configuration file.

  9. If the operation sequence is configured as transactional, the operation service treats the entire operation sequence as a single transaction. All the components within the operation sequence that implement the IOperationSequenceComponent.Execute interface method must succeed entirely before any change is committed to the database. At this point, the operation service begins the transaction and executes the components as described in step 10. By default, operation sequences are not transactional. In which case, the operation service executes the components as described in step 10. For more information, see Commerce Foundation Transactions.

  10. The operation service looks for any components in the operation sequence that implement the IOperationSequenceComponent.Execute interface method and executes those components in the order in which they appear in the configuration file.

  11. If the operation sequence is configured as transactional and a single sequence component fails, any tentative changes to the database are rolled back. However, if all the operation sequence components are successfully executed, the changes are committed to the database.

  12. If an error occurs during the execution of the IOperationSequenceComponent.Execute phase of an operation sequence, the operation service catches the exception. The operation service then looks for any components in the operation sequence that implement the IPostProcessSequenceComponent.PostProcess interface method, passes the exception to each of those components, and executes those components in the order in which they appear in the configuration file. The IPostProcessSequenceComponent.PostProcess interface method passes the error that occurred during the execution of the IOperationSequenceComponent.Execute phase, if one occurred.

  13. The operation service finishes the execution of the operation by returning the Response object updated by the operation sequence components.

Operation Service Interpretation of an AuthorizeRequest

The operation service performs the following actions to interpret an AuthorizeRequest:

  1. The operation service inspects the incoming request context to determine the appropriate channel to retrieve from Channel Configuration.

  2. The operation service checks the type of the Request object and the type of the model contained in this object to determine the name of the message handler operation responsible for handling this request.

  3. The operation service creates the OperationCacheDictionary object. For more information about how the operation components can use the OperationCacheDictionary, see Commerce Foundation OperationCacheDictionary.

  4. The operation service creates a CommerceAuthorizationOperationResponse.

  5. If this is the first time the operation is to be executed, the operation service loads the operation sequence component type information from configuration file and stores it in the internal cache. For more information about the operation configuration, see Commerce Foundation Operation Sequences. Dependency checking is performed at this point. Otherwise, on the subsequent calls to the operation, the operation service retrieves the operation component type information from the internal cache.

  6. Using the type information obtained in the previous step, the operation service instantiates all the configured operation sequence components using reflection.

  7. The operation service first looks for any components in the operation sequence that implement the IPreprocessSequenceComponent.Preauthorize interface and executes those components in the order in which they appear in the configuration file.

  8. The operation service looks for any components in the operation sequence that implement the ICommerceAuthorizableSequenceComponent.AuthorizeOperation interface and executes those components in the order in which they appear in the configuration file.

  9. If an error occurs during the execution of the ICommerceAuthorizableSequenceComponent.AuthorizeOperation phase of an operation sequence, the operation service catches the exception. The operation service then looks for any components in the operation sequence that implement the IPostProcessSequenceComponent.PostAuthorize interface method, passes the exception to each of those components, and executes those components in the order in which they appear in the configuration file. The IPostProcessSequenceComponent.PostAuthorize interface method passes the error that occurred during the execution of the ICommerceAuthorizableSequenceComponent.AuthorizeOperation phase, if one occurred.

  10. The operation service finishes the execution of the operation by returning the Response object updated by the operation sequence components.

See Also

Other Resources

Commerce Foundation Operation Sequences