1 Reply Latest reply on Jun 30, 2016 10:21 AM by Martin Kouba

    How do I invoke an injected method with Weld SE?

    Christian Wansart Newbie



      I'm trying to understand how to use method injection, but I cannot find a way to use it properly. I was wondering: Is it even possible with Weld SE or is this a feature that depends on a Java EE server?



      public class App {
          public static void main(String[] args) {
              Weld weld = new Weld();
              WeldContainer container = weld.initialize();
              Foo foo = container.select(Foo.class).get();
              // call foo.test() here



      public class Foo {
          public void test(Baz baz) {
              System.out.println("Baz: " + baz);



      public class Baz {
          private String name = "Baz";
          public String toString() {
              return "Baz{" + "name=" + name + '}';


      But how do I invoke foo.test() now with the injection? Is this possible?