Class GrizzlySupport

java.lang.Object
org.forgerock.http.grizzly.GrizzlySupport

public final class GrizzlySupport extends Object
Provides the Grizzly HTTP library support to the common HTTP Framework.

Simple example usage with OpenIG. It attempts to listen on port 8080 and expects to find an OpenIG config directory under the config-base directory where the example is started. It runs until an exception is thrown or the process is killed.

     

        import org.forgerock.http.HttpApplication;
        import org.forgerock.http.grizzly.GrizzlySupport;
        import org.forgerock.openig.http.GatewayEnvironment;
        import org.forgerock.openig.http.GatewayHttpApplication;
        import org.glassfish.grizzly.http.server.HttpServer;

        public class Main {

            public static void main(String[] args) {

                // Set this to an appropriate value to enable OpenIG to find its configuration files.
                System.setProperty(GatewayEnvironment.BASE_SYSTEM_PROPERTY, "config-base");
                HttpServer server = HttpServer.createSimpleServer(null, 8080);
                HttpApplication application = new GatewayHttpApplication();
                server.getServerConfiguration().addHttpHandler(GrizzlySupport.newGrizzlyHttpHandler(application));
                // Set to true if you want to enable HTTP methods such as Delete having a payload.
                server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true);
                try {
                    server.start();
                } catch (Exception e) {
                    server.shutdownNow();
                }
            }
        }
     
 
  • Method Details

    • newGrizzlyHttpHandler

      public static org.glassfish.grizzly.http.server.HttpHandler newGrizzlyHttpHandler(HttpApplication httpApplication)
      Create a new Grizzly HttpHandler wrapping the given common HTTP Framework HttpApplication. The life-cycle of the provided HttpApplication is bound to the returned Grizzly HttpHandler. All the operations performed on the Grizzly HttpHandler will be forwarded to the common HTTP Framework Handler
      Parameters:
      httpApplication - The HttpApplicationException to wrap.
      Returns:
      A Grizzly HttpHandler ready to be added to an HttpServer
    • newGrizzlyHttpHandler

      public static org.glassfish.grizzly.http.server.HttpHandler newGrizzlyHttpHandler(Handler handler, org.forgerock.util.Factory<Buffer> storage)
      Create a new Grizzly HttpHandler from the given common HTTP Framework Handler. All the operations performed on the Grizzly HttpHandler will be forwarded to the common HTTP Framework Handler. No API Description will be exposed.
      Parameters:
      handler - The HttpHandler to wrap.
      storage - The Factory that will create temporary storage Buffers to handle the processing of requests. If null, a default buffer factory will be used.
      Returns:
      A Grizzly HttpHandler ready to be added to an HttpServer
    • newGrizzlyHttpHandler

      public static org.glassfish.grizzly.http.server.HttpHandler newGrizzlyHttpHandler(Handler handler, org.forgerock.util.Factory<Buffer> storage, ApiProducer<io.swagger.models.Swagger> apiProducer)
      Create a new Grizzly HttpHandler from the given common HTTP Framework Handler. All the operations performed on the Grizzly HttpHandler will be forwarded to the common HTTP Framework Handler.
      Parameters:
      handler - The Handler to wrap.
      storage - The Factory that will create temporary storage Buffers to handle the processing of requests. If null, a default buffer factory will be used.
      apiProducer - The ApiProducer to use to expose an OpenAPI API Description.
      Returns:
      A Grizzly HttpHandler ready to be added to an HttpServer