From 69bd2a29170d9b51ad564cafe0590f9893e8611d Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Mon, 02 May 2016 07:50:48 +0000
Subject: [PATCH] OPENDJ-2556: Avoid Servlet dependency in OpenDJ server by using grizzly-http.

---
 opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
index ec1950b..399d09e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
@@ -19,6 +19,7 @@
 import static org.opends.messages.ProtocolMessages.*;
 import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
+import static org.forgerock.http.grizzly.GrizzlySupport.newGrizzlyHttpHandler;
 
 import java.io.IOException;
 import java.net.InetAddress;
@@ -45,7 +46,6 @@
 import org.forgerock.http.HttpApplicationException;
 import org.forgerock.http.handler.Handlers;
 import org.forgerock.http.io.Buffer;
-import org.forgerock.http.servlet.HttpFrameworkServlet;
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.server.ConfigChangeResult;
@@ -62,7 +62,6 @@
 import org.glassfish.grizzly.http.server.ServerConfiguration;
 import org.glassfish.grizzly.monitoring.MonitoringConfig;
 import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
-import org.glassfish.grizzly.servlet.WebappContext;
 import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
 import org.glassfish.grizzly.strategies.SameThreadIOStrategy;
 import org.glassfish.grizzly.utils.Charsets;
@@ -681,10 +680,7 @@
     }
 
     this.httpServer = createHttpServer();
-
-    // Register servlet as default servlet and also able to serve REST requests
-    createAndRegisterServlet("OpenDJ HTTP servlet", "", "/*");
-
+    this.httpServer.getServerConfiguration().addHttpHandler(newGrizzlyHttpHandler(new RootHttpApplication()));
     logger.trace("Starting HTTP server...");
     this.httpServer.start();
     logger.trace("HTTP server started");
@@ -748,14 +744,6 @@
     return server.getServerConfiguration().getMonitoringConfig().getHttpConfig();
   }
 
-  private void createAndRegisterServlet(final String servletName, final String... urlPatterns) throws Exception
-  {
-    // Create and deploy the Web app context
-    final WebappContext ctx = new WebappContext(servletName);
-    ctx.addServlet(servletName, new HttpFrameworkServlet(new RootHttpApplication())).addMapping(urlPatterns);
-    ctx.deploy(this.httpServer);
-  }
-
   private void stopHttpServer()
   {
     if (this.httpServer != null)

--
Gitblit v1.10.0