-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate @Context annotations #639
Comments
@ggam isn't that replacement already available in the form of |
@arjantijms I'm actually with you. I think This issue is just to trigger the needed discussions to make it happen as soon as possible. For me that would be 2.2, but we need to get @path as a bean defining annotation (perhaps via a |
Thanks @ggam I'm not really sure that there is much consensus that 2.2 is too early, especially when we have no idea yet when we're even able to release a 2.2. Having The reason why I'm pushing this a little is that I've seen how always thinking that it's too early has delayed this by many years in JSF. The native managed beans could already have been replaced by CDI in JSF 2.0 (2009), and when that window of opportunity was missed surely in JSF 2.2 (2013). But people kept being afraid that it was "too soon", meanwhile causing quite a bit of confusion. I'm fairly sure that if I didn't finally deprecate managed beans in JSF 2.3, they still wouldn't be deprecated today. Although I think |
The point with 2.2 is that CDI is optional still in that release. If you want to deprecate |
The idea is to have In that case, of course, CDI MUST be supported by the implementations. User code however that doesn't use CDI (yet) can still run unchanged, as
|
I totally agree with you. In the last days of 2.1 I researched myself a bit
but I couldn't find a way to *portably* get @path beans scanned by an
extension.
It is done in WildFly via propietary APIs. It's not the best solution and
it wasn't received with too much enthusiasm when I proposed it dor 2.1, but
would be a transitory solution. I opened a CDI issue related to this some
time ago: https://issues.jboss.org/browse/CDI-701
Provided that we find a way to get resources automatically detected as CDI
beans, I think we can deprecate the old DI on 2.2.
El lun., 23 jul. 2018 20:42, Arjan Tijms <[email protected]>
escribió:
… Thanks @ggam <https://github.com/ggam>
I'm not really sure that there is much consensus that 2.2 is too early,
especially when we have no idea yet when we're even able to release a 2.2.
Having @path being bean defining or effectively causing beans with that
annotation to be scanned is more of a nice to have than a big requirement
IMHO. Might be worth it though to double check how this is done in the MVC
spec with @chkal <https://github.com/chkal>.
The reason why I'm pushing this a little is that I've seen how always
thinking that it's too early has delayed this by many years in JSF. The
native managed beans could already have been replaced by CDI in JSF 2.0
(2009), and when that window of opportunity was missed surely in JSF 2.2
(2013). But people kept being afraid that it was "too soon", meanwhile
causing quite a bit of confusion. I'm fairly sure that if I didn't finally
deprecate managed beans in JSF 2.3, they still wouldn't be deprecated today.
Although I think @path doesn't have to be bean defining for a 2.2
release, it might be quite doable to have beans with the @path annotation
scanned by making use of a CDI extension, or indeed a stereo type.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#639 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACAucHDNeYY_JWzgx0TZuDew5XI6ZMXXks5uJhkKgaJpZM4VaZg2>
.
|
While I remember this discussion and do like the idea, IIRC so far we did *not officially vote* that 2.2 will make CDI mandatory to vendors (I might be wrong, then please post link to the outcome). So if you want to follow that plan (which I second), please set up an official vote, so we have confidence. Please also clearly include in the voting request whether you mean CDI 1, CDI 2, or CDI 2 + SeContainer.
…-Markus
From: Arjan Tijms [mailto:[email protected]]
Sent: Montag, 23. Juli 2018 22:09
To: eclipse-ee4j/jaxrs-api
Cc: Markus KARG; Comment
Subject: Re: [eclipse-ee4j/jaxrs-api] Deprecate @context annotations (#639)
The idea is to have @context formally deprecated by actually putting an @deprecated annotation on it, and then using an @deprecated annotation in Javadoc pointing to the usage of CDI.
In that case, of course, CDI MUST be supported by the implementations. User code however that doesn't use CDI (yet) can still run unchanged, as @context, even though being deprecated still works.
@context can then be actually removed (pruned) in 3.0.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#639 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/ABn3t7cjvtteBFrazq1SHZQWNp_BGq5dks5uJi1FgaJpZM4VaZg2> . <https://github.com/notifications/beacon/ABn3tw1nPuD11y3AAHcKoXIHJh_dXdUeks5uJi1FgaJpZM4VaZg2.gif>
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/eclipse-ee4j/jaxrs-api","title":"eclipse-ee4j/jaxrs-api","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/eclipse-ee4j/jaxrs-api"}},"updates":{"snippets":[{"icon":"PERSON","message":"@arjantijms in #639: The idea is to have `@Context` formally deprecated by actually putting an `@Deprecated` annotation on it, and then using an `@deprecated` annotation in Javadoc pointing to the usage of CDI.\r\n\r\nIn that case, of course, CDI *MUST* be supported by the implementations. User code however that doesn't use CDI (yet) can still run unchanged, as `@Context`, even though being deprecated still works.\r\n\r\n`@Context` can then be actually removed (pruned) in 3.0."}],"action":{"name":"View Issue","url":"#639 (comment)"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "#639 (comment)", "url": "#639 (comment)", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [eclipse-ee4j/jaxrs-api] Deprecate @context annotations (#639)", "sections": [ { "text": "", "activityTitle": "**Arjan Tijms**", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@arjantijms", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"eclipse-ee4j/jaxrs-api\",\n\"issueId\": 639,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"eclipse-ee4j/jaxrs-api\",\n\"issueId\": 639\n}" }, { "targets": [ { "os": "default", "uri": "#639 (comment)" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 359241782\n}" } ], "themeColor": "26292E" } ]
|
While I understand your dreams and hopes (which I do share), just voting for a plan does not make it fulfilled in short term: You still need vendors willing to fill in human resources into that project in short term. Otherwise you would still need to wait. And so far I have not heared officially in this forum that any vendor agreed to our CDI-mandatory-for-vendors idea. So just +1'ing on the API project does not change much, unfortunately.
|
We had some earlier discussions about this already. Even if we assume that all implementations support CDI (as stated in the spec today), the transition from As I argued before, we need to have a recipe that explains how to transition from one DI to another, and this is more than a simple annotation replacement:
And there's likely more. |
vs
Am I the only one who sees some potentially conflicting statements there? If they're not conflicting, please explain ;) It's not a bad idea to start a vote about this. Anyway, Payara, which uses Jersey, and to which we contribute, is in favour of CDI support in JAX-RS. If I'm not mistaken we have mentioned this before. There's not that much for Jersey to change there anyway, as it supports CDI already today. |
I agree, so it's a case of carefully analysing each of those. There's a few things I'm sure we can do regardless, even when we ultimately decide not to use the For instance, saying that implementations MUST support CDI is quite close to what the spec already asks. I have to look up the exact wording, maybe it's even already fine as it is. Adding built-in beans for JAX-RS types like UriInfo, SecurityContext is probably quite doable and doesn't break anything else. It would just mean that one can use either |
@arjantijms What I wanted to tell with that statements is that I would be happy to have an official vote resulting in the fact that the majority of the committers wants to make CDI mandatory in 3.0, but that we have to understand that still all vendors have to implement CDI if not done already. For Jersey, CDI is done in part (not completely: at least not for the standalone server backends but only for the containers like used in Payara; and you cannot use an already existing |
I agree, but this issue discusses explicitly |
@arjantijms I think rather than creating more issues, and then having these isolated discussions started again, we should create a wiki and analyze all the |
@arjantijms Maybe you simply like to open a PR that shows us how easy and safe all your ideas fit into JAX-RS 2.2? So we know exactly what you do propose. BTW, the exact words of the spec are: |
It's true that we don't want too many isolated discussions where the same things are repeated. Definitely +1 for that. On the other hand, there's the well known divide and conquer tactics, which of course everyone here knows about it. Fully deprecating I'll start an initial wiki page then based on your list presented here, and will update that with some of discussions we already had about it. |
Great, thanks! Until then, I assume we will keep my initial setting that this issue has to stay with 3.0 and cannot be done earlier, just as I said from the start. ;-) |
A PR for CDI injectable beans which are owned by JAX-RS (so that they don't need a qualifier), probably doesn't have much or any API surface, and I assume it will be mostly an implementation thing (with just a mention in the spec document, see for example how the CDI core spec defines that |
@arjantijms Sad but true, this one more proofs that Oracle & EF really have to find an agreement soon regarding the spec documents. We simple need them ASAP. |
@arjantijms @spericas +1 on creating the wiki page to deal with all @context usecases, thanks |
AFAIK, the Eclipse Foundation has a process that recommends a release once per 3 months (did not check). Should the 2.2 release take place in autumn and 3.0 in mid 19, I see a room for 1 - 2 additional JAXRS releases that can actually deprecate @context (at that time the impls can have both @context and @Inject working). I do not see an urge to do so in 2.2. |
Given that we indeed go for 1 or 2 additional releases (say 2.3, 2.4), then I agree and we can do it in 2.3 if needed. My main point is we can start working on it now, and whether it will be included in 2.2 or 2.3 is another question. I don't see much need to wait (e.g. until 3.0) just for the sake of waiting, especially if it's not clear what we'd be exactly waiting for. |
Yes, you can start working on it now, and depending on when it is finished and how much breaking it really is we can decide then into which development stream (next major or next minor) we have to merge it. Until then, the only realistic option is to deprecate in 3.0. Hence, again, this issue #639) has to be on hold for the time being. |
Last time I checked, CDI did not support injecting in method parameters, where |
Sorry I just now realised that was discussed already here and in #569. My personal opinion is that method param injection alone is a good reason to keep As an added benefit we have with |
There’s no reason to keep @context for method parameter injection, and also no reason to switch to field injection when using CDI. The JAX-RS runtime can easily inject values into a method using CDI, as explained before. |
Well, yes we can do the injection ourselves for method parameters, but I'm not sure we can do async injection for fields anymore if CDI is in charge. I'd have to check that. |
But how often does one uses an entity manager in the The injection of just the entity manager doesn't do anything yet. It's a very lightweight object. For example:
When you're doing It depends on whether |
The injection itself would rarely be blocking. Only if it was a dependent scoped bean, that performs logic involving an (external) other system in its |
So if it does not depend on the spec, you can just use the same RESTEasy internals for it that |
@ggam yes, except that CDI would have to change API to support it: it couldn't be doing |
@arjantijms in the reactive world there are lots of things you want injected that might actually block (anything that might hit the network).
It works right now, but only if you don't remove |
I understand, but what I mean is that during injection it would be awkward at best if a dependency would start hitting the network. There's really only two things potentially executed when a dependent s scoped dependency is injected during injection time; the constructor and the Accessing the network from those methods is not super common I think (of course, it's possible). But, injecting dependent scoped objects themselves is already relatively rare. If you inject normal scoped, there's nothing executed during injection time at all, as you get a lightweight proxy. The resources that such dependency uses are typically prepared way upfront. E.g. connection are allocated during startup of the server and put into a connection pool. I do see why you'd want to have an instance injected that has eagerly resolved all of its potentially heavyweight (custom) dependencies, but as I mentioned, constantly eagerly instantiating has its costs too if the dependency is not always actually used. |
Well, true, but at some point the proxied will need to instantiate its
proxied value.
You are right about the EntityManager example and indeed you don't usually
inject a db connection, but a DataSource from which you get and release a
collection only when you need it. That example wasn't so good.
But you can easily inject a config property that tries to get a value from
an external server and after failling, falls back to the db. Injection
won't block as it will only create the proxy, but at some point your code
will try to get the value from that proxy and the blocking connections will
need to be done.
If you need to inject a "User" bean in a stateless service which doesn't
have a session, such injection will probably need to hit the db or even
another microservice handling the user details.
Perhaps injection time is not the moment for it, but proxied objet
construction time. But I think there are valid usecases (more related to
CDI than JAX-RS in particular, which will only handle injection of a few
objects).
El vie., 12 oct. 2018 16:39, Arjan Tijms <[email protected]>
escribió:
… So this is really about treating CompletionStage producers in CDI in a
special way in order to do non blocking injection, and not about JAX-RS
producing an async response.
The injection itself would rarely be blocking. Only if it was a dependent
scoped bean, that performs logic involving an (external) other system in
its @PostConstruct method would that happen.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#639 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACAucJDByO7l9eiAsatSbj8mShUfkvzQks5ukKmngaJpZM4VaZg2>
.
|
It's rare to hit the network during construction, but what about @produces?
It can be done exactly for such dynamic cases. Still a lightweight proxy
will be injected, but before using it, the producer code will need to be
invoked. I personally don't consider producers with network dependencies a
bad practice.
El vie., 12 oct. 2018 16:50, Arjan Tijms <[email protected]>
escribió:
… in the reactive world there are lots of things you want injected that
might actually block (anything that might hit the network).
I understand, but what I mean is that during injection it would be awkward
at best if a dependency would start hitting the network. There's really
only two things potentially executed when a dependent s scoped dependency
is injected during injection time; the constructor and the @PostConstruct
method.
Accessing the network from those methods is not super common I think (of
course, it's possible).
But, injecting dependent scoped objects themselves is already relatively
rare. If you inject normal scoped, there's nothing executed during
injection time at all, as you get a lightweight proxy.
The resources that such dependency uses are typically prepared way
upfront. E.g. connection are allocated during startup of the server and put
into a connection pool.
I do see why you'd want to have an instance injected that has eagerly
resolved all of its potentially heavyweight (custom) dependencies, but as I
mentioned, constantly eagerly instantiating has its costs too if the
dependency is not always actually used.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#639 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACAucHCbqBIfC9w3c_WIgWhf38ydpoaUks5ukKxKgaJpZM4VaZg2>
.
|
Right, understood.
Exactly, and without looking at an example (do you have one?), if feels that the potential code simplification provided by async injection is minimal over the standard JAX-RS 2.1 API. As you said, this is a bit off-topic, but these are the type of discussions that help improve specifications, so definitely worth having them ;) |
Absolutely correct, but then we do come back to the question whether the injected bean will indeed be used. Just an example:
In that case, you will not always actually hit the Potentially a lot of work. If you use a dependency all the time, or most of the time it could be worth it. If not, it's a wasted effort. |
Instead of trying to convince us to keep |
Agreed. But if object construction is now done only when the proxy is first
used, wouldn't that work still in this non blocking way?
You get an empty proxy and once you try to use if, its CompletionStage is
used to create it asyncronously.
That's different from what @formage has explained, as it misses the
opportunity to create all objects on the same pipeline, and has the
potential outcome of going to another thread a lot of times. But as you
also said, it's not so common to inject network dependent objects so this
would only affect the few arfitacts you are wrapping on a CompletionStage.
El vie., 12 oct. 2018 18:02, Arjan Tijms <[email protected]>
escribió:
… but before using it, the producer code will need to be
invoked. I personally don't consider producers with network dependencies a
bad practice.
Absolutely correct, but then we do come back to the question whether the
injected bean will indeed be used.
Just an example:
@RequestScoped
public void SomeThing {
@Inject
UserService service;
public void persistUser(SomeParam param) {
if (param == ... && foo == ...) {
service.persist(...);
}
}
}
In that case, you will not always actually hit the UserService. So in the
example of FroMage, SomeThing would be asynchronously instantiated, and
all its dependencies, which is UserService here cascade into being
asynchronously instantiated as well, and its dependencies too, etc.
Potentially a lot of work.
If you use a dependency all the time, or most of the time it could be
worth it. If not, it's a wasted effort.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#639 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACAucONMDzuZ3xXcLNTqW0o1NuxHGUvyks5ukL0MgaJpZM4VaZg2>
.
|
Our usage samples reveal that method-injection (of async types) helped a lot for readability for methods where those async types where always used, especially when there were several of them. |
That's also an effort underway, but I had to point out that until this is resolved in CDI, |
Show us the samples!! :-) |
I just wanted to share an interesting discussion about the JAX-RS <-> CDI integration from the MicroProfile mailing list. Especially, because it lists some important edge cases. |
Hi All, Related (only partially) to the topic of async injection, would we need some sort of CDI thread context propagation mechanism? I bring this up due to some discussion in the MP Concurrency about whether they should support JAX-RS specific thread context propagation, or just rely on CDI propagation - see here for more details of the MP discussion. I envision a scenario like this:
If we assume that HttpHeaders is request scoped, then this works just fine for synchronous resource methods (we get the header value for the request), but what about asynchronous methods like the above? The call to HttpHeaders is on another thread, so CDI won't know that it is associated with the same request from the initial thread. Today Thanks, Andy |
Thanks for bringing this up @andymc12. Clearly, all this works fine in the synchronous case. For async, I see two separate cases: the If the JAX-RS implementation does not manage the executor service, then I don't see how the code above would work even if you use If the JAX-RS implementation does manage the executor service, then it can make sure the original "request scope" is available when the new thread runs, and a similar mechanism would be required for CDI --this is all handwavy, there may be difficult technical details that need to be resolved for this to happen. |
@andymc12 note that using MP-Context-Propagation (formerly MP-Concurrency) this works with RESTEasy because it defines a |
Lots of interesting discussions here, but the original purpose of the issue was about deprecation of |
Once we have a complete CDI replacement for
@Context
annotations (tentatively on 3.0), they should be deprecated as a first step before removal on a later release.The text was updated successfully, but these errors were encountered: