Re: Providers ordering


Guillermo González de Agüero
 

Hi,

On Sun, May 21, 2017 at 11:03 AM, Pavel Bucek <pavel.bucek@...> wrote:

Hi Christian,

see chapter 4.2.4:

An implementation MUST support application-provided entity providers and MUST use those in preference to its own pre-packaged providers when either could handle the same request. More precisely, step 4 in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer application-provided over pre-packaged entity providers.

Which i s the base of what I mentioned - there is one issue though - this is only about entity providers, not about ExceptionMappers, which are covered by chapter 4.3.

I believe we could include more general statement in chapter 4, which would say that application provided Providers have priority over build-ins (and maybe define what build-in is) OR we can say that implementation providers should have some concrete priority set - which could be simpler than formally defining built-in provider.

I was writing to propose exactly that. That's be the more flexible approach, and would resolve my open question about what exactly is a built-in provider (https://github.com/jax-rs/api/issues/537#issuecomment-302853229).


Santiago, others, what do you think?

Thanks,
Pavel


On 21/05/2017 10:48, Christian Kaltepoth wrote:
Hi everyone,

I'm very happy to see that the issue of provider ordering is addressed in the upcoming JAX-RS release. Thanks a lot for your work on that.

I would like to point the EG to a discussion from one of the issues which was about whether the priority ordering should be used only for "custom providers" or for all providers (custom and built-in providers). See [1] for details. During the discussion Pavel mentioned that JAX-RS already mandates that custom providers are preferred over built-in providers. I didn't find this anywhere in the spec document, but maybe I just missed it.

The one thing that still makes me think that the priority ordering should be used for all providers is that the definition of "built-in provider" is a bit blurry. What is a built-in provider? What about providers which are deployed as app server modules and therefore are provided out of the box by the container? Are they built-in or custom providers? Perhaps this should simply be clarified in the spec?

I would be happy to hear about other opinions.

Christian













2017-05-19 14:08 GMT+02:00 Pavel Bucek <pavel.bucek@...>:

Dear experts,

there is couple of filed issues related to provider ordering, namely:

https://github.com/jax-rs/api/issues/538
https://github.com/jax-rs/api/issues/537

We already do have them implemented in the RI and we discovered that we can do similar things for almost all providers (including readers/writers, ..), which don't have already defined @Priority handling (filters and interceptors do have that already).

For these providers, lover priority value means higher priority. For example, if you have following ExceptionMappers:

then "MySecondExceptionMapper" will be invoked when "MyException" is thrown.

@Provider
@Priority(300)
public static class MyFirstExceptionMapper implements ExceptionMapper<MyException> {
    // ...}

@Provider
@Priority(100)
public static class MySecondExceptionMapper implements ExceptionMapper<MyException> {
    // ...

}

@Provider
@Priority(200)
public static class MyThirdExceptionMapper implements ExceptionMapper<MyException> {
    // ...

}

Do you have any comments or suggestions before we incorporate that change into the spec document?

Thanks and regards, Pavel




--



Regards,

Guillermo González de Agüero.

Join jaxrs-spec@javaee.groups.io to automatically receive all group messages.