Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Dynamic Servlet Registration

Jan,

Thanks for answering. Unfortunately, the Grails Jetty plugin uses version 7.6.0. I was only looking at its API, and it didn't look as straight forward as the simple closure I'm using to register the servlets with Tomcat 7.

Ken


On 17.10.2013, at 23:47, Jan Bartel <janb@xxxxxxxxxxx> wrote:

> Hi Ken,
> 
> That API looks like the standard servlet 3.0 api. If you use jetty-8.x
> or jetty-9.x or jetty-9.1.x then that API is supported.
> 
> cheers
> Jan
> 
> On 18 October 2013 00:13, Ken Siprell <ken.siprell@xxxxxxxxx> wrote:
>> 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
>> 
>> _______________________________________________
>> jetty-users mailing list
>> jetty-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>> 
> 
> 
> 
> -- 
> Jan Bartel <janb@xxxxxxxxxxx>
> www.webtide.com
> 'Expert Jetty/CometD developer,production,operations advice'
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top