Hi all,

I've researched this a bit more, and I see now that Continuations are
a bit trickier to use than I had originally realized. It seems that in
order to use continuations, one must run a script in interpreted mode,
rather than compiled mode. So this line works:

jbea...@ubuntu:~$ rhino -opt -1 -f test.js

While this line fails:

jbea...@ubuntu:~$ rhino -opt 0 -f test.js
js: Direct call is not supported

I'm now no longer sure if what I'm trying to do can be achieved. I
want to create a servlet, but do so in pure Rhino, so without any Java
"host" code that would create Rhino in a scripting context. In order
to achieve this, I've created a script with top-level servlet methods
(doPost, doGet, etc.), and used rhino's jsc tool with the options
"-extends javax.servlet.http.HttpServlet". With this approach, I've
successfully compiled class files that I've been able to deploy onto
Tomcat. I've been very happy with how well this has worked so far.

Continuations are obviously useful in the context of web programming,
but I'm not sure if I can leverage them using the above approach. I
think I need to create class files in order to deploy my rhino code to
Tomcat, however, it does not appear as thought I can use jsc to create
class files if that code includes Continuations. Although, strangely,
jsc can take an -opt argument of -1, implying that it can "compile
class files in interpreted mode". If someone could please let me know
whether it is possible to use jsc to create class files from Rhino
scripts that use Continuations, I'd really appreciate it.

If I cannot use jsc to create class files from Rhino scripts that use
Continuations, then it seems I may need to create a Java class which
extends HttpServlet to act as the host, and then delegate to a
scripting context, running in interpreted mode, which uses
Continuations. I think this programming model is much more confusing
than just compiling a Rhino script, but it may be that this is the
only way to leverage Rhino's continuations for web programming when
targeting servlets. If anyone could offer any guidance on this, I'd
appreciate it.

Thanks,

Jake


On Thu, Oct 8, 2009 at 10:10 PM, Jacob Beard <[email protected]> wrote:
> Hi all,
>
> I'm encountering very strange behaviour involving Continuations with
> Rhino 1.7R1 (packaged with Ubuntu Jaunty), and the latest 1.7R2. I can
> create a new continuation within the Rhino shell, but cannot create
> one when interpreting a script file. Please see the following:
>
> jbea...@ubuntu:~$ cat test.js
> new Continuation();
> jbea...@ubuntu:~$ rhino test.js
> js: Direct call is not supported
>
> jbea...@ubuntu:~$ rhino
> Rhino 1.7 release 1 2008 10 20
> js> new Continuation();
> [object Continuation]
> js>
> jbea...@ubuntu:~$
>
>
> Googling has not been productive, and I can't find a related bug in
> Bugzilla. If anyone has any insight into this, I would greatly
> appreciate it if you would let me know.
>
> Thanks,
>
> Jake
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to