📄 ch05s01.html
字号:
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>1. Rife和Continuation</title><link rel="stylesheet" href="html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="Java网络程序员看Continuation"><link rel="up" href="ch05.html" title="Chapter 5. RIFE简介"><link rel="prev" href="ch05.html" title="Chapter 5. RIFE简介"><link rel="next" href="ch05s02.html" title="2. 安装和启动Rife"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1. Rife和Continuation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><th width="60%" align="center">Chapter 5. RIFE简介</th><td width="20%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e639"></a>1. Rife和Continuation</h2></div></div></div><p>所以,如果您现在就想在Java平台上用continuation,那么您其实没有太多的选择。比较著名的Java框架中,Rife是唯一一个支持continuation的。不过这里先要警告您一下,Rife是一个相当大的框架,它在从ORM映射到html模版到CRUD操作等等全部层次上都有一套自己的做法。其作者Geert Bevin称之为full stack framework,也就是您只需要用Rife一个框架就能满足所有的需求。不过,要重新学习这样庞大的一个系统恐怕不是每个程序员都愿意做的事,而且很多时候我们也不能突然把整个结构都换成一个新的框架。所以,您可能应该先在一些简单的、独立的项目中试试Rife。</p><p>Rife感觉上非常的Java。它用XML集中配制程序结构,支持部件的同时也支持基于页面编程,讲究view和controller之间的分层,template中只能有简单的Rife自定义的表达式和OGNL代码,等等。所以如果Seaside前卫的结构让您一时手足无措的话,您不用担心Rife会有一样的问题。</p><p>学习Rife之前,我们先简单的介绍一下Rife底层的continuation处理。Rife的continuation实现方法和我们上一章讲的基于stack方法非常相似,不过我们的RecordStackException在Rife中叫做PauseException,我们的RuntimeStack在Rife中叫做ContinuationContext。另外,Rife中包括了一个基于asm的bytecode处理器,用来把通常的代码转换成我们上一章介绍的模式,有兴趣的读者可以自己看看com.uwyn.rife.engine.ResumableMethodAdapter的代码,它负责真正的bytecode转换。注意Rife的API文档里似乎没有列出这个类。</p><p>Rife的continuation支持主要在com.uwyn.rife.engine.ElementSupport类中,Rife里最重要的类,com.uwyn.rife.engine.Element(相当于我们通常所讲的部件Component),就是ElementSupport的子类。ElementSupport中有我们熟悉的call(),answer()函数和另一个pause()。我们在后面的例子中会看到pause()的用法。基于效率的考虑,Rife的continuation只支持com.uwyn.rife.engine.Element一个类中的processElement()一个方法。不过如果您遵循Rife的编程方法,这不应该是太大的限制。</p><p>Rife在编程风格上给了我们一个选择,我们即可以用continuation编程,也可以用传统的基于页面的方法编程。本文下面的例子中重点展示Rife中的continuation风格编程。如果您有兴趣了解更多Rife的内容,您可以去Rife的网站:<code class="uri">www.rifers.org</code>。</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. RIFE简介 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 2. 安装和启动Rife</td></tr></table></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -