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
--
Jakub Podlesak
http://blogs.sun.com/japod