Previous Topic

Next Topic

Book Contents

Book Index

Hooks

The Home Automation Manager provides the hooks mechanism for intercepting information about automation objects. Hooks allow you to introduce some custom logic in the way that information is pre-processed before it reaches its destination.

The HAM API bundle exports the com.prosyst.mbs.services.ham.hooks package that currently holds only one hook: HAMValidateHook.

Using the HAMValidateHook

Implement and register the hook if you want to use some custom logic for validating newly created automation objects (conditions, commands, and rules).

Implementing the Hook Interface

Provide an implementation of the HAMValidateHook and introduce some custom logic in its validate(HAObject hao) method. There are two approaches for creating your hook implementation:

Registering the Hook as an OSGi Service

Register the hook's implementation as an OSGi service to make it available to the Home Automation Admin. All registered HAMValidateHooks are called when a new condition/command/rule is created and configured and should be added to HAM via the save() method of the com.prosyst.mbs.services.ham.HAObject interface. The validate method is called before the save() method is invoked for the specific automation object. In case the validation fails an exception should be thrown and the new automation object will not be saved in HAM.