Welcome to the Jazz Community Forum
Cannot use inner class as configuration properties validator class

Using an inner class:
public class ScheduledTask extends AbstractAutoScheduledTask {
[...]
public class ConfigurationPropertyValidator extends AbstractConfigurationPropertyValidator {
[...]
}
}
as validator class for configuration properties:
<prerequisites> <configurationProperties validatorClass="ScheduledTask$ConfigurationPropertyValidator"> [...]
throws a class instantiation exception:
java.lang.InstantiationException: ScheduledTask$ConfigurationPropertyValidator
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1558)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
at com.ibm.team.repository.service.internal.registry.ClientLocalizingRegistryStrategy.createExecutableExtension(ClientLocalizingRegistryStrategy.java:56)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.service.internal.registry.ClientLocalizingConfigurationElement.createExecutableExtension(ClientLocalizingConfigurationElement.java:137)
at com.ibm.team.repository.common.transport.AbstractElementDescriptor.createInstance(AbstractElementDescriptor.java:254)
at com.ibm.team.repository.common.transport.internal.registry.ConfigurationPropertiesElementDescriptor.createValidatorInstance(ConfigurationPropertiesElementDescriptor.java:41)
... 174 more
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.
at com.ibm.team.repository.service.AbstractService.getService(AbstractService.java:788)
at ScheduledTask.validateProperties(ScheduledTask.java:202)
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!)
IContributorService contributorService = (IContributorService) services.get(IContributorService.class.getName());
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:
- Validator Class - implementation of the validator
- plugin.xml - contains the plugin definition including the requiredService declaration and the validator class usage
- MANIFEST.MF - ensure that you have imported all required packages
Depending on your needs, you might implement IConfigurationPropertyValidator instead of extending AbstractConfigurationPropertyValidator.

Defining IContributorService as a required interface is the way to go if you are working with IContributor related data.
Yep, we need it to validate a property which have to contain user ID.
Depending on your needs, you might implement IConfigurationPropertyValidator instead of extending AbstractConfigurationPropertyValidator.
We already tried to implement IConfigurationPropertyValidator on the same class of our scheduled task; citing:
If outer class simply implements the configuration properties validator interface, then methods cannot use services [...]
Do you mean we could implement IConfigurationPropertyValidator instead of exteding AbstractConfigurationPropertyValidator on the inner class?
Have a look at our Secure User Property Store on GitHub which is also using a validator 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.