>  Maybe I should create a ServerFactory instead?

Yeah, that's one option. 

Let's maybe take the discussion off Cayenne list (e.g. to GitHub). I just 
opened a ticket there:

https://github.com/nhl/bootique-jetty/issues/12

Andrus




> On Mar 10, 2016, at 1:04 PM, Lon Varscsak <lon.varsc...@gmail.com> wrote:
> 
> Hmm, yeah this is trickier the more I get into it.  So I was able to
> successfully subclass WicketServlet and hack in the values I need to get it
> running.  However, I need my ServerContextHandler to be allocated with
> SESSIONS option.  Maybe I should create a ServerFactory instead?
> 
> On Thu, Mar 10, 2016 at 10:29 AM, Lon Varscsak <lon.varsc...@gmail.com>
> wrote:
> 
>> Yeah, it’s WicketServlet (I could subclass).
>> 
>> On Thu, Mar 10, 2016 at 10:25 AM, Andrus Adamchik <and...@objectstyle.org>
>> wrote:
>> 
>>> Is that a third-party servlet that you can't change?
>>> 
>>> Andrus
>>> 
>>>> On Mar 10, 2016, at 12:23 PM, Lon Varscsak <lon.varsc...@gmail.com>
>>> wrote:
>>>> 
>>>> 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 <and...@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.varsc...@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.varsc...@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
>>>>>>> 
>>>>> 
>>>>> 
>>> 
>>> 
>> 

Reply via email to