[ 
https://issues.apache.org/jira/browse/SLING-6660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15931704#comment-15931704
 ] 

Konrad Windszus commented on SLING-6660:
----------------------------------------

Although this approach would simplify code within the validator core, it would 
be then more effort to implement a Validator. Especially in the future with 
Mapped Field Injection 
(https://github.com/osgi/design/blob/master/rfcs/rfc0222/rfc-0222-DeclarativeServicesUpdates.pdf,
 3.4) it is less effort to rely on service properties only.

Also I think it makes sense to enforce using service properties for both id and 
severity (to allow to reconfigure those even for existing Validator's). Also 
inspecting both {{id}} and {{severity}} in the web console in the existing 
components plugin is useful during debugging (otherwise a dedicated web console 
plugin would be necessary).

Currently an exception is thrown during binding 
(https://github.com/apache/sling/blob/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationModelRetrieverImpl.java#L198)
 when a validator is found lacking the mandatory service.property.

Not too sure what is the better solution, though. At least for 
{{org.apache.sling.spi.resource.provider.ResourceProvider}} 
(https://github.com/apache/sling/blob/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java)
 it is also required to set some service properties (without exposing those 
values through dedicated methods).

I would be interested to hear the opinion of [~cziegeler] on this one.


> Validators should expose their id and severity
> ----------------------------------------------
>
>                 Key: SLING-6660
>                 URL: https://issues.apache.org/jira/browse/SLING-6660
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions, Validation
>            Reporter: Oliver Lietz
>
> {{Validator}}s should expose their {{id}} and {{severity}} (maybe from 
> service properties, but haven't to be service properties at all) by their own:
> {noformat}
> [...]
> public interface Validator <T> {
> [...]
>     String getId(); // validator.id
>     int getSeverity(); // validator.severity
> [...]
> }
> {noformat}
> This addition allows less code in {{ValidationModelRetrieverImpl}} and makes 
> {{ValidatorAndSeverity}} obsolete.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to