-
Notifications
You must be signed in to change notification settings - Fork 77
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
Make CDI Lite optional #648
Comments
Not true - see Jakarta EE Core Profile.
Could you be more specific? Compilation is not a runtime phase.
Basically any portable extension that collects some information and make use of this information at runtime is incompatible. And from my experience, minimum of portable extensions are stateless.
You should be more specific and provide some serious measurement. In any case, it does improve the application startup time significantly because the discovery and dependency resolution happens at build time. We did some experiments and measurements during the early days of Quarkus. And that was the reason why we started to work on a new build-time DI solution and did no reuse Weld. |
So I must understand "not true, you are right"? This link does not help at all any user since it writes "we want to do build time" but it does not define anything to enable it so it does not exists in the spec.
Right but the API is not compilation friendly since it relies on
Nop, you can get a stateful portable extension, while the impl can dump its state. The main diff working from
Please provide numbers comparing
I know but quarkus is a way to achieve it creating a new API, using CDI 2/3 API also enables it and with minimal enhancements (the ones mentionned) you get the same benefit + enable to reuse most of the ecosystem instead of forcing all extension writers to reimplement it twice practically - yes lite makes the ecosystem split in 2 so we now have an umbrella project with 2 subprojects in practise, can't last long IMHO. Since lite is not usable by end user as of today I'd just drop it asap as a requirement and rework the original goal with something not breaking CDI itself. |
"The Core Profile is targeted at developers of modern cloud applications with focus on a minimal set of APIs that support microservices with a focus on enabling implementations that make use of ahead of time complitation build to minimize startup time and memory footprint." That's IMO enough to justify a build-time oriented API in a spec.
I don't understand. What does "compilation friendly" mean?
And this part is not exactly easy. Many existing extensions would be broken anyway because their state does not implement
You're confusing a build time technology (where a JVM instance is the runtime environment of an app) and compilation to a native image.
|
I certainly hope I learn more about them.
How come?
The only thing that's actually new in CDI 4.0 is the built compatible extension API. Are you suggesting to make that optional? I'm game -- I don't know why people care so much about extensions, we could have saved so much time simply by ignoring that part and insisting that Lite has no extension API whatsoever.
Are you implying how the API works based on its package name? If so, you should be fair. The package name is
The The real reason why Full includes the entirety of Lite is coherence. Applications, libraries and extensions written against Lite should work without a change in Full. We had long and fierce discussions about the possibility of Lite-only extensions. That would just create 2 separate CDI worlds that couldn't be bridged.
There is no requirement on a "specific runtime phase" at all. It is perfectly possible to implement CDI Lite in a way that bean discovery and dependency wiring happens solely at build time. There are 2 independent projects that do that and IIUC, they are both relatively close to passing the CDI Lite part of the CDI TCK. In later replies, you allude to the usage of We originally had a
This has been refuted many times. It is not possible to run Portable Extensions at build time because:
Performance is a property of implementation, not specification. You may be fine with spending time on bean discovery and dependency wiring during application startup, but that doesn't mean everyone else is too. |
No, it explains the intent, I agree, but it does not enable to use it. What is the API to use it? What is the
Think you mixed (like in speaking vs writing) compilation and build, compilation means
Well you can store anything in JSON while the extension is responsible of its serialization (
People care about extensions because it is what makes CDI so strong and not just a shortcuts for setters. If you make lite without any extension (ie drop build package) I can envision a real use case and could agree on that, would be a good compromise.
Then you just duplicated the extension API, so does not make sense which is why part of the CDI community asked to not make this package part of the official JakartaEE release.
I understood but you create the inconsistency the other way, there are 2 parallel modes so whatever one onforces the other, it is inconsistent.
Please stop writing that, it works and is used. It has some limitations and context but works as well as the new API.
So no need of a new API?
Once again, as written it is NOT the case with |
@rmannibucau Please show me an example of (A) a build-time CDI implementation and (B) portable extensions that do work with this implementation. Note that I'm not talking about GraalVM native image compilation which is a different use case. |
@mkouba graalvm is more or less the same case, only difference is graalvm enforces you to become build time for part of the process whereas other cases (java) do not require it. Here is an implementation which works like that (with the current extension limitation and depending the app it can require some tuning/extension filtering and event disablement but all comes as toggle in openwebbeans): https://github.com/apache/geronimo-arthur/blob/master/knights/openwebbeans-knight/src/main/java/org/apache/geronimo/arthur/knight/openwebbeans/OpenWebBeansExtension.java. The impl is usable without native image tuning the maven plugin and owb.properties. So yes extension API needs some extension (very light as you saw) and no build package does not solve the goal it had so let's make it an optional part of CDI and work toward a more global and simple solution on the long term 🙏 . |
Well exactly! There you have it. Lite needs an extension API.
See above.
It does make sense, because the "duplicate" has some important properties the original doesn't.
Agree to disagree.
Except they are not parallel. One is a strict subset of the other.
It does not work in general. The approach you present very specifically relies on the ability to snapshot and restore the JVM state (especially the managed heap). This is hardly common on stock JVMs, and even that is not enough for extensions that start threads or open files or sockets. Hopefully, those are rare :-) Your other suggestion to require extension authors to correctly serialize their state is a recipe for disaster frankly (how do you serialize a client proxy to JSON?). The only sane way to write such "build friendly" extensions would be to push most of the state out of the extension instance into synthetic beans and observers. The build compatible extension API makes that the only option.
We certainly do not need a new API for performance. We certainly do need a new API for enabling other architectures of CDI implementations. |
at runtime, at build time people always do what they want, but they care about dynamism at runtime for a lot of apps. But point is lite can leverage runtime API a lot instead of forking it in style.
Well didn't find much in terms of feature for end users. I can see some impl ones but it is leaking an impl in the spec, can't work long otherwise you will end up with a dozens of concurrent API.
Not really, both can work without the other so they are parallel/transversal.
it does as soon as you enable extension to dump/load their state which are 2 methods and not duplicating the full extension API, it got proven multiple times.
Depends the part you need but can be as simple as a
Technically it is 1-1, just an API you prefer maybe but does not enable any use case.
Means you want an implementation to surface in the spec, if so, please make it an implementation specific and not surface in the spec, I have a ton of wish coming from implementations but I don't think you would want most of it cause it is API and library specific at the end. So please, once again, let's make build package optional, enhance extension API to offer a build time API and enhance the extension API to optimize part of it (bulk load instead of per type event for ex, it literally makes the complexity from |
There is so much wrong claims in this thread that I'm not able to catch up even.
Truth is:
|
They could be parallel. They would be if we made the BCExtensions API Lite-only, which we did not.
Quite the opposite. I want the spec to not prevent certain implementation architectures. |
it does, but I don't want the opposite, ie the spec let surface all impl details which is lite api. |
But creating a new framework to program Extensions but trashing the existing variant is maybe not a clever idea because JakartaEE is ALL about investment security in existing code! Basically CDI-lite is NOT CDI but a completely new specification with some very small overlap (mostly JSR-330 with a very little bit of 299 basically) |
Wow, you really think this is really a problem? Good news for you: no, it's not. We've solved this when we wrote CDI-10 already for the JSF use case and clustering. The mechanism is |
@rmannibucau Not really, graalvm native image is a very specific use case because (A) the target runtime is not JVM and (B) the graalvm native image tool takes care of state serialization/deserialization, i.e. makes a snapshot of the JVM state when building the native image. |
In other words, it's not a generic solution at all. |
@mkouba graalvm native-image is 100% about converting bytecode in native format (so to caricature), everything done around (quarkus, arthur, native image agent, ...) is about precomputing at build time (or not) the runtime and just serving it as this at runtime (AOT), this applies to any process including a plain java one. This process is 100% doable with the extension API as soon as you add the dump/load API as mentionned or you assume they are stateless as you mentionned but we don't need any new discovering/enhancing/... API in any cases, we just need a write and reload API. The fact to not create a new API enables the ecosystem to be consistent and unique, the build API created a new framework and ecosystem inconsistent with the existing one as soon as you are not redhat or IBM (no offence, it is more than you own 100% of the stack and write it yourself), it means there is no more diversity in the ecosystem so no more abstraction in practise so no more need of a spec at eclipse jakarta if we keep it like that, don't think it was the intent but it is the direct implication of current spec. Since it is not usable by users and quite easy to fix let's just do it before it is too late. |
You were talking about client proxies. For those the additional rules of |
Java EE/Jakarta EE in general has historically favored profiles over optional features. The reason for this is more deterministic compatibility and portability across certified implementations. If the project decides to go the route of optional features, I suggest getting feedback from the platform project and the specification committee. Profiles also generally require some platform level alignment, so seeking input before really finalizing decisions would be advisable. |
@m-reza-rahman I'd say profiles are quite different and not that adapted there, they enable to flip features but, in EE ecosystem, should stay a pile/stack. Here it is literally building two concurrent frameworks in parallel which diverge/fork so there is no real hope jaxrs can embrace both at some point until it implements both so it means the 20+ specs relying on CDI will need to integrate twice with CDI. |
Did it really? Afair profiles only got introduced in JavaEE 6 (2010). Optional features otoh have been around as early as the first servlet specification. Another good example is XA support in JDO and later JPA. That was 2002-ish? |
I don't see that we would go the route of optional as that has been explicitly called out as no longer desired by the spec committee. |
But got broken in fresh specs just a few weeks later... |
@starksm64 it is fine, ticket can be to "drop" instead of making it optional but as of today spec is 1. inconsistent and 2. unusable due to that so it must be fixed and we are sure there is no adopter as of today since 2 so let's act :). |
I suggest that a more forward looking pursuit is exploring how to supersede and drop the older portable extensions API. The ability to author extensions is a key value proposition to CDI. It would be good to see if there can be one API to do this instead of two. |
This is already possible via |
Does it make sense to document the general positioning of the two APIs further, with a view towards possibly deprecating the older API at a future point? |
I don't think the view is worth capturing as we cannot be sure when/if that happens and given that it would force existing extensions to rewrite, I don't see that happening any time soon. In theory, you can either be rigorous and write everything via BCE because you are going to migrate your app every other Monday to a different platform that may use either Lite or Full. Alternatively, you can choose the model that fits you based on whether you are running in an environment supporting Lite or Full. The compatibility is there but which one you choose to pick is up to you and up to what's easier to manage. In practice I doubt there are many applications that would commonly swap between, say, build time approach and runtime approach - or if they were, they'd have bigger hurdles to overcome in the first place. In other words, I don't see any urgent need to consolidate the two models so long as there is a one way portability (from Lite to Full) between them. |
Just a minor point of clarification - the extensions API is still mostly geared towards plug-in developers instead of business application developers, correct? So basically it’s a matter of a plug-in developer choosing to target something like Payara only, something like Quarkus only or ideally both? In the longer term, I would like to see us settle in a place where a plug-in writer can use just one API to target all environments, possibly introducing conditional handling within the same plug-in if truly required. Is that the current design intent of BCE? |
That is my understanding, yes. Application developers can use the API as well, but it is certainly geared towards framework integrators.
The intent is that you can either target Full only, or you can target both. The option to target "Quarkus only" is not present.
Exactly. |
Hi Reza!
There are a few things to consider: 1st: from a functionality pov: You can do all the things of the BuildCompatibleExtension also with a classic CDI Extension. But not the other way around. BuildCompatibleExtensions are much more restricted. For example it is not possible to configure the behaviour and apply Interceptors/Alternatives etc based on configuration on different servers. That's important for staging concepts. There is also another big problem in big modular projects: if you only have build time modification, then you'd need to crack open dependenies, modify them and rebundle them. Lot's of fun really - NOT :( 2nd: from a container pov: It is possible to implement all the BuildCompatibleExtension feature via a standard CDI Extension. And if someone wants to use build time handling then this is also perfectly possible right now. Helidon, Arthur, Meecrowave, etc ALL run on GraalVM quite nicely since many years! All those - and also Weld! - then use proprietary ways to enrich the classes with information, e.g. upfront generating proxies and stuff. But they are ALL proprietary anyway, even when using BuildCompatibleExtensions. 3rd: That means if you use the BuildCompatibleExtension system to enrich your project at build time, then it will ONLY run on that very targetted container! If you build for Quarkus, you will ONLY be able to run it on Quarkus, but not on WebLogic, TomEE, Glassfish or whatever other server. You are bound to the very vendor you compiled it for. That's imo not very EE-ish, isn't? That doesn't make that big of a difference for simple apps. But it might be a problem if you have 3rd party libs or reusable parts in bigger companies. 4th: no, CDI Extensions are not only for system integrators. I've seen tons of CDI Extensions written by and for customers. It might not be random Joe who uses it, but it's really used a lot, well established and would be a pity to loose it. |
We have a choice:
do you really want to go the new spec? if so please create a new spec and don't break CDI, also think it means breaking all other specs so you just break Jakarta with that. |
There are restrictions due to the very nature of build-time compatibility (e.g. can't read runtime configuration directly in the extension, although there are way to engineer around that), and there are holes that can be filled (e.g. the API does not support transforming beans or injection points yet, but nothing prevents adding that in the future).
There's exactly nothing in the specification that requires modifying and rebundling dependencies. Zero. Zip. Zilch. Nada. I'm not familiar enough with ODI to speak about that, but ArC doesn't do that and doesn't need to do that.
Intentionally. So that it's trivial for existing CDI implementations to add support for the API.
Don't conflate build time support with GraalVM Native Image support. They are not the same thing. If we wanted to compile Weld to native image, we would have done that. I'll help myself with an analogy: if Weld is the Guice of CDI, we wanted to build Dagger. CDI 3.0 and before didn't allow that.
Incorrect.
Incorrect.
Incorrect.
Fortunately enough, reusable libraries remain reusable. This page https://jakarta.ee/connect/ includes a link to the Jakarta EE Specifications Calendar. I hereby invite anyone and everyone to join any of the CDI calls and I'll be happy to explain how ArC works, including demos and details, as well as guided code walkthrough if anyone is interested. I also hereby refuse to continue engaging in discussions that are based on unverified assumptions presented as facts. Thanks for understanding. |
+100 to both of these points |
Right but real life ;). In practise build time has enough constraints to rarely work. Quarkus is a great proof of what Mark stated and even if EE can try to enable that it does not give any guarantee nor validation (which is a part of the design of EE) so this part is just empty and therefore Mark statement is very accurate from an user standpoint. Implementing the validations is possible but requires heavy processes which are not that friendly for modern development (do you want to get back to WAS/Weblo time?).
The opposite actually ;). Once again, both API are concurrent so you can always try to build one of top of the other but as of today runtime API is a superset of build API so you can implement build API with runtime API but not the opposite and at the end you get back to this particular ticket: new unsupported and build related API is not needed at all as you mention.
Don't think it was the point, graalvm just implies build time so is an example of the statement.
Guess you are both as right as wrong: it is undefined and does not exist in the spec so it can or not be as of today (literally, build time extensions are not a spec thing as of today, they are mentionned but not spec-ed to be implementable).
It is since quarkus does not support CDI and generated code is Arc specific so not reusable.
Please use an user friendly media == github for any discussions otherwise what is done privately does not exist for the community generally speaking (not specific to jakarta, more a general way to run OSS projects). Also note that Mark is right too, if you want to leverage the build support of quarkus you need to include in your app the jar Now, assuming you do that, how is this code portable:
So either you use build time API as a pure In both case the API failed. Add the other reasons of this ticket and we can safely drop the package. |
Now let's assume you have a LGPL licensed dependency which has some package scoped classes which need to be intercepted. Let's also assume that we are talking about Java17 with Java Module System in place. How is that solved in your environment? |
CDI lite has a lot of pitfalls in the way it is designed and consumers/end users can't rely on any part of this specification subpart so let's make it optional for now for any implementation.
Pitfalls to solve before thinking about making it a profile or anything concrete in the implementation:
build
but "build" means nothing for JakartaEE which is 99% about "runtime" in terms of API and features (only exception is JPA which references an annotation processor but explicitly excludes the build part of the spec intentionally in its wording since there is no ant/gradle/maven/javac coverage - not a goal - of the spec) so as of today it is a dead package you can only use relying on a vendor so no point to have it under jakartaee umbrellaExtension
API and technically you can runExtension
at build time since years, the only limitation would beExtension
with runtime impacts so it can be as efficient to just mark extensions with@BuildFriendly
- which can even be vendor specific since not loadable annotations are ignored by the JVM.Extension
)So before this API is adopted by people, let's just do a fix release saying it is optional and make it a specific profile for 4.1.0 (or whatever next version is cdi).
The text was updated successfully, but these errors were encountered: