Hooks¶
Hooks are a way to add custom functionality to the pipeline. They are called at various points in the process and can be used to perform custom actions.
Hooks are added to the system by creating a class that implements the corresponding hook interface.
A single hook can implement multiple interfaces and can be used to perform multiple actions.
Available Hooks:¶
BeforePipelineHook → Called before the pipeline is executed.
BeforePipelineHookInterface
AfterBulkHook → Called after each bulk has been processed.
AfterBulkHookInterface
AfterPipelineHook → Called after the pipeline has been executed.
AfterPipelineHookInterface
Adding a Hook:¶
To add a hook to the system, you need to create a HookPlugin class
that will be used to register the hook in the system.
The HookPlugin class should implement the HookPluginInterface and
should be registered in the SpringbokDependencyProvider@getHookPlugins method.
Example:¶
<springbok xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/schema file://../../../src/Generated/Zed/Springbok/schema.xsd"
xmlns="http://www.example.com/schema">
<pipeline name="hooks_example">
<extractor>
<csv-file filename="data/import/common/common/category.csv" bulkSize="5" />
</extractor>
<transformers>
<copy from="category_key" to="key_category" />
</transformers>
<loaders>
<xml outputFileName="data/output/output.xml" />
</loaders>
<hooks>
<before-pipeline-example />
<after-pipeline-example />
<after-bulk-example />
</hooks>
</pipeline>
</springbok>
Further Reading:¶
See How to write a new hook plugin for more information on how to write a hook plugin.