question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Programmatic lookup improvements

See original GitHub issue

Both the reference implementation (Weld) and ArC have an enhanced version of javax.enterprise.inject.Instance that provide features that might be worth adding to the spec.

Enhancement Description
Instance#getHandler() (name TBC) Allows the client to obtain a “contextual reference handler” which not only holds the contextual reference but also makes it possible to inspect the metadata (i.e. Bean<?>) of the relevant bean and to destroy the underlying contextual instance.
Instance#handlers() (name TBC) Returns an Iterable of handlers described above.
select() method that accepts java.lang.reflect.Type This allows for generic selection of instances which can be handy while dealing with third party beans through extensions. However, it’s not type-safe.
Caching the result of Instance#get() See https://quarkus.io/guides/cdi-reference#caching-the-result-of-programmatic-lookup

See also Weld docs about WeldInstance - Enhanced version of jakarta.enterprise.inject.Instance.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
manovotncommented, Sep 15, 2021

FTR this issue was discussed during CDI meeting yesterday. General consensus was that the Handler feature should be added into specification (e.g. Instance#handlers() and Instance.getHandler()) while the remaining two features got mixed reactions and the decision was to be keep track of them but don’t add them to the specification just yet.

1reaction
Ladicekcommented, Sep 13, 2021

The main point of Handle is really the ability to browse beans of certain type before creating their instances. The fact that you can perform get and destroy from there is just a convenience.

I wouldn’t call it “just a convenience”, because if you getHandles() and filter based on Bean metadata and then want to create an instance, going back to the Instance would require you to 1. remember position, 2. iterate again and rely on iteration order, which is clunky and generally a bad idea. So I’d consider instantiating and destroying essential.

In any case, I just wanted to clarify for myself, and thought perhaps that would be useful for someone else too 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatic lookup improvements
Programmatic lookup improvements ... It is less known that Instance extends Iterable and so it allows to iterate through contextual references of ...
Read more >
Programmatic lookup of all beans of parametrized interface
I need to use programmatic lookup to find bean that implement the given interface regardless of parameter types. Because of type safe ...
Read more >
The Path to Improve the Programmatic Experience
The programmatic ad buying experience needs to be improved to be more approachable to mid-market advertisers testing it for the first time.
Read more >
Programmatic Measure Benchmarks & Performance ...
Provider Portal changesWe've made visual and functional upgrades for an improved experience. For Communities · Healthy Communities.
Read more >
The Beginner's Guide to Programmatic Advertising
With programmatic advertising, marketers have more time for the optimization and improvement of ads to drive campaign success.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found