当前位置: 首页>>代码示例>>Java>>正文


Java NettyJaxrsServer.setHostname方法代码示例

本文整理汇总了Java中org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer.setHostname方法的典型用法代码示例。如果您正苦于以下问题:Java NettyJaxrsServer.setHostname方法的具体用法?Java NettyJaxrsServer.setHostname怎么用?Java NettyJaxrsServer.setHostname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer的用法示例。


在下文中一共展示了NettyJaxrsServer.setHostname方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String host = "0.0.0.0";
    int port = 8080;
    if (args.length > 0) {
        host = args[0];
    }
    if (args.length > 1) {
        port = Integer.parseInt(args[1]);
    }


    NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(new MyApplication());
    netty.setDeployment(deployment);
    netty.setHostname(host);
    netty.setPort(port);
    netty.setRootResourcePath("/");
    netty.setSecurityDomain(null);
    netty.start();
}
 
开发者ID:smallnest,项目名称:Jax-RS-Performance-Comparison,代码行数:22,代码来源:Main.java

示例2: test_host_for_LISTEN_ADDRESS

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
/**
 * // lsof -i:8990
 * // COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
 * 
 * @throws InterruptedException
 */
@Test
public void test_host_for_LISTEN_ADDRESS() throws InterruptedException {

    // String hostname = "10.100.0.25";
    // String hostname = "127.0.0.1";//java 29782 username 146u IPv6 0x41980098a5e8db51 0t0 TCP localhost:8990 (LISTEN)
    // String hostname = "localhost";

    String hostname = "0.0.0.0";// java 29827 username 146u IPv6 0x41980098a5e8db51 0t0 TCP *:8990 (LISTEN)
    int port = 8990;
    SecurityDomain securityDomain = null;
    String rootResourcePath = "/";
    int ioWorkerCount = Runtime.getRuntime().availableProcessors() * 2;
    int executorThreadCount = 12;

    NettyJaxrsServer nettyJaxrsServer = new NettyJaxrsServer();

    nettyJaxrsServer.setHostname(hostname);
    nettyJaxrsServer.setPort(port);
    nettyJaxrsServer.setSecurityDomain(securityDomain);
    nettyJaxrsServer.setRootResourcePath(rootResourcePath);

    nettyJaxrsServer.setIoWorkerCount(ioWorkerCount);
    nettyJaxrsServer.setExecutorThreadCount(executorThreadCount);

    ResteasyDeployment deployment = nettyJaxrsServer.getDeployment();
    List<Object> resources = new ArrayList<Object>();
    deployment.setResources(resources);
    nettyJaxrsServer.start();
    ResourceMethodRegistry resourceMethodRegistry = (ResourceMethodRegistry) deployment.getRegistry();
    resourceMethodRegistry.setWiderMatching(true);// 不设置也可以

    deployment.getRegistry().addSingletonResource(new RestServiceImpl());
    // TimeUnit.MINUTES.sleep(1);

}
 
开发者ID:sdcuike,项目名称:dubbo-rpc-rest,代码行数:42,代码来源:RestProtocolTest.java

示例3: startHttpServer

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
private void startHttpServer() throws PluginException {
    try {
        int port = Integer.parseInt(getConfig(HttpConstants.HTTP_PORT, "8018"));
        String host = getConfig(HttpConstants.HTTP_HOST, "0.0.0.0");
        int bossCount = Integer.parseInt(getConfig(HttpConstants.HTTP_BOSS_COUNT, "-1"));
        bossCount = bossCount < 0 ? Runtime.getRuntime().availableProcessors() * 2 : bossCount;
        int workCount = Integer.parseInt(getConfig(HttpConstants.HTTP_WORK_COUNT, "200"));

        LOG.info("Starting http server, listen on port->{}", port);
        netty = new NettyJaxrsServer();
        netty.setIoWorkerCount(bossCount);
        netty.setExecutorThreadCount(workCount);

        ResteasyDeployment deployment = new ResteasyDeployment();
        deployment.setProviderFactory(new ResteasyProviderFactory());
        // deployment.getProviderFactory().register(ResteasyJacksonProvider.class);
        deployment.setApplication(new ESApplication());
        netty.setDeployment(deployment);
        netty.setHostname(host);
        netty.setPort(port);
        netty.setRootResourcePath(HttpConstants.PATH_ROOT);

        netty.setSecurityDomain(null);
        if (isHttpsEnabled()) {
            // SelfSignedCertificate ssc = new SelfSignedCertificate();
            // netty.setSSLContext(SslContextBuilder.forServer(ssc.certificate(),
            // ssc.privateKey()).build());
        }

        netty.start();
        LOG.info("Start http server successfully!");
    } catch (Exception e) {
        throw new PluginException(e.getCause());
    }
}
 
开发者ID:dzh,项目名称:jframe,代码行数:36,代码来源:JfDemoESPlugin.java

