Julio Faerman
Julio Faerman

Reputation: 13501

How to pass parameters to instantiation of a CDI @Dependent bean?

How to pass runtime parameters to the instantiation of a @Dependent bean, obtained by Instance<T>.get() or equivalent in CDI?

For instance, consider the code:

@Inject
Instance<Person> instance;
...
var name = "Some One";
var bean = instance.get();
bean.setName(bean);

It may be desirable to pass the parameter in instantiation, to make the object immutable for example. Something like

@Inject
Instance<Person> instance;
...
var name = "Some One";
var bean = instance.get(name); // ?

Is there a syntax for that in current CDI?

Upvotes: 1

Views: 199

Answers (0)

Related Questions