title: How to provide constructor parameters to Resteasy resources loaded from reflection?
body: <p>I'm running Undertow as a simple Servlet container. I deployed Resteasy servlet:</p>
  
  <pre><code>    ResteasyDeployment restEasyDeployment = new ResteasyDeployment();
  
      Reflections reflections = new Reflections("");
      Set&lt;Class&lt;?&gt;&gt; resourceClassSet = reflections.getTypesAnnotatedWith(Path.class);
      restEasyDeployment.getActualResourceClasses().addAll(resourceClassSet);
  
      ServletInfo servletInfo = Servlets.servlet("RestEasyServlet", HttpServlet30Dispatcher.class);
      servletInfo.setAsyncSupported(true)
              .setLoadOnStartup(1)
              .addMapping("/*");
  
      DeploymentInfo deploymentInfo = new DeploymentInfo();
      deploymentInfo.setContextPath(path)
                      .addServletContextAttribute(ResteasyDeployment.class.getName(), restEasyDeployment)
                      .addServlet(servletInfo)
                      .setDeploymentName("api")
                      .setClassLoader(ClassLoader.getSystemClassLoader());
  
      DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(deploymentInfo);
      deploymentManager.deploy();
  </code></pre>
  
  <p>This code is based on <a href="http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html_single/index.html#d4e1422" rel="nofollow">this tutorial</a> and <a href="https://github.com/resteasy/Resteasy/blob/master/jaxrs/server-adapters/resteasy-undertow/src/main/java/org/jboss/resteasy/plugins/server/undertow/UndertowJaxrsServer.java" rel="nofollow">this code</a>. </p>
  
  <p>How to provide any construction parameters to the resources deployed inside Resteasy? </p>
  
  <p>I see tutorials using static fields but I want to keep dependency inversion in place for easy testing. In a Servlet world a right way of doing it would be to put everything in context. </p>