我可以将 Netty 与Resteasy或作为Fileserver一起使用:
public void file()
{
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
bootstrap.setPipelineFactory(new HttpStaticFileServerPipelineFactory());
bootstrap.bind(new InetSocketAddress(8080));
}
public void rest()
{
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.getActualResourceClasses().add(RestClass.class);
NettyJaxrsServer netty = new NettyJaxrsServer();
netty.setDeployment(deployment);
netty.setPort(8080);
netty.setRootResourcePath("");
netty.setSecurityDomain(null);
netty.start();
}
两者都可以使用不同的端口,但是如何集成在单个端口上运行一个 Netty 服务器的两种方法?
更新 目前我使用这个设置:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty</artifactId>
<version>3.0.1.Final</version>
</dependency>