示例4: main

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
/**
 * @param args
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {

    String hostname = "0.0.0.0";
    int port = 8889;
    SecurityDomain securityDomain = null;
    String rootResourcePath = "/";
    int ioWorkerCount = Runtime.getRuntime().availableProcessors() * 2;
    int executorThreadCount = 12;

    NettyJaxrsServer nettyJaxrsServer = new NettyJaxrsServer();

    nettyJaxrsServer.setHostname(hostname);
    nettyJaxrsServer.setPort(port);
    nettyJaxrsServer.setSecurityDomain(securityDomain);
    nettyJaxrsServer.setRootResourcePath(rootResourcePath);

    nettyJaxrsServer.setIoWorkerCount(ioWorkerCount);
    nettyJaxrsServer.setExecutorThreadCount(executorThreadCount);
    Map<ChannelOption, Object> channelOptions = new HashMap<ChannelOption, Object>();
    channelOptions.put(ChannelOption.CONNECT_TIMEOUT_MILLIS, 100);
    nettyJaxrsServer.setChannelOptions(channelOptions);
    nettyJaxrsServer.setChildChannelOptions(channelOptions);

    ResteasyDeployment deployment = nettyJaxrsServer.getDeployment();

    List<Object> resources = new ArrayList<>();

    // dubo 消费远程服务:当前应用配置
    ApplicationConfig dubboApp = new ApplicationConfig();
    dubboApp.setName("dubboAppClient");
    // 注册中心配置
    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress("127.0.0.1:2181");
    registryConfig.setProtocol("zookeeper");
    registryConfig.setClient("curator");
    registryConfig.setGroup("dubbo");

    ReferenceConfig<DemoService> demoServiceReferenceConfig1 = new ReferenceConfig<>();
    demoServiceReferenceConfig1.setApplication(dubboApp);
    demoServiceReferenceConfig1.setRegistry(registryConfig);
    demoServiceReferenceConfig1.setInterface(DemoService.class);
    demoServiceReferenceConfig1.setVersion("1.0");
    demoServiceReferenceConfig1.setCheck(false);
    DemoService demoService1 = demoServiceReferenceConfig1.get();

    ReferenceConfig<DemoService> demoServiceReferenceConfig2 = new ReferenceConfig<>();
    demoServiceReferenceConfig2.setApplication(dubboApp);
    demoServiceReferenceConfig2.setRegistry(registryConfig);
    demoServiceReferenceConfig2.setInterface(DemoService.class);
    demoServiceReferenceConfig2.setVersion("2.0");
    demoServiceReferenceConfig2.setCheck(false);

    DemoService demoService2 = demoServiceReferenceConfig2.get();
    deployment.setResources(resources);

    nettyJaxrsServer.start();

    // resteasy 暴露服务
    deployment.getProviderFactory().register(MyContainerRequestFilter.class);
    deployment.getRegistry().addSingletonResource(demoService1, "1.0");
    deployment.getRegistry().addSingletonResource(demoService2, "2.0");
    // TimeUnit.SECONDS.sleep(6);
    // nettyJaxrsServer.stop();
    // demoServiceReferenceConfig.destroy();

}
 
开发者ID:sdcuike,项目名称:book-reading,代码行数:71,代码来源:DubboDemoClient2Version.java

示例5: main

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
/**
 * @param args
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {

    String hostname = "0.0.0.0";
    int port = 8889;
    SecurityDomain securityDomain = null;
    String rootResourcePath = "/";
    int ioWorkerCount = Runtime.getRuntime().availableProcessors() * 2;
    int executorThreadCount = 12;

    NettyJaxrsServer nettyJaxrsServer = new NettyJaxrsServer();

    nettyJaxrsServer.setHostname(hostname);
    nettyJaxrsServer.setPort(port);
    nettyJaxrsServer.setSecurityDomain(securityDomain);
    nettyJaxrsServer.setRootResourcePath(rootResourcePath);

    nettyJaxrsServer.setIoWorkerCount(ioWorkerCount);
    nettyJaxrsServer.setExecutorThreadCount(executorThreadCount);
    Map<ChannelOption, Object> channelOptions = new HashMap<ChannelOption, Object>();
    channelOptions.put(ChannelOption.CONNECT_TIMEOUT_MILLIS, 100);
    nettyJaxrsServer.setChannelOptions(channelOptions);
    nettyJaxrsServer.setChildChannelOptions(channelOptions);

    ResteasyDeployment deployment = nettyJaxrsServer.getDeployment();
    List<Object> resources = new ArrayList<>();

    // dubo 消费远程服务:当前应用配置
    ApplicationConfig dubboApp = new ApplicationConfig();
    dubboApp.setName("dubboAppClient");
    // 注册中心配置
    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress("127.0.0.1:2181");
    registryConfig.setProtocol("zookeeper");
    registryConfig.setClient("curator");
    registryConfig.setGroup("dubbo");

    ReferenceConfig<DemoService> demoServiceReferenceConfig = new ReferenceConfig<>();
    demoServiceReferenceConfig.setApplication(dubboApp);
    demoServiceReferenceConfig.setRegistry(registryConfig);
    demoServiceReferenceConfig.setInterface(DemoService.class);
    demoServiceReferenceConfig.setCheck(false);
    DemoService demoService = demoServiceReferenceConfig.get();

    // resteasy 暴露服务

    resources.add(demoService);
    deployment.setResources(resources);
    nettyJaxrsServer.start();

    // TimeUnit.SECONDS.sleep(6);
    // nettyJaxrsServer.stop();
    // demoServiceReferenceConfig.destroy();

}
 
开发者ID:sdcuike,项目名称:book-reading,代码行数:59,代码来源:DubboDemoClient.java


注:本文中的org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer.setHostname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。