I'm making an application which loads modules dynamically based on configuration files. Each module has its own servlet and its own path.
It works, but so far it's only serving content I annotate with @Path
in my classes (rest services), thanks to the ServerProperties.PROVIDER_PACKAGES
property:
Context:
ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS );
context.setContextPath( "/" );
Each module/servlet is initialized like this:
ServletHolder jerseyServlet = context.addServlet( org.glassfish.jersey.servlet.ServletContainer.class, "/" );
jerseyServlet.setInitOrder( 0 );
jerseyServlet.setInitParameter( ServerProperties.PROVIDER_PACKAGES, "com.my.packages.rest.server.root" );
This gives me a url path per module - great.
But I also have some static html in the resource/modulename folder of each module, which I don't know how to serve...
With a DefaultServlet, I can do it like this:
DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder staticAppServlet = new ServletHolder( "default", defaultServlet );
staticAppServlet.setInitParameter( "resourceBase", "./src/main/resources/modulename/" );
context.addServlet( staticAppServlet, "/path" );
But I don't know how to do it with a jetty ServletHolder
.
Any idea?