Re: Providers ordering
Santiago Pericas-Geertsen
I agree. Naturally, user-defined providers should take precedence over built-in ones. Clearly, this statement is implicit rather than explicit and should be clarified —at least for some providers. That was always the intent. As for what is user-defined vs. built-in, I don’t thing that is hard to define: if it is registered using the JAX-RS API or discovered via class scanning (i.e. annotated with @Provider), then it is user-defined regardless of their physical location (library, container, etc.). Built-in ones should not be made available using those mechanisms. — Santiago
|
|
Re: Returning CompletionStage from the resource method
Pavel Bucek
Hi Sergey, ad 1) the response processing will be done on the caller (completer) thread (so, completionStage#whenComplete(..), not #whenCompleteAsync(..)), simply because it works in a same way as when using AsyncResponse. ad 2) good idea. I'm not sure whether we'll be able to do that now, but could you please file an issue? https://github.com/jax-rs/api/issues Thanks,
On 21/05/2017 13:47, Sergey Beryozkin
wrote:
|
|
Re: Built-in proxy support in Client API?
Hi Pavel, I don't want to hijack the topic, I'm just saying that we can handle both cases in a common way. Regards
|
|
Re: Built-in proxy support in Client API?
Pavel Bucek
Hi Dennis, thanks for the pull request; please don't hijack the topic - this
one is about client proxy support. Feel free to start a new
thread. Regards,
On 21/05/2017 11:05, Dennis Kieselhorst
wrote:
|
|
Re: Providers ordering
Sergey Beryozkin
Hi Christian
On 21/05/17 18:22, Christian Kaltepoth wrote: Thanks too, I agree using @Priority is a viable option. But as I implied earlier, this approach (apart from solving the issue shown with MVC vs custom CSRF mapper) raises the question - why to support two ExceptionMapper<MyObject> or ParamConverters in general. Perhaps it does not really matter, but I guess we'd like to avoid supporting the solutions where the developers will start thinking about dropping 3 ExceptionMapper<MyObject>, and ordering them 1, 2, 3 and making each of them, say, 1 and 2, not to map, for 3 to do the final mapping :-). That said, may be this example is hypothetical, and using @Priority just works, though I thought I'd suggest a 'default mapper' around javax.* idea too... Thanks, Sergey
|
|
Re: Providers ordering
Sergey Beryozkin
Continuing with the idea of the special
treatment of the providers shipped with the spec implementations. Rather than pursue a @DefaultProvider idea, how about treating the providers in the javax.* namespace as 'default' ones ? Thus if say an MVC API ships its own CSRF exception mapper then it will be selected, unless the application has registered its own. Moreover, perhaps this idea and the idea of using @Priority are not mutually exclusive. IMHO the former puts less 'pressure' on the application providers to make it right... Sergey
On 21/05/17 16:19, Sergey Beryozkin wrote:
|
|
Re: Providers ordering
Hey Sergey, thanks for your quick reply.
Yes, exactly. In this case JAX-RS currently doesn't specify which one should be used.
Not sure if something like @DefaultProvider is flexible enough. Maybe this "default provider" vs "custom provider" use case is just one special case? I mean, it is always possible to have multiple exception mappers on the classpath if they are provided by different libraries. And in this case it would be nice to have some clear rules on how to handle this situation.
For filters and interceptors there is already javax.ws.rs.Priorities which contains constants which can be used for ordering. So this could also be used for exception mappers and param providers.
That wouldn't be a problem, because MVC will go final after JAX-RS and therefore could depend on JAX-RS 2.1. Best regards Christian
|
|
Re: Providers ordering
Sergey Beryozkin
Hi Christian Right, do you mean that both of these providers are custom as far as the JAX-RS implementation is concerned ? Sure, I see what you mean now. I guess my only doubt at this stage is, should the providers offered by MVC implementation (or some other *spec-implementaion* API) have a special treatment status, as far as JAX-RS is concerned ? Example, be annotated with some @DefaultProvider annotation (to be introduced in JAX-RS) ? In this case JAX-RS, seeing two MyObject exception mappers, will select the one which has no @DefaultProvider. May be using @Priority is simpler, but it would require application mappers to know how to set their own @Priority to ensure it is high or low enough. The problem with @DefaultProvider is that it is probably too late as ex MVC API would need updated after 2.1 is out. Cheers. Sergey
On 21/05/17 15:58, Christian Kaltepoth wrote:
|
|
Re: Providers ordering
Hi Sergey,
Of course nobody will want to create two ExceptionMapper<MyObject> implementations in his application. It is more about the case that some framework provides a "default" exception mapper for a specific exception type and the developer should still be able to provide a custom one which is preferred by the JAX-RS implementation. We had this case in JSR-371 (MVC 1.0): If the validation of a CSRF token fails, the MVC implementation throws a CsrfValidationException. The MVC implementation provides a default mapper ExceptionMapper<CsrfValidationException> which just sends a 403 status code. But the developer should be able to provide a custom exception mapper which does something else, like rendering some HTML page. However, this is currently not possible, because if there are two ExceptionMapper<CsrfValidationException> implementations discovered, there is no way to tell the JAX-RS implementation which one to choose. Christian
|
|
Re: Returning CompletionStage from the resource method
Sergey Beryozkin
Hi Pavel I'd leave it up to the implementation to decide. The other thing I was thinking about. On the client side we have RxInvoker which supports not only CompletableFuture. Should we have something like RxResponse such that not only CompletableFuture is supported ? Thanks, Sergey
|
|
Re: Providers ordering
Sergey Beryozkin
Hi Pavel Not sure it is relevant but it is not exactly the case with MessageBodyReader/Writers where the custom providers can still lose to built-in providers. By the way, what is the actual point of ordering say 2 ExceptionMapper<MyObject> - would it go a bit too far without bringing any real benefit ? Thanks Sergey
On 21/05/17 10:03, Pavel Bucek wrote:
|
|
Re: Providers ordering
Hey Pavel, thanks a lot for your quick reply.
Thanks a lot for pointing me to section 4.2.4. But as you already wrote the current version of this statement just covers entity providers.
I would be fine with both options as both would fix the problem I mentioned. Although I think the latter one would should be preferred because it is much simpler. Best regards Christian
|
|
Re: Built-in proxy support in Client API?
Hi, in my view there should be at least standardized constants for the properties in 2.1. I created a PR for the timeout stuff yesterday: https://github.com/jax-rs/api/pull/555 These properties can be used by convenience methods in ClientBuilder. I can also create a PR for the proxy constants if the solution is agreed. Regards Dennis
|
|
Re: Providers ordering
Guillermo González de Agüero
Hi, On Sun, May 21, 2017 at 11:03 AM, Pavel Bucek <pavel.bucek@...> wrote:
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).
Regards, Guillermo González de Agüero.
|
|
Re: Providers ordering
Pavel Bucek
Hi Christian, see chapter 4.2.4:
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. Santiago, others, what do you think? Thanks, On 21/05/2017 10:48, Christian
Kaltepoth wrote:
|
|
Re: Providers ordering
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@...>:
--
|
|
Built-in proxy support in Client API?
Andy McCright
Hi all,
It might be too late to add this (if so, no worries), but I've been running into a few customer situations where customers are using HTTP/HTTPS proxy servers with their JAX-RS client APIs. Today, proxy support is enabled, but requires vendor-specific properties. Would it make sense to add some methods to ClientBuilder/Client/Configurable like proxyHost(String), proxyPort(int), proxyBasicAuth(String user, byte[] password), etc.?
Here is a relevant issue where this was previously discussed: https://github.com/jax-rs/api/issues/497
Thanks,
Andy
J. Andrew McCright IBM WebSphere Development +1 507 253 7448 TL 553-7448 andymc@...
|
|
Re: Providers ordering
Guillermo González de Agüero
Hi,
toggle quoted messageShow quoted text
Have you considered how this will behave when the provider is a CDI @Alternative or @Stereotype? I'm unsure how much those could interfere but I think it's something to take into account nonetheless, specially since improved CDI integration is already planned [1]. Regards, Guillermo González de Agüero
El vie., 19 de mayo de 2017 14:04, Pavel Bucek <pavel.bucek@...> escribió:
|
|
Returning CompletionStage from the resource method
Pavel Bucek
Dear experts,
as we already stated, we'd like to support returning CompletionStage from the resource mehod, corresponding spec issue is here: https://github.com/jax-rs/api/issues/551 The only open issue is related to the thread on which the response will be processed (on which will be the "whenComplete" callback invoked"). Markus suggests that it could/should be done on servlet provided thread/executor, but there is no facility which would give as such thread. The case mentioned in the issue comment won't work, because "whenComplete" would be invoked on the thread which completed the CompletionStage (i.e.: there is no magic which would get back the thread, which was already handled over back to the servlet container). We could leave it like that (the application would need to have some thread which will complete the stage anyway) or we can say that container managed thread will be used, if available. Please let us know if you have any suggestions or comments. Thanks and regards, Pavel
|
|
Providers ordering
Pavel Bucek
Dear experts, there is couple of filed issues related to provider ordering, namely: https://github.com/jax-rs/api/issues/538 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
|
|