sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Lietz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SLING-6660) Validators should expose their id and severity
Date Mon, 20 Mar 2017 14:38:41 GMT

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

Oliver Lietz commented on SLING-6660:
-------------------------------------

bq. Because that way this information is duplicated. Even if we move the logic of exposing
ID and severity from the service property into an abstract class, a Validator could decide
to overwrite those methods or not derive from the abstract class at all. That is something
I want to prevent, because that would prevent overwriting those values and also does not allow
to easily debug those values (via the web console).

There is no need to duplicate, you can delegate easily:

{noformat}
    @Activate
    private void activate(final ValidatorConfiguration configuration) {
        this.configuration = configuration;
    }
    
    @Override
    public String getId() {
        return configuration.validator_id();
    }
{noformat}

bq. I understand that, but IMHO the code in ValidationModelRetrieverImpl is easy to understand
and pretty straightforward. With OSGi R7 we might even fully rely on field injection. ValidatorAndSeverity
is only used within validation models, therefore all consumers of Sling Validation won't ever
get in contact with that class. Only if you want to implement your own ValidationModelProvider
you need that class.

Then move {{ValidatorAndSeverity}} out of API. But still {{ValidationModelRetrieverImpl}}
is agnostic to runtime modifications of service properties (SLING-6659) – in my opinion
broken and worth a refactoring.

> 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)

Mime
View raw message