我可以在恢复期或文件服务器中使用Netty
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>发布于 2013-06-24 08:06:38
基本上,您必须将不同的处理程序组合成一个新的ServerPipelineFactory。一种方法是创建一个管道,该管道的公共处理程序已经就位,再加上一个"dispatcher“处理程序,它检查请求,并根据URL路径动态添加处理程序,用于静态文件服务或resteasy处理。
https://stackoverflow.com/questions/17260102
复制相似问题