Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Override validateConfigurationParameters in binding to check config?(Question about best practice building binding )
Override validateConfigurationParameters in binding to check config? [message #1775923] Wed, 08 November 2017 09:49 Go to next message
Hilbrand Bouwkamp is currently offline Hilbrand BouwkampFriend
Messages: 5
Registered: October 2017
Junior Member
In many bindings config validation is done in the initialize method. However there is also a protected method validateConfigurationParameters in the BaseThingHandler. While I could not find a binding that overrides this method (it's protected so it is intended to be overridden) it seems logic to override this method and check for configurations in this method instead in the initialize. I couldn't find anything in the documentation about this. But is doing the checks in the validateConfigurationParameters a valid or maybe even preferred approach?
Re: Override validateConfigurationParameters in binding to check config? [message #1776034 is a reply to message #1775923] Thu, 09 November 2017 13:57 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

There is a JavaDoc for the method:

Quote:

/**
* Validates the given configuration parameters against the configuration description.
*
* @param configurationParameters the configuration parameters to be validated
*
* @throws ConfigValidationException if one or more of the given configuration parameters do not match
* their declarations in the configuration description
*/


So, the intention is to ensure that the configuration fits to the used configuration description.

I would expect that we rely in the initialize method that the configuration does not conflict with its description.

Correct?
Re: Override validateConfigurationParameters in binding to check config? [message #1776036 is a reply to message #1776034] Thu, 09 November 2017 14:33 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

Hm, is this part of https://www.eclipse.org/forums/index.php/t/1089703/ ?
@kaikreuzer I am not sure if understand your answer correctly, shouldn't this also check max?

[Updated on: Thu, 09 November 2017 14:34]

Report message to a moderator

Re: Override validateConfigurationParameters in binding to check config? [message #1776130 is a reply to message #1776036] Sun, 12 November 2017 22:47 Go to previous messageGo to next message
Hilbrand Bouwkamp is currently offline Hilbrand BouwkampFriend
Messages: 5
Registered: October 2017
Junior Member
It's somewhat related to the other topic. But this question is specific if it's a good idea to use this method to override and add additional checks not related to the parameter configuration. While the javadoc of the method refers, as you mention, to check if it matches the parameter that can be read as to only check on those conditions, it is a protected method. That would suggest it's designed to be overridden.

Re: Override validateConfigurationParameters in binding to check config? [message #1776793 is a reply to message #1776130] Tue, 21 November 2017 16:23 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
It is a fair question and I actually do not have a good answer - I think the architecture is not really clean here.
"validateConfigurationParameters" looks indeed like the best place to check the configuration (and yes, it is meant to be overwritten), so it could be called in general from "initialize" as well.
Unfortunately, its defined to throw a ConfigValidationException, which should not be thrown from initialize, so it makes the handling in there a bit ugly.
Re: Override validateConfigurationParameters in binding to check config? [message #1782742 is a reply to message #1776793] Wed, 28 February 2018 19:00 Go to previous message
Flavio Costa is currently offline Flavio CostaFriend
Messages: 23
Registered: February 2018
Junior Member
validateConfigurationParameters() seems to be currently used on BaseThingHandler to validate the configuration before it is updated (stored) after being changed. It is not intended to validate the configuration during initialization.

The JavaDoc of the class being used on the actual configuration matching further clarifies that the method is not to be used against freshly loaded configuration:
"So it can be used as a static pre-validation to avoid that the configuration of an entity is updated with parameters which do not match with the declarations in the configuration description."

As stated above, configuration problems during initialization are not expected to throw exceptions, which is consistent with the understanding that validateConfigurationParameters() normally should not be called on initialize().
Previous Topic:Data storage and visualization with SmartHome
Next Topic:New Build on Ubuntu 16.04 - Web services not loading
Goto Forum:
  


Current Time: Fri Mar 29 11:02:35 GMT 2024

Powered by FUDForum. Page generated in 0.05849 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top