本文整理汇总了Java中org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java NettyJaxrsServer.setPort方法的具体用法?Java NettyJaxrsServer.setPort怎么用?Java NettyJaxrsServer.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer
的用法示例。
在下文中一共展示了NettyJaxrsServer.setPort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
public void start() {
ResteasyDeployment dp = new ResteasyDeployment();
Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();
Assert.notEmpty(controllers);
// extract providers
if (providers != null) {
dp.getProviders().addAll(providers);
}
// extract only controller annotated beans
dp.getResources().addAll(controllers);
netty = new NettyJaxrsServer();
netty.setDeployment(dp);
netty.setIoWorkerCount(ioWorkerCount);
netty.setExecutorThreadCount(executorThreadCount);
netty.setPort(port);
netty.setRootResourcePath(rootResourcePath);
netty.setSecurityDomain(null);
netty.start();
LOGGER.info("rest-netty-server started , port {}", port);
}
示例2: 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();
}
示例3: createServer
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
private static NettyJaxrsServer createServer(ResteasyDeployment deployment) throws Exception {
NettyJaxrsServer netty = new NettyJaxrsServer();
netty.setDeployment(deployment);
netty.setPort(8080);
netty.setRootResourcePath("");
netty.setSecurityDomain(null);
return netty;
}
示例4: 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);
}
示例5: start
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
public void start() {
ResteasyDeployment dp = new ResteasyDeployment();
Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();
Assert.notEmpty(controllers);
// extract providers
if (providers != null) {
dp.getProviders().addAll(providers);
}
// extract only controller annotated beans
dp.getResources().addAll(controllers);
Map<String, Object> channelOptions = new HashMap<String, Object>();
channelOptions.put("reuseAddress", true);
List<ChannelHandler> channelHandlerList = new ArrayList<ChannelHandler>();
channelHandlerList.add(channelHandler);
channelHandlerList.add(idleStateHandler);
channelHandlerList.add(healthCheckHandler);
netty = new NettyJaxrsServer();
netty.setChannelOptions(channelOptions);
netty.setDeployment(dp);
netty.setPort(port);
netty.setRootResourcePath("/resteasy");
netty.setIoWorkerCount(ioWorkerCount);
netty.setExecutorThreadCount(executorThreadCount);
netty.setMaxRequestSize(maxRequestSize);
netty.setSSLContext(sslContext);
netty.setKeepAlive(true);
netty.setChannelHandlers(channelHandlerList);
netty.setSecurityDomain(null);
netty.start();
}
示例6: 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());
}
}
示例7: setupServer
import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer; //导入方法依赖的package包/类
private void setupServer(Application application) {
Properties serverProperties = readProperties();
int port = Integer.parseInt(serverProperties.getProperty(PORT_PROPERTY));
server = new NettyJaxrsServer();
server.setRootResourcePath(ROOT_RESOURCE_PATH);
server.setPort(port);
server.getDeployment().setApplication(application);
}
示例8: 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();
}
示例9: 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();
}