I'm running Undertow as a simple Servlet container. I deployed Resteasy servlet:
ResteasyDeployment restEasyDeployment = new ResteasyDeployment();
Reflections reflections = new Reflections("");
Set<Class<?>> 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();
This code is based on this tutorial and this code.
How to provide any construction parameters to the resources deployed inside Resteasy?
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.