Adelin
Adelin

Reputation: 19011

How to dependecy inject an EJB3 constructor?

According to EJB3 DI documentation it is possible to inject fields and setters. But how to inject a bean constructor ?

Upvotes: 2

Views: 998

Answers (1)

Brett Kail
Brett Kail

Reputation: 33956

The EJB specification does not support constructor injection. The EJB programming model only uses the no-arg constructor, and can then perform field or setter method injection after the instance has been constructed.

That said, EJB 3.1 is part of EE 6, which includes CDI. If your EJB module is a CDI BDA (bean deployment archive) because it includes beans.xml, then you can use CDI constructor injection.

Upvotes: 3

Related Questions