Salut,
this is fixed. Mainly, you just need to do:
ServletAdapter sa = new ServletAdapter();
...
ServletAdapter sa2 = sa.newServletAdapter(Servlet2);
The documentation is here:
https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/servlet/ServletAdapter.html
and I added a test case here:
https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/samples/http/adapter/GrizzlyEmbedWebServer.html
A+
- Jeanfrancois
Jeanfrancois Arcand wrote:
> Salut,
>
> Tom wrote:
>> On Tue, Jan 13, 2009 at 4:07 PM, Jeanfrancois Arcand
>> <Jeanfrancois.Arcand_at_sun.com> wrote:
>>> Salut,
>>>
>>> Tom wrote:
>>>> Hi,
>>>>
>>>> Is it possible to have more than one servlet running in a
>>>> ServletContext with the grizzly-servlet-webserver?
>>> Yes, it is. You need to use the GrizzlyAdapterChain (which is used by
>>> default by the GrizzlyWebServer class. Take a look at [1] for an
>>> example.
>>> Mainly, you can do:
>>>
>>>> GrizzlyWebServer ws = new GrizzlyWebServer(path);
>>>> ServletAdapter sa = new ServletAdapter();
>>>> sa.setRootFolder(".");
>>>> sa.setServletInstance(new ServletTest("Adapter-1"));
>>>> ws.addGrizzlyAdapter(sa, new String[]{"/Adapter-1"});
>>>>
>>>> ServletAdapter sa2 = new ServletAdapter();
>>>> sa2.setRootFolder("/tmp");
>>>> sa2.setServletInstance(new ServletTest("Adapter-2"));
>>>> ws.addGrizzlyAdapter(sa2, new String[]{"/Adapter-2"});
>>>>
>>>> System.out.println("Grizzly WebServer listening on port 8080");
>>>> ws.start();
>>
>> Wouldn't this create two instances of a ServletContext? My 'webapp'
>> has a Listener that loads configuration and then the Servlets share
>> this resource (with ServletContext.getAttribute()).
>
> I see....Yes you are right. I can easily fix that by allowing
> 'shareability' amongst ServletAdapter.
>
>
>>
>> I'm expecting multiple servlets to belong to one context. I appreciate
>> that this adds complexity (servlet mappings) and may be beyond the
>> scope of what the module is expected to support.
>
> No this is simple to fix. If you file an issue here:
>
> https://grizzly.dev.java.net/issues/
>
> I promise a fix this afternoon :-)
>
>
>>
>> I was thinking I might be in the wrong place since some combination of
>> Grizzly and Glassfish must already be doing this for war-file
>> deployments. (I'm hoping to be free from war files and web.xml but
>> have everything else :-)
>>
>
> Serv;et 3.0 will add programmatic way to configure Servlet, and
> GlassFish v3 has already started implementing some part of it. You might
> want to look at the GlassFish Embed sub project for more information
> [1]. But this is work in progress :-)
>
> A+
>
> -- Jeanfrancois
>
> [1] https://embedded-glassfish.dev.java.net/
>
>
>> Thanks again!
>>
>> Tom
>>
>>>
>>> I've been using
>>>> ServletAdapter to set up servlets but it creates its own context each
>>>> time.
>>>>
>>>> It doesn't look like too much work to extend the functionality of
>>>> ServletAdapter but I'm worried I am looking in the wrong place.
>>>> At the moment, my aim is to change one of our applications so that it
>>>> controls/manages the servlet engine, rather than the other way round.
>>> Try the above and let me know if you face any issues. I will fix them
>>> ASAP
>>> but my simple test:
>>>
>>> https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/samples/http/adapter/GrizzlyEmbedWebServer.html
>>>
>>> http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-multiple-adapter/1.9.4-SNAPSHOT/
>>>
>>>
>>> seems to works fine.
>>>
>>> A+
>>>
>>> -- Jeanfrancois
>>>
>>> [1]
>>> http://weblogs.java.net/blog/jfarcand/archive/2009/01/extending_the_g_5.html
>>>
>>>
>>>
>>>> Regards,
>>>> Tom
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>