This advanced JSup feature enable a I/O Channel to get its I/O hooks from a JavaCode function that will decide which tag (for instance based according to the tag class) will be bound to which device item and if in read/write only mode.
The JavaCode function must accept an unique parameter: ChannelInfo ch
And must return an Iterable<IOHookCodeCreatedInfo> object.
Its signature should be:
Iterable<IOHookCodeCreatedInfo> functionName ( ChannelInfo ch ) throws JException;
The JavaCode function can determine which tag to include be enumerating the tags that belong to a certain tag class. The following example provides MQTT I/O hook for the tag of tag class named /device/onoff:
final Vector<IOHookCodeCreatedInfo> v = new Vector<>();
for( final TagRef tag : getTagClass( "/device/onoff" ).tags() ) {
v.add( new IOHookCodeCreatedInfo.N.Adapter(
tag, "/JSupTest/device/onoff/"+tag.getName(), true, false, null, null, false )
);
}