我有这个Restlet结构:
我实例化一个Server对象:
server = new Server(new Context(), config.getServerProtocol(), config
.getServerPort());在我实例化了一个新的扩展应用程序的MyApp类之后:
app = new org.myproject.restlet.server.MyApp(
config, server.getContext());
app.start();并启动服务器:
server.setNext(app);
server.start();我没有任何组件,MyApp分发到路由器并处理请求。如果在这一点上任何人有什么意见,都将不胜感激。我使用Restlet 2.0.14 JSE,并链接jetty jars以像使用我的http服务器一样使用它。我的服务器运行得很好,我有一个javascript客户端,用一个经典的轮询来进行ajax调用。但我需要在服务器中实现长轮询(出于某些原因,我放弃了流和推送模式)。我正在阅读关于如何实现这一点的文章,第一种方式(丑陋的方式)可能是:-休眠服务器中的线程,并在服务器可能有什么东西时恢复。这种方式被丢弃,因为它是不可伸缩的(here are a post about it)。+第二种方式可能是使用版本7的Jetty continuations api。在这个link中,我可以看到如何使用jetty comet api来挂起请求,但我不知道如何应用于我的restlet实现,如此another link中所述,我可以看到:
Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.suspend();但是getContinuation方法接收一个ServletRequest对象。但我的请求不是ServletRequest。有人知道如何在restlet中转换或使用ServletRequest吗?可能我没有掌握服务器编程的所有概念。
发布于 2012-07-30 19:05:42
我不能对Restlet实例化的Jetty使用jetty continuations。为了实现长轮询,我忘记了Restlet,并使用java并发实现:wait() & notify(),一切运行正常。
https://stackoverflow.com/questions/11361970
复制相似问题