Hi Alfred,
I found this sample on the mailing list:
_webServer = new GrizzlyWebServer(port, docRoot.getAbsolutePath());
// Jersey adapter
ServletAdapter jerseyAdapter = new ServletAdapter();
jerseyAdapter
.addInitParameter("com.sun.jersey.config.property.packages",
"mdt.web.jersey");
jerseyAdapter.setServletInstance(new ServletContainer());
_webServer.addGrizzlyAdapter(jerseyAdapter, new String[] { "/
jersey" });
// Static adapter
_webServer.addGrizzlyAdapter(new GrizzlyAdapter() {
@Override
public void service(GrizzlyRequest request, GrizzlyResponse
response) {
}
}, new String[] { "/" });
_webServer.start();
You can also add any number of Grizzly ServletAdapter(s) to serve
servlets.
To use servlet filters - please pass them (class names) via
"listeners" parameter of ServletAdapter constructor [1]
Hope this will help.
If you'll have more questions - just ask.
Thanks.
WBR,
Alexey.
[1]
/**
* Convenience constructor.
*
* @param publicDirectory The folder where the static resource are
located.
* @param servletCtx {_at_link ServletContextImpl} to be used by new
instance.
* @param contextParameters Context parameters.
* @param servletInitParameters servlet initialization parameres.
* @param listeners Listeners.
*/
protected ServletAdapter(String publicDirectory,
ServletContextImpl servletCtx,
HashMap<String,String> contextParameters,
HashMap<String,String> servletInitParameters,
ArrayList<String> listeners)
On Jul 30, 2010, at 14:59 , Paul Sandoz wrote:
> Hi Alfred,
>
> Cross posting to the Grizzly users list they should be able to help
> with the related Grizzly set up using GrizzlyWebServer.
>
> Paul.
>
> On Jul 22, 2010, at 5:44 PM, Rebel Geek wrote:
>
>> Hello,
>>
>> I did a few searches in the forums and I could not find what I was
>> looking for, so please forgive me if I've indadvertedly repeated a
>> question....
>>
>> I have a Wep Application (WAR) that I have running with the Jetty-
>> runner. It has the following features:
>>
>> Serves up dojo pages (static HTML)
>> Has Servlets/filters for authentication and AJAX
>>
>> I would like to add Jersey RESTful services to this, but I'd also
>> like to get rid of Jetty and use Grizzly completely embedded in the
>> application. I see examples of embedding Grizzly and I see
>> examples of creating REST Resource, etc., but I don't see any
>> examples that will point me to using Jersey/Grizzly to create a web
>> server that will server HTML, Servlets and RESTful services all in
>> one.
>>
>> The reason why I'm struggling is because the Jersey examples use
>> the com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory
>> as opposed to GrizzlyWebServer class from the Grizzly packages. Can
>> somebody point me to documentation or an example that will put me
>> on the correct path?
>>
>> Thank you,
>>
>> Alfred
>