WriteHandler Management

My Module creates a custom TagProvider. This TagProvider dynamically creates and updates tags as needed. When a new tag is created, I run the registerWriteHandler() method for that tag.

class myWriteHandler implements WriteHandler {
     ...
}

SimpleTagProvider myTagProvider;

...
...

myTagProvider.updateValue(tagPath, tagValue, DataQuality.GOOD_DATA);
myTagProvider.registerWriteHandler(tagPath, myWriteHandler);

As you can see, I use the updateValue() method to both update AND create (if the tag doesn’t exist) tags in myProvider.

The Question:
Is it a problem that I register a write handler on a tag every time the tag is updated? Should I only register the write handler upon tag creation? If so, how do I check if a write handler has already been registered for a given tagPath?

It looks like registering WriteHandlers multiple times is safe. The new handler replaces the old handler.

It doesn’t look like anything is available via SimpleTagProvider to check if it has been registered before; you would need to do that bookkeeping yourself.

Thanks, Kevin!