Skip to main content

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

Hi Ken,

Wow, that's old! jetty-7 is up to 7.6.13, not to mention the whole
jetty-8 series, and jetty-9.0, and jetty-9.1 (for servlet 3.1).

Moreover, isn't it confusing for Grails users that the Tomcat version
in use supports servlet 3.0, but the jetty version doesn't??? Really
sounds like Grails needs to update a version - do you have any
contacts within Grails to advocate for that?

Certainly it would make a lot of sense for you if the jetty plugin was
updated to jetty-8 or jetty-9 so that your servlet 3.0 code will work
for both containers ....

If you're reaaaaaally stuck on jetty-7.x, then possibly the best thing
to do is to look at an example of using jetty in embedded mode, like
this one:
http://download.eclipse.org/jetty/stable-7/xref/org/eclipse/jetty/embedded/OneServletContext.html

This jetty doco page, whilst being for jetty-9, might still be of use
to you too: http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html#d0e16410

Finally, please let me re-emphasise how useful it would be for Grails
to update to a more recent jetty version :)
Jan

On 18 October 2013 15:10, Ken Siprell <ken.siprell@xxxxxxxxx> wrote:
> 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
>
> _______________________________________________
> 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'


Back to the top