Hi,
I don't think you can produce interceptors, but Ondro is exactly right about alternatives. Since it wasn't possible to put
@Priority on methods for a long time, the typesafe resolution algorithm contains a "hack" where producers inherit priority from their declaring beans. That is no longer necessary — producers can declare priority on their own.
Priority may affect order of beans that you may iterate on an Instance , but that has never been specified and so is implementation-specific.
LT
From: cdi-dev <cdi-dev-bounces@xxxxxxxxxxx> on behalf of Ondro Mihályi via cdi-dev <cdi-dev@xxxxxxxxxxx>
Sent: Monday, July 14, 2025 08:06
To: cdi developer discussions <cdi-dev@xxxxxxxxxxx>
Cc: Ondro Mihályi <mihalyi@xxxxxxxxxxx>
Subject: [EXTERNAL] Re: [cdi-dev] What is the purpose of @Priority on Producers?
This Message Is From an External Sender
This message came from outside your organization.
In short, allowing @Priority on producer methods makes producer methods equally powerful than defining beans by classes.
I’m not sure if Priority plays role in the order of beans, maybe it impacts the order of beans returned from the iterator if an injected Instance.
But Priority has a very important side-effect on beans marked as @Alternative - it enables them automatically, without adding them to beans.xml. And it also automatically enables interceptors without adding them to beans.xml, besides
ordering them.
Both alternative beans and interceptors can be produced by a producer. Then you are able to enable them (and order them in case of multiple interceptors) in the same way as if they are defined by a class.
Ondro
For example, if the same interface with different implement, we can identify them with qualifiers. Two producers for this case with @
Priority is meaningless.
And the beans instantation ordering can be detected by the dependencies.
Is there a simple example to demonstrate it resolves the current issue?
---
Regards,
Hantsy Bai
Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker
GitHub:
https://github.com/hantsy
Twitter:
https://twitter.com/@hantsy
|