我可以使用Netty与Resteasy一起使用,或者作为文件服务器:
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>