mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Yannick Lecaillez
29.00.2016 69bd2a29170d9b51ad564cafe0590f9893e8611d
OPENDJ-2556: Avoid Servlet dependency in OpenDJ server by using
grizzly-http.
4 files modified
44 ■■■■ changed files
opendj-dsml-servlet/pom.xml 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/pom.xml 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/http/SdkConnectionAdapter.java 5 ●●●●● patch | view | raw | blame | history
opendj-dsml-servlet/pom.xml
@@ -36,6 +36,13 @@
    </properties>
    <dependencies>
        <!-- Servlet API -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <!-- ForgeRock libraries -->
        <dependency>
            <groupId>org.forgerock.commons</groupId>
opendj-server-legacy/pom.xml
@@ -133,7 +133,7 @@
    <dependency>
      <groupId>org.forgerock.http</groupId>
      <artifactId>chf-http-servlet</artifactId>
      <artifactId>chf-http-grizzly</artifactId>
    </dependency>
    <!-- ForgeRock Common Audit libraries -->
@@ -173,19 +173,7 @@
      <artifactId>jul-to-slf4j</artifactId>
    </dependency>
    <!-- servlet and mail -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.grizzly</groupId>
      <artifactId>grizzly-http-servlet</artifactId>
      <version>${grizzly-framework.version}</version>
    </dependency>
    <!-- mail -->
    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>javax.mail</artifactId>
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)
opendj-server-legacy/src/main/java/org/opends/server/protocols/http/SdkConnectionAdapter.java
@@ -23,8 +23,7 @@
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.http.HttpServletResponse;
import org.forgerock.http.protocol.Status;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.AbstractAsynchronousConnection;
import org.forgerock.opendj.ldap.ByteString;
@@ -283,7 +282,7 @@
    // At this point, we try to log the request with OK status code.
    // If it was already logged, it will be a no op.
    this.clientConnection.log(HttpServletResponse.SC_OK);
    this.clientConnection.log(Status.OK.getCode());
    isClosed = true;
  }