欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  资讯频道

DWR支持Grizzly Comet框架的补丁

程序员文章站 2022-06-04 08:32:03
...
Jean-Francois Arcand编写了一个DWR的补丁,可以让DWR的用户通过Reverse Engine来使用Grizzly Comet框架了。Grizzly真的是现在非常火爆的Java AJAX异步调用服务器端框架。

因为DWR也支持Jetty Continuations实现的异步调用,Jean-Francois Arcand比较了两种实现方法:

通过Jetty Continuations挂起连接:

Continuation continuation = ContinuationSupport.getContinuation(request, mutex);
continuation.suspend(timeout);


通过Grizzly挂起连接:

CometContext ctx = CometEngine.getEngine().register("DWR");
  CometHandler continuationHandler = new CometHandler() {
        public void attach(Object o) {
        }
        public void onEvent(CometEvent cometEvent) throws IOException {
        }
        public void onInitialize(CometEvent cometEvent) throws IOException {
        }
        public void onInterrupt(CometEvent cometEvent) throws IOException {
        }
        public void onTerminate(CometEvent cometEvent) throws IOException {
        }
    };
  ctx.setExpirationDelay(sleepTime);
  ctx.addCometHandler(continuationHandler);


Jean-Francois Arcand认为虽然Grizzly的实现方法略微复杂一些,但是Grizzly可以通过CometHandler在连接之间共享信息,要比Jetty Continuations功能强大,程序员有更多的控制能力。

也许我们应该多多关注Grizzly了。
相关标签: Comet DWR 框架