cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lon Varscsak <lon.varsc...@gmail.com>
Subject Re: OT: Boutique
Date Thu, 10 Mar 2016 17:23:57 GMT
Okay, that’s where I ended up (so I’m glad I was on the right track)…my
servlet that I’m using gets all of it’s values from the init parameters and
the only way I know to set them programmatically (no web-xml) is to use a
ServletHolder.  Thoughts?

I might be able to create a subclass and do some tricks.

-Lon

On Wed, Mar 9, 2016 at 6:49 PM, Andrus Adamchik <andrus@objectstyle.org>
wrote:

> Hi Lon,
>
> Yeah, we need to make this a bit more transparent (servlet-related API is
> still minimal, as we focsed on other areas like web services). But you are
> going in the right direction. JettyModule.contributeServlets(Binder) is
> what you need. We wrap the servlet in Bootique MappedServlet class to
> attach the URL mapping. So the whole thing may look like this:
>
> public class App implements Module {
>
>   @Override
>   public void configure(Binder binder) {
>     Set<String> urlPatterns = Collections.singleton("/*");
>     MyServlet servlet = new MyServlet();
>     JettyModule.contributeServlets(binder).addBinding().toInstance(new
> MappedServlet(servlet, urlPatterns));
>   }
> }
>
> Since you create the servlet in the code, you don't need init parameters.
> Instead you treat the servlet as a Java object, and pass anything you need
> in constructor or via setters. (The whole point is to avoid web.xml).
>
> We may improve this API in the future (a bit too much code for my liking;
> also servlet has to be instantiated and initialized manually instead of
> using injection). But it is fully functional and will get you going.
>
> Andrus
>
> > On Mar 9, 2016, at 6:28 PM, Lon Varscsak <lon.varscsak@gmail.com> wrote:
> >
> > I also need to add init parameters to my servlet, but I only know how to
> do
> > it through ServletHolder (which bootique doesn’t support).
> >
> > -Lon
> >
> > On Wed, Mar 9, 2016 at 3:11 PM, Lon Varscsak <lon.varscsak@gmail.com>
> wrote:
> >
> >> Since I can’t find an email list for Bootique… :D
> >>
> >> How do I add a servlet to Jetty through Bootique.  I see
> >> JettyModule.contributeServlets(Binder)…but I can’t figure it out.  DI is
> >> still magical to me.
> >>
> >> Thanks,
> >>
> >> Lon
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message