Hi,
I'm the author of a Grails plugin (
https://github.com/kensiprell/grails-atmosphere-meteor) that up to this point has only worked with Tomcat. I have a request to support Jetty that I'd like to implement as well.
The plugin registers the servlets programmatically using the Groovy method below (no web.xml). I've been reading up on the Jetty docs and API, but I can't figure out how to adapt the method to configure the Jetty servlets. As you can see below it's easy with Tomcat after getting ahold of a ServletRegistration object.
def doWithDynamicMethods = { applicationContext ->
def config = ApplicationContextHolder.atmosphereMeteorConfig
def servletContext = applicationContext.servletContext
config?.servlets?.each { name, parameters ->
ServletRegistration servletRegistration = servletContext.addServlet(name, parameters.className)
servletRegistration.addMapping(parameters.mapping)
servletRegistration.setAsyncSupported(Boolean.TRUE)
servletRegistration.setLoadOnStartup(1)
def initParams = parameters.initParams
if (initParams != "none") {
initParams?.each { param, value ->
servletRegistration.setInitParameter(param, value)
}
}
}
}
I assume the starting point should be the method below:
ServletHolder ServletContextHandler.addServlet(Class<? extends Servlet> servlet, String pathSpec)
The classes below look promising, but I can't figure out how to tie them all together:
org.eclipse.jetty.servlet.Holder
ServletRegistration.Dynamic
Is there a similar way to do this with Jetty?
Thanks for the help,
Ken