use of org.glassfish.grizzly.http.server.NetworkListener in project ddf by codice.
the class SecureStubServer method run.
/**
* Starts the server
*/
public SecureStubServer run() {
simpleServer.getServerConfiguration().addHttpHandler(stubsToHandler(), "/");
try {
if (secured) {
for (NetworkListener networkListener : simpleServer.getListeners()) {
networkListener.setSecure(true);
SSLEngineConfigurator sslEngineConfig = new SSLEngineConfigurator(getSslConfig(), false, false, false);
networkListener.setSSLEngineConfig(sslEngineConfig);
}
}
simpleServer.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
return this;
}
use of org.glassfish.grizzly.http.server.NetworkListener in project dukescript-presenters by dukescript.
the class Browser method pageURL.
private static URI pageURL(String protocol, HttpServer server, final String page) {
NetworkListener listener = server.getListeners().iterator().next();
int port = listener.getPort();
try {
return new URI(protocol + "://localhost:" + port + page);
} catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
}
}
use of org.glassfish.grizzly.http.server.NetworkListener in project ff4j by ff4j.
the class AbstractEmbeddedGrizzlyIntegrationTest method initOnce.
@BeforeClass
public static void initOnce() throws IOException {
// WebContext for testing
webappContext = new WebappContext("Test Context");
ServletRegistration servletRegistration = webappContext.addServlet("jersey-servlet", ServletContainer.class);
servletRegistration.setInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter("javax.ws.rs.Application", SampleFF4jJersey2Application.class.getCanonicalName());
servletRegistration.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
servletRegistration.addMapping("/*");
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(JacksonJsonProvider.class);
clientConfig.register(FF4jJacksonMapper.class);
client = ClientBuilder.newClient(clientConfig);
server = new HttpServer();
NetworkListener listener = new NetworkListener("grizzly2", HOST, PORT);
server.addListener(listener);
webappContext.deploy(server);
}
use of org.glassfish.grizzly.http.server.NetworkListener in project narayana by jbosstm.
the class SpdyEnabledHttpServer method addSpdy.
private static void addSpdy(HttpServer server) {
NetworkListener listener = server.getListener("grizzly");
SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);
}
use of org.glassfish.grizzly.http.server.NetworkListener in project OpenTripPlanner by opentripplanner.
the class BrokerMain method run.
public void run() {
int port = config.getProperty("port") != null ? Integer.parseInt(config.getProperty("port")) : DEFAULT_PORT;
String addr = config.getProperty("bind-address") != null ? config.getProperty("bind-address") : DEFAULT_BIND_ADDRESS;
LOG.info("Starting analyst broker on port {} of interface {}", port, addr);
HttpServer httpServer = new HttpServer();
NetworkListener networkListener = new NetworkListener("broker", addr, port);
// We avoid blocking IO, and the following line allows us to see closed connections.
networkListener.getTransport().setIOStrategy(SameThreadIOStrategy.getInstance());
httpServer.addListener(networkListener);
// Bypass Jersey etc. and add a low-level Grizzly handler.
// As in servlets, * is needed in base path to identify the "rest" of the path.
broker = new Broker(config, addr, port);
httpServer.getServerConfiguration().addHttpHandler(new BrokerHttpHandler(broker), "/*");
try {
httpServer.start();
LOG.info("Broker running.");
// run queue broker task pump in this thread
broker.run();
Thread.currentThread().join();
} catch (BindException be) {
LOG.error("Cannot bind to port {}. Is it already in use?", port);
} catch (IOException ioe) {
LOG.error("IO exception while starting server.");
} catch (InterruptedException ie) {
LOG.info("Interrupted, shutting down.");
}
httpServer.shutdown();
}
Aggregations