users@grizzly.java.net

Re: Where is GrizzlyWebServer ?

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 20 Nov 2014 14:22:19 -0800

Hi Nicolas,

>
> Is renamed or deleted ?
It's reworked :)

> I was trying to achieve something like this :
>
> GrizzlyWebServer grizzly = new GrizzlyWebServer();
> ServletAdapter sa;
> String servletClassName =
> "com.vaadin.terminal.gwt.server.ApplicationServlet";
> try {
> Servlet s = (Servlet)Class.forName(servletClassName).newInstance();
> sa = new ServletAdapter();
> sa.setServletInstance(s);
> } catch (...) {
> }
> sa.setRootFolder("WebContent");
> sa.addContextParameter("productionMode", "false");
> sa.setContextPath("/MyApp");
> sa.setProperty(ServletAdapter.LOAD_ON_STARTUP, "1");
> sa.addInitParameter("application", "my.domain.MyApplication");
> grizzly.addGrizzlyAdapter(sa, new String[]{"/MyApp","/VAADIN"});
You need to use Grizzly http-servlet module.
If you use maven, the artifact is:
     <groupId>org.glassfish.grizzly</groupId>
     <artifactId>grizzly-http-servlet</artifactId>

The app will look like:

/HttpServer httpServer = HttpServer.createSimpleServer("WebContent");//
//
//WebappContext ctx = new WebappContext("Test", "/MyApp");//
//final ServletRegistration reg = ctx.addServlet("ServletName",
servletClassName);//
//reg.addMapping("/servletPath");//
//reg.setLoadOnStartup(1);//
//
//ctx.setInitParameter("productionMode", "false");//
//
//ctx.deploy(httpServer);//
//
//httpServer.start();/

I didn't test this code, but it should give you a hint what to look at.

Thanks.

WBR,
Alexey.