Cannot use inner class as configuration properties validator class
Using an inner class:
public class ScheduledTask extends AbstractAutoScheduledTask {
as validator class for configuration properties:
<prerequisites> <configurationProperties validatorClass="ScheduledTask$ConfigurationPropertyValidator"> [...] throws a class instantiation exception: java.lang.InstantiationException: ScheduledTask$ConfigurationPropertyValidator
If outer class simply implements the configuration properties validator interface, then methods cannot use services due to:
com.ibm.team.repository.common.transport.internal.registry.ServiceNotFoundException: The service 'ScheduledTask@7d757d75' failed to find the required service 'interface com.ibm.team.repository.common.service.IContributorService'. Check <prerequisites> in plugin.xml.
even if these required services are defined in plugin.xml:
<prerequisites> [...] <requiredService interface="com.ibm.team.repository.common.service.IContributorService" /> </prerequisites>
Thanks in advance.
Cheers.
|
Accepted answer
If outer class simply implements the configuration properties validator interface, then methods cannot use services [...] We figured out we have to implement IConfigurationPropertyValidator2 instead of IConfigurationPropertyValidator if we need services on our validator class. public Map<String, IStatus> validateProperties( Map<String, Object> properties, boolean fast, Map<String, Object> services) {(Nooby mistake since the same approach is required for accessing properties!) Ralph Schoon selected this answer as the correct answer
|
2 other answers
Hi SEC,
Defining IContributorService as a required interface is the way to go if you are working with IContributor related data.
Have a look at our Secure User Property Store on GitHub which is also using a validator class:
Depending on your needs, you might implement IConfigurationPropertyValidator instead of extending AbstractConfigurationPropertyValidator.
|
Yep, we need it to validate a property which have to contain user ID.
We already tried to implement IConfigurationPropertyValidator on the same class of our scheduled task; citing:
Do you mean we could implement IConfigurationPropertyValidator instead of exteding AbstractConfigurationPropertyValidator on the inner class?
We saw the example you linked, but it's a stand-alone class. Instead, we are trying to use an inner class as configuration property validator in our existing class for a scheduled task.
Anyway, thank you Lukas for your answer.
Cheers.
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.