Previous Topic

Next Topic

Book Contents

Book Index

Hooks (deprecated)

The HDM provides a mechanism for inserting custom logic for its basic operations - adding/removing devices or zones, changing the value of a home device or a device class object property, or executing a device class object operation.

Using Hooks

To use a hook implement its interface and register it as an OSGi service. Optionally, you can specify as registration properties of the service the parameters of the devices or zones that this hook should be used for.

For each Hook interface is provided a list of registration properties that you can use.

The value of a property can be either of type String - for one value or String[] - for multiple values.

After the Hook is registered the Home Device Manager automatically discovers it and attaches it to its system.

When multiple hook services are registered for a certain device or zone, the service with the highest ranking number will be called first.

Available Hooks

Currently there are four hooks available:

DeviceClassObjectModifyHook

The DeviceClassObjectModifyHook is used when the value of a Device Class Object property is about to be changed. Before setting the new value the Home Device Manager calls the modifyProperty method to check if this value needs to be modified or can be used as it is. Optionally, to specify the target devices, you can register this Hook with the following properties:

HomeDeviceAddHook

The HomeDeviceAddHook is used to prevent adding unexpected Home Devices to the HDM, as well as to specify the visibility of Home Devices which cannot be removed from the HDM (for example, due to Protocol Adapter limitations).

The HomeDeviceAddHook provides three methods - setHandler, deviceAvailable and deviceUnavailable. HDM uses such hooks when:

If multiple services need to be registered to a specific device, the hooks are called in the compareTo reverse ordering of their Service References. The service with the highest ranking number is called first when:

In some cases custom logic will be needed in order to prevent any useless adding of devices or visibility state management issues. In order to add a home device, it must be specified with the hook model which accepts/rejects devices that are waiting to be added. Otherwise a device, different from the expected one might be detected first. All devices that are collected in the inbox are checked. The hook is notified for every available device and is responsible to accept or reject every device by invoking a method of the HomeDeviceAddHookHandler as a callback. The devices that are accepted by the hook should be added and set to visible. A rejected device should be removed. When a device is unavailable the HDM notifies the HomeDeviceAddHook that the provided device is removed.ptionally, to specify the target devices, you can register this Hook with the following properties:

HomeDeviceValidateHook

The Home Device Manager calls all registered HomeDeviceValidateHook services when the values of Home Device properties need to be validated before they are set. HDM uses such hooks when an application tries to:

Optionally, to specify the target devices, you can register this Hook with the following properties:

HomeZoneValidateHook

The Home Device Manager calls all registered HomeZoneValidateHook services when the values of the Home Zone properties and Device Class Object properties that should be set to devices part of a Home Zone, need to be validated before they are set. HDM uses such hooks when an application tries to:

Optionally, to specify the target zones, you can register this Hook with the following properties: