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.

Allow the easy instantiation of CDI beans

See original GitHub issue

Description

I was wondering if it would make sense to make eager instantiation super easy for users via either an annotation (for per bean control) and / or a config property that would make bean instantation eager by default.

Implementation ideas

We could basically generate the necessary void startup(@Observes StartupEvent event) under the hood - or perhaps tie deeper into Arc to make this controllable.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
mkoubacommented, Dec 5, 2019

Implementation note: the easiest solution from impl POV would be to introduce an interface, e.g. StartupCallback with default no-op startup() method and then in the LifecycleEventRunner iterate over all beans that implement this interface and invoke each of the beans.

2reactions
gastaldicommented, Dec 5, 2019

+1 for a @Startup annotation. In some classes writing an observer method just to initialize (which does nothing) during the startup is annoying

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to instantiate more CDI beans for one class?
In Spring there is possible to instantiate any class by defining the corresponding bean in xml conf. It is also possible to instantiate...
Read more >
Using CDI Beans in Instantiated Components - Coding Ninjas
CDI Beans are classes that CDI can Automatically instantiate, manage and inject to meet the requirement of the Other objects. CDI can manage...
Read more >
Introduction to Contexts and Dependency Injection - Quarkus
There is a simple rule: exactly one bean must be assignable to an injection point, otherwise the build fails. If none is assignable...
Read more >
CDI (Part 4): Lazy Initialization - DZone
Let's move onto another big benefit of CDI: lazy initialization. See how and when to implement it in your Java projects with this...
Read more >
Weld 2.4.0.CR1 - CDI Reference Implementation
We need to enable an alternative in the beans.xml descriptor of a bean archive to make it available for instantiation and injection. However,...
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