I'm trying to get into Weld and cdi-api. I have created a empty beans.xml (with bean-discovery-mode="all") and I defined classes like below:
public static void main(String[] args) {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
container.select(MainWindow.class).get();
@Dependent
public class MainWindow{
...
//some swing components
...
private void initItemTableView() {
itemTableModel = new ItemTableModel();
I heard that you can't use keyword 'new' because CDI will not have control over lifecycle of the object so instead, I also tried injecting ItemTableModel by @Inject and defining it as @ApplicationScoped but with the same results.
@ApplicationScoped
public class ItemTableModel extends AbstractModel {
@Inject
private TtcDataService ttcDataService; // <- this is null
(TtcDataService is defined with @ApplicationScoped annotation)
I'm complete newbie in terms of CDI, I would be very grateful for pointing out where I did wrong.