Jakub, thanks for the info,
It looks like in order to use the validator at design time, we will
first need to implement a
design time version of the abstract model. I haven't kept up with the
resource model, but I remember that it was designed around java reflection.
Is it still the case? For NB, since we are working with source files,
java reflection information is not available.
Peter
Jakub Podlesak wrote:
> Hi all,
>
> There is validation of resource models implemented in
> [com.sun.ws.rest.impl.modelapi.validation].
> A very basic validation currently being invoked
> before runtime resource models get created is
> placed in
> [com.sun.ws.rest.impl.modelapi.validation.BasicValidator].
> People can implement their own validators by extending
> [com.sun.ws.rest.impl.modelapi.validation.BasicValidator.AbstractModelValidator]
>
> The idea is, that a validator checks resources and
> keeps a list of all issues found. Issues could be fatal or just warnings.
>
> The way how to validate a resource would be:
>
> // create a validator:
> BasicValidator validator = new BasicValidator();
> // validate resources:
> validator.validate(abstractResource1);
> validator.validate(abstractResource2);
> //process issues found by iterating over
> validator.getIssueList();
> //clean the list if you want to reuse the validator:
> validator.cleanIssueList();
>
> It would be nice if people could review currently checked
> issues and provide feedback (suggest another issues to be checked).
> Also a feedback on a way of validation invocation would be nice.
>
> Current issues being checked (a list of sample error messages) follows:
>
> ERROR: A HTTP GET method, public void com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResourceARM.getMethod(), MUST return a non-void type.
> ERROR: A sub-resource locator, public void com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResourceSRL.subResLocator(), MUST return a non-void type.
> ERROR: A sub-resource locator, public void com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResourceSRL.subResLocator(), has an invalid URI path: null
> ERROR: A HTTP GET method, public void com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResourceASRM.subResMethod(), MUST return a non-void type.
> ERROR: A sub-resource method, public void com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResourceASRM.subResMethod(), has an invalid URI path: null
> WARNING: A resource class, class com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResource, does not have any resource method, sub-resource method, or sub-resource locator.
> ERROR: A root resource class, class com.sun.ws.rest.impl.modelapi.validation.BasicValidatorTest$TestResource, has an invalid URI path: UriPathValue(null).
>
> Thanks,
>
> ~Jakub
>
>