Package org.forgerock.http.grizzly
Class GrizzlySupport
java.lang.Object
org.forgerock.http.grizzly.GrizzlySupport
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 Summary
Modifier and TypeMethodDescriptionstatic org.glassfish.grizzly.http.server.HttpHandler
newGrizzlyHttpHandler
(Handler handler, org.forgerock.util.Factory<Buffer> storage) Create a new GrizzlyHttpHandler
from the given common HTTP FrameworkHandler
.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 GrizzlyHttpHandler
from the given common HTTP FrameworkHandler
.static org.glassfish.grizzly.http.server.HttpHandler
newGrizzlyHttpHandler
(HttpApplication httpApplication) Create a new GrizzlyHttpHandler
wrapping the given common HTTP FrameworkHttpApplication
.
-
Method Details
-
newGrizzlyHttpHandler
public static org.glassfish.grizzly.http.server.HttpHandler newGrizzlyHttpHandler(HttpApplication httpApplication) Create a new GrizzlyHttpHandler
wrapping the given common HTTP FrameworkHttpApplication
. The life-cycle of the providedHttpApplication
is bound to the returned GrizzlyHttpHandler
. All the operations performed on the GrizzlyHttpHandler
will be forwarded to the common HTTP FrameworkHandler
- Parameters:
httpApplication
- TheHttpApplicationException
to wrap.- Returns:
- A Grizzly
HttpHandler
ready to be added to anHttpServer
-
newGrizzlyHttpHandler
public static org.glassfish.grizzly.http.server.HttpHandler newGrizzlyHttpHandler(Handler handler, org.forgerock.util.Factory<Buffer> storage) Create a new GrizzlyHttpHandler
from the given common HTTP FrameworkHandler
. All the operations performed on the GrizzlyHttpHandler
will be forwarded to the common HTTP FrameworkHandler
. No API Description will be exposed.- Parameters:
handler
- TheHttpHandler
to wrap.storage
- TheFactory
that will create temporary storageBuffer
s to handle the processing of requests. Ifnull
, a default buffer factory will be used.- Returns:
- A Grizzly
HttpHandler
ready to be added to anHttpServer
-
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 GrizzlyHttpHandler
from the given common HTTP FrameworkHandler
. All the operations performed on the GrizzlyHttpHandler
will be forwarded to the common HTTP FrameworkHandler
.- Parameters:
handler
- TheHandler
to wrap.storage
- TheFactory
that will create temporary storageBuffer
s to handle the processing of requests. Ifnull
, a default buffer factory will be used.apiProducer
- TheApiProducer
to use to expose an OpenAPI API Description.- Returns:
- A Grizzly
HttpHandler
ready to be added to anHttpServer
-