2 Replies Latest reply on Jun 8, 2017 6:32 AM by christoph.tornau

    What is the alternative to the WeldContainer.instance-method?

    christoph.tornau

      Within a Java SE application I am trying the following:

       

      Weld weld = new Weld();
      WeldContainer container = weld.initialize();
      Test t = container.instance().select(Test.class).get();
      

       

      However the method instance() of container is deprecated and the documentation says: "Applications are encouraged to use methods for programmatic lookup directly." (see: https://github.com/weld/core/blob/master/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldContainer.java )

       

      So how is it possible to avoid the deprecated warning. It's not possible for me to work with an @Inject annotation because this class isn't loaded by Weld initially because it's a Java SE application. I googled around and didn't find an answer to this. All examples are using the deprecated instance()-method.

       

      Thank you in advance.