• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GrizzlyHttpContainer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer的典型用法代码示例。如果您正苦于以下问题:Java GrizzlyHttpContainer类的具体用法?Java GrizzlyHttpContainer怎么用?Java GrizzlyHttpContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GrizzlyHttpContainer类属于org.glassfish.jersey.grizzly2.httpserver包,在下文中一共展示了GrizzlyHttpContainer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
public static HttpServer startServer() {
    HttpServer server = new HttpServer();
    server.addListener(new NetworkListener("grizzly", "0.0.0.0", 8080));

    final TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance();
    //transportBuilder.setIOStrategy(WorkerThreadIOStrategy.getInstance());
    transportBuilder.setIOStrategy(SameThreadIOStrategy.getInstance());
    server.getListener("grizzly").setTransport(transportBuilder.build());
    final ResourceConfig rc = new ResourceConfig().packages("xyz.muetsch.jersey");
    rc.register(JacksonFeature.class);
    final ServerConfiguration config = server.getServerConfiguration();
    config.addHttpHandler(RuntimeDelegate.getInstance().createEndpoint(rc, GrizzlyHttpContainer.class), "/rest/todo/");

    try {
        server.start();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return server;
}
 
开发者ID:n1try,项目名称:http-server-benchmarks,代码行数:22,代码来源:Main.java


示例2: startSecureServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
/**
 * Starts Grizzly HTTP server exposing JAX-RS resources defined in this
 * application.
 *
 * @return Grizzly HTTP server.
 */
public static HttpServer startSecureServer ()
{
  if (false)
    System.setProperty ("javax.net.debug", "all");

  final WebappContext aContext = _createContext (BASE_URI_HTTPS);

  final SSLContextConfigurator aSSLContext = new SSLContextConfigurator ();
  aSSLContext.setKeyStoreFile ("src/test/resources/test-https-keystore.jks");
  aSSLContext.setKeyStorePass ("password");
  aSSLContext.setKeyStoreType ("JKS");
  aSSLContext.setTrustStoreBytes (StreamHelper.getAllBytes (new ClassPathResource (PeppolKeyStoreHelper.TRUSTSTORE_COMPLETE_CLASSPATH)));
  aSSLContext.setTrustStorePass (PeppolKeyStoreHelper.TRUSTSTORE_PASSWORD);
  aSSLContext.setTrustStoreType ("JKS");
  aSSLContext.setSecurityProtocol ("TLSv1.2");

  final SSLEngineConfigurator aSSLEngine = new SSLEngineConfigurator (aSSLContext);
  aSSLEngine.setClientMode (false);
  aSSLEngine.setNeedClientAuth (true);
  aSSLEngine.setEnabledCipherSuites (new String [] { "TLS_RSA_WITH_AES_128_CBC_SHA",
                                                     "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
                                                     "TLS_RSA_WITH_AES_128_CBC_SHA256",
                                                     "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
                                                     "TLS_RSA_WITH_AES_128_CBC_SHA" });

  // create and start a new instance of grizzly https server
  // exposing the Jersey application at BASE_URI
  final HttpServer ret = GrizzlyHttpServerFactory.createHttpServer (URI.create (BASE_URI_HTTPS),
                                                                    (GrizzlyHttpContainer) null,
                                                                    true,
                                                                    aSSLEngine,
                                                                    true);
  aContext.deploy (ret);
  return ret;
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:42,代码来源:MockServer.java


示例3: get

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
@Override
protected HttpHandler get(Injector injector, Configurations configurations) {

    /* Setup our object mapper (could be qualified with path) */
    final ObjectMapper mapper = getInstance(injector, ObjectMapper.class, path);

    final Map<Class<?>, Integer> contractPriorities = new HashMap<>();
    contractPriorities.put(MessageBodyWriter.class, Integer.MIN_VALUE);
    contractPriorities.put(MessageBodyReader.class, Integer.MIN_VALUE);
    config.register(new JacksonJsonProvider(mapper,
                new Annotations[] { Annotations.JACKSON, Annotations.JAXB }),
                Collections.unmodifiableMap(contractPriorities));

    /* Create a ServiceLocator parent of all locators and inject the configurations */
    final ServiceLocator locator = ServiceLocatorFactory.create(injector, path);

    /* Set up the ObjectMapper that will be used by this application */
    ServiceLocatorUtilities.addOneConstant(locator, mapper, null, ObjectMapper.class);

    /* Create a brand new Grizzly HTTP container from Jersey */
    log.debug("Jersey application at \"%s\" initializing", path.value());
    GrizzlyHttpContainer container = GrizzlyHttpContainerFactory.create(config, locator);
    log.info("Jersey application at \"%s\" initialized successfully", path.value());

    /* Create our handler and add it to our server configuration  */
    final HttpServer server = injector.getInstance(HttpServer.class);
    server.getServerConfiguration().addHttpHandler(container, path.value());
    log.info("Serving \"%s\" using Jersey application \"%s\"", path.value(), config.getApplicationName());

    /* All done! */
    return container;
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:33,代码来源:RestHandlerProvider.java


示例4: startServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
/**
 * Starts Grizzly HTTP server exposing static content, JAX-RS resources
 * and web sockets defined in this application.
 *
 * @param webRootPath static content root path.
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer(String webRootPath) 
{
    final HttpServer server = new HttpServer();
    final NetworkListener listener = new NetworkListener("grizzly", BASE_URI, PORT);

    server.addListener(listener);

    final ServerConfiguration config = server.getServerConfiguration();
    // add handler for serving static content
    config.addHttpHandler(new StaticContentHandler(webRootPath), APP_PATH);

    // add handler for serving JAX-RS resources
    config.addHttpHandler(  RuntimeDelegate
                            .getInstance()
                            .createEndpoint(new ResourceConfig().packages("it.unito.geosummly.api"),
                                            GrizzlyHttpContainer.class),
                                            API_PATH
                          );

    try {
        // Start the server.
        server.start();
    } catch (Exception ex) {
        throw new ProcessingException("Exception thrown when trying to start grizzly server", ex);
    }

    return server;
}
 
开发者ID:giusepperizzo,项目名称:geosummly,代码行数:36,代码来源:Server.java


示例5: create

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
public static GrizzlyHttpContainer create(final Application application) {
    return create(new Class<?>[]{ Application.class },
                  new Object[]  { application });
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:5,代码来源:GrizzlyHttpContainerFactory.java


示例6: createServer

import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer; //导入依赖的package包/类
private HttpServer createServer(URI uri, ResourceConfig configuration) {
		GrizzlyHttpContainer handler = ContainerFactory.createContainer(GrizzlyHttpContainer.class, configuration);
		boolean secure = false;
		SSLEngineConfigurator sslEngineConfigurator = null;
		boolean start = false;

		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);
		}

		// insert
//		listener.

		CompressionConfig cg = listener.getCompressionConfig();
		cg.setCompressionMode(CompressionConfig.CompressionMode.ON);
//		cg.setCompressableMimeTypes("text","application/json");
		// end insert

		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);

		if (start) {
			try {
				// Start the server.
				server.start();
			} catch (IOException ex) {
				throw new ProcessingException("IOException thrown when trying to start grizzly server", ex);
			}
		}

		return server;
	}
 
开发者ID:jakobwenzel,项目名称:rallye-server,代码行数:46,代码来源:RallyeServer.java



注:本文中的org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JSONException类代码示例发布时间:2022-05-23
下一篇:
Java TubelineassemblyMessages类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap