Documentation Center

Plugin Execution Flow

This topic explains the basic terms and gives an overview of the execution flow.

Basic Terms And Definitions

Plugin
A custom module which execution can be triggered by the certain actions (like Create or Update).
Action
The main operation that triggers plugin execution.
Body Plugin
A plugin that is executed as a part of the transaction. If the plugin fails, main action fails. If the main action succeeds, all the plugins are guaranteed to have executed. This is the only type of plugins that is currently supported.
Plugin Engine
An application module that is responsible for executing plugins.
Plugin Category
A logical category which defines when a plugin will be executed and what it is allowed to do. Currently the only supported category is "Write" category.
Write Plugins
A category of plugins that are executed when changes that affect the object state are committed to the database (Create/Update/CheckIn/CheckOut).

Plugin Execution Flow

When executing plugins, plugin engine goes through the following stages:
  1. Create plugin instances
    1. Filter the plugin configuration applying the conditions to get the list of plugins. As the result, there should be no more than 1 write elements. If there is no write elements, plugins don't run. If there is more than one, the exception is thrown
    2. Create plugin instances. Plugin engine uses the value of the handler attribute of the plugin element specified in the configuration to find matching plugin implementation
  2. Initialize all plugins. Plugin engine makes sure every plugin is initialized before any plugin is executed
  3. Run all plugins. Plugin engine fills the context and passes to every plugin
  4. Cleanup. Plugin engine calls Dispose for every plugin

Error Handling

If plugin cannot finish what it is expected to do, it should throw any appropriate exception (e.g. InvalidArgumentException,...). Every exception thrown in the plugin code will be caught by the plugin engine, and will be properly logged, wrapped.