1 Reply Latest reply on Feb 29, 2016 8:54 AM by mkouba

    Use of @Parameters in WELD-SE,

    kalber

      1. starting the container and passing something as arg.

       

      public class Bootstrapping {

           public static void main(String[] args) {

              Weld weld = new Weld();

              try (WeldContainer container = weld.initialize()) {

              }

      }

       

      2. Inject @Paramters in my HelloWorld, but  is null.

       

      @ApplicationScoped

      public class HelloWorld {

          @Inject

          @Parameters

          List<String> params;

          public void printHello(@Observes ContainerInitialized event) {

       

       

              System.out.println(String.format("Hello i have %d args", params.size));

          }

      }


      My question is, is @Parameters referring to args ?


      Or @Parameters a readed from a config.xml file ?

        • 1. Re: Use of @Parameters in WELD-SE,
          mkouba

          Hi Karlheinz,

          yes, parameters refer to command line arguments. However, they are available out of the box only if org.jboss.weld.environment.se.StartMain is used. So if usig a custom main method you'll have to set the args manually, see also org.jboss.weld.environment.se.beans.ParametersFactory.setArgs(String[])