use of org.glassfish.grizzly.http.server.ServerConfiguration in project dukescript-presenters by dukescript.
the class Browser method server.
private static HttpServer server(RootPage r) {
int from = 8080;
int to = 65535;
// NOI18N
String port = System.getProperty("com.dukescript.presenters.browserPort");
if (port != null) {
from = to = Integer.parseInt(port);
}
HttpServer s = HttpServer.createSimpleServer(null, new PortRange(from, to));
final ServerConfiguration conf = s.getServerConfiguration();
conf.addHttpHandler(r, "/");
return s;
}
use of org.glassfish.grizzly.http.server.ServerConfiguration in project nuls by nuls-io.
the class RpcServerServiceImpl method startServer.
@Override
public void startServer(String ip, int port) {
URI serverURI = UriBuilder.fromUri("http://" + ip).port(port).build();
final Map<String, Object> initParams = new HashMap<>();
initParams.put("jersey.config.server.provider.packages", RpcConstant.PACKAGES);
initParams.put("load-on-startup", "1");
NulsResourceConfig rc = new NulsResourceConfig();
rc.addProperties(initParams);
httpServer = GrizzlyHttpServerFactory.createHttpServer(serverURI, rc);
try {
httpServer.start();
ClassLoader loader = this.getClass().getClassLoader();
CLStaticHttpHandler docsHandler = new CLStaticHttpHandler(loader, "swagger-ui/");
docsHandler.setFileCacheEnabled(false);
ServerConfiguration cfg = httpServer.getServerConfiguration();
cfg.addHttpHandler(docsHandler, "/docs/");
} catch (IOException e) {
Log.error(e);
}
Log.info("http restFul server is started!url is " + serverURI.toString());
}
use of org.glassfish.grizzly.http.server.ServerConfiguration in project narayana by jbosstm.
the class SpdyEnabledHttpServer method createHttpServer.
private static HttpServer createHttpServer(final URI uri, final GrizzlyHttpContainer handler, final boolean secure, final SSLEngineConfigurator sslEngineConfigurator, final int poolSize, final boolean enableSpdy) throws ProcessingException {
final String host = (uri.getHost() == null) ? NetworkListener.DEFAULT_NETWORK_HOST : uri.getHost();
final int port = (uri.getPort() == -1) ? 80 : uri.getPort();
final HttpServer server = new HttpServer();
final NetworkListener listener = new NetworkListener("grizzly", host, port);
listener.setSecure(secure);
if (sslEngineConfigurator != null) {
listener.setSSLEngineConfig(sslEngineConfigurator);
}
if (poolSize > 0) {
TCPNIOTransport transport = listener.getTransport();
transport.getKernelThreadPoolConfig().setMaxPoolSize(poolSize);
}
if (enableSpdy) {
SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
System.out.printf("SPDY: max conc. streams: %d%n", spdyAddOn.getMaxConcurrentStreams());
listener.registerAddOn(spdyAddOn);
}
listener.setSecure(secure);
server.addListener(listener);
// Map the path to the processor.
final ServerConfiguration config = server.getServerConfiguration();
if (handler != null) {
config.addHttpHandler(handler, uri.getPath());
}
config.setPassTraceRequest(true);
try {
// Start the server.
server.start();
} catch (IOException ex) {
throw new ProcessingException("IOException thrown when trying to start grizzly server", ex);
}
return server;
}
Aggregations