本文整理匯總了Java中org.glassfish.grizzly.http.server.HttpServer.createSimpleServer方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServer.createSimpleServer方法的具體用法?Java HttpServer.createSimpleServer怎麽用?Java HttpServer.createSimpleServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.glassfish.grizzly.http.server.HttpServer
的用法示例。
在下文中一共展示了HttpServer.createSimpleServer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerWebsocket
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
private void registerWebsocket() throws IOException {
Configuration configuration = ConfigurationReader.INSTANCE.readConfiguration("core-site.xml");
websocketServicePort = Integer
.parseInt(configuration.get("events.server.websocket.port", "8082"));
try {
ServerSocket s = new ServerSocket(websocketServicePort);
websocketServicePort = s.getLocalPort();
s.close();
waitTillSocketIsClosed(s);
String webSocketserviceHost = java.net.InetAddress.getLocalHost().getHostAddress();
final HttpServer server = HttpServer.createSimpleServer(null, webSocketserviceHost,
websocketServicePort);
for (NetworkListener listener : server.getListeners()) {
listener.registerAddOn(new WebSocketAddOn());
}
WebSocketEngine.getEngine().register("", "/event-stream", new EventsSocketApplication());
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
}, "Server-Showdown-Thread"));
} catch (IOException | InterruptedException e) {
throw new IllegalStateException("Failed to start api-service. name = events.service", e);
}
}
示例2: httpServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Bean
public HttpServer httpServer()
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, KeyStoreException,
FileNotFoundException, CertificateException, UnrecoverableEntryException, ConfigurationException {
HttpServer server = HttpServer.createSimpleServer("./", 8080);
WebSocketAddOn addon = new WebSocketAddOn();
server.getListeners().stream().forEach((listen) -> {
listen.registerAddOn(addon);
listen.setSecure(true);
listen.setSSLEngineConfig(
new SSLEngineConfigurator(this.sslConf()).setClientMode(false).setNeedClientAuth(false));
});
String messengerPath = configuration().getString(GlobalConfig.MESSENGER_PATH);
if (messengerPath == null) {
messengerPath = GlobalConfig.MESSENGER_PATH_DEFAULT;
}
ChatApplication application = this.chatApplication();
WebSocketEngine.getEngine().register("", messengerPath, application);
return server;
}
示例3: PullServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public PullServer(PushSerConfig config) {
this.wsContext = new PushContext(config);
this.center = new MessageCenter();
PreCheckListener check = new PreCheckListener(center);
ProtocolManager instance = ProtocolManager.getInstance();
instance.addCodec(new RFC6455CodecImpl());
this.wsContext.setProtocolManager(instance);
this.wsContext.addConnListener(check);
this.wsContext.setMessageCenter(center);
this.port = config.getPort();
String base = config.getResourceBase();
server = HttpServer.createSimpleServer(base, port);
sercfg = server.getServerConfiguration();
sercfg.getMonitoringConfig().getWebServerConfig().addProbes(this);
doInit(center);
}
示例4: start
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void start(final ApplicationContext applicationConfig, final int port, String path) {
try {
// Logging settings
InputStream loggingStream = GrizzlyServer.class.getResourceAsStream("/logging.properties");
if (nonNull(loggingStream)) {
LogManager.getLogManager().readConfiguration(loggingStream);
}
HttpServer server = HttpServer.createSimpleServer(null, port);
server.getServerConfiguration().addHttpHandler(
new GrizzlyApplicationHandler(applicationConfig), path);
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow));
server.start();
LOG.info("Grizzly Server started. Stop the application using ^C.");
Thread.currentThread().join();
} catch (IOException | InterruptedException e) {
LOG.log(Level.SEVERE, null, e);
}
}
示例5: runHttpServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
private static void runHttpServer() throws IOException, InterruptedException {
logger.info("Http Server starting");
final HttpServer server = HttpServer.createSimpleServer("/",10024);
final ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(new UpdateLocationApi(), "/yelli/update");
config.addHttpHandler(new CreateTrackerApi(), "/yelli/create");
config.addHttpHandler(new TestServelet(), "/yelli/test");
config.setJmxEnabled(true);
server.start();
}
示例6: startServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer(int port, Action<ServerWebSocket> websocketAction) throws Exception {
server = HttpServer.createSimpleServer(null, port);
NetworkListener listener = server.getListener("grizzly");
listener.registerAddOn(new WebSocketAddOn());
WebSocketEngine.getEngine().register("", TEST_URI, new AsityWebSocketApplication()
.onwebsocket(websocketAction));
server.start();
}
示例7: startServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer(int port, Action<ServerHttpExchange> requestAction) throws Exception {
server = HttpServer.createSimpleServer(null, port);
ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(new AsityHttpHandler().onhttp(requestAction), TEST_URI);
server.start();
}
示例8: IPCamServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
* @param httpPort the http port to server on
*/
public IPCamServer(int httpPort) {
mCamDevices = new ConcurrentHashMap<>();
synchronized (serverMonitor) {
server = HttpServer.createSimpleServer(null, httpPort);
server.getServerConfiguration().addHttpHandler(new IndexHandler(mCamDevices));
}
}
示例9: startServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer() throws Exception {
server = HttpServer.createSimpleServer(null, port);
NetworkListener listener = server.getListener("grizzly");
listener.registerAddOn(new WebSocketAddOn());
WebSocketEngine.getEngine().register("", "/test", new VibeWebSocketApplication().onwebsocket(performer.serverAction()));
server.start();
}
示例10: startServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer() throws Exception {
server = HttpServer.createSimpleServer(null, port);
ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(new VibeHttpHandler().onhttp(performer.serverAction()), "/test");
server.start();
}
示例11: startWebserver
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@BeforeClass
public static void startWebserver() throws IOException {
MimeType.add("mp4", "video/mp4");
server =
HttpServer.createSimpleServer(
Samples.TEST_PREFIX, "127.0.0.1", new PortRange(10000, 60000));
server.start();
LOG.info("Started server at {}", getWebserverRoot());
}
示例12: setUp
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String httpRoot = URLDecoder.decode(new File(getClass().getResource("/").getFile()).getAbsolutePath(), "utf-8");
httpServer = HttpServer.createSimpleServer(httpRoot, "localhost", 9997);
// Disable file cache to fix https://java.net/jira/browse/GRIZZLY-1350
((StaticHttpHandler) httpServer.getServerConfiguration().getHttpHandlers().keySet().iterator().next()).setFileCacheEnabled(false);
httpServer.start();
}
示例13: initServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
final HttpServer initServer(Bck2Brwsr.Resources... extraResources) throws IOException {
xRes.addAll(Arrays.asList(extraResources));
HttpServer s = HttpServer.createSimpleServer(".", new PortRange(8080, 65535));
final ServerConfiguration conf = s.getServerConfiguration();
conf.addHttpHandler(new VM(resources), "/bck2brwsr.js");
conf.addHttpHandler(new VMInit(), "/vm.js");
conf.addHttpHandler(new Classes(resources), "/classes/");
return s;
}
示例14: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) {
Server server = new Server(HOST, WEB_SOCKET_PORT, WEB_SOCKET_CONTEXT, EchoEndpoint.class);
HttpServer httpServer = HttpServer.createSimpleServer(HTTP_SERVER_CONTEXT_ROOT, HOST, HTTP_SERVER_PORT);
try {
server.start();
httpServer.start();
System.out.println("Please press a key to stop the server.");
System.in.read();
} catch (Exception e) {
e.printStackTrace();
} finally {
httpServer.stop();
server.stop();
}
}
示例15: run
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public void run(CompletableFuture start, JaxRsServletConfigurer jaxRsConfigurer, CompletableFuture end) {
WebappContext webappContext = new WebappContext("WebappContext", "");
new ServletContextListenerConfigurer(serverData, servletContextListenerData, servletRequestListenerData);
jaxRsConfigurer.addServlet(this.serverData,webappContext);
new ServletConfigurer(serverData, servletData).addServlets(webappContext);
new FilterConfigurer(serverData, this.filterData).addFilters(webappContext);
addListeners(webappContext);
HttpServer httpServer = HttpServer.createSimpleServer(null, "0.0.0.0", serverData.getPort());
serverData.getModule().getServerConfigManager().accept(new WebServerProvider(httpServer));
addAccessLog(httpServer);
addSSL(httpServer);
startServer(webappContext, httpServer, start, end);
}