Helma Logo
main list history

Version 26 by hannes on 03. April 2008, 23:32

65As of 2007/02/082008/02/08, serialization issues in combination with Continuations and Javascript functions in general have been fixed in Subversion, so it's no longer a problem to use continuations in combination with persistent sessions.

Version 25 by hannes on 18. February 2008, 16:17

11While adding continuation and callback support to existing Helma releases has been a bit of a hack, recent Helma snapshots have added features to make that easier, namely the introduction of *req.uri|https://dev.helma.org/trac/helma/changeset/8774* and *req.actionProcessor|https://devactionHandler|https://dev.helma.org/trac/helma/changeset/8775*org/trac/helma/changeset/8792*.

Version 24 by hannes on 08. February 2008, 17:03

65An area that still needs work is serialization supportAs of 2007/02/08, as continuations currently will not work serialization issues in conjunction combination with persistent sessions. Persistent HopObjects shouldn't be included Continuations and Javascript functions in a serialized continuation, so we need to convert Nodes into NodeHandles general have been fixed in the output streamSubversion, and convert back to Nodes in the input stream. The latter currently fails in session restore because it requires a Transactor thread. For global references we need to make sure theyso it're excluded from serialization. Helma 1.7 seems like s no longer a good timeframe problem to fix these issuesuse continuations in combination with persistent sessions.

Version 23 by hannes on 05. February 2008, 17:49

41This action displays three pages: the first renders a form, the second a link, and the third will show a message containing the string entered in the first page. Remember that for continuatino continuation support to work, you must call Continuation.resume() in onRequest():

Version 22 by hannes on 05. February 2008, 17:45

22
23And although continuations work best with POST forms and ordinary links, if you must use GET forms, there also is:
24

Version 21 by hannes on 05. February 2008, 17:41

38This action displays three pages: the first renders a form, the second a link, and the third will show a message containing the string entered in the first page. Remember that for continuatino support to work, you must call Continuation.resume() in onRequest():
39
40  function onRequest() {
41    Continuation.resume();
42  }

Version 20 by hannes on 05. February 2008, 17:29

22* Continuation.nextId() - returns the ID for the next contiuation for cases GET forms where it isn't possible to use Continuation.nextUrl() and the continuation_id has to be set via hidden input field (GET requests)field.

Version 19 by hannes on 05. February 2008, 17:24

17This adds four the following static methods to the Continuation constructor:
19* Continuation.nextId() - returns the ID for the next contiuation for cases where it isn't possible to use Continuation.nextUrl() and the continuation_id has to be set via hidden input field (GET requests).
23* Continuation.nextId() - returns the ID for the next contiuation for cases where it isn't possible to use Continuation.nextUrl() and the continuation_id has to be set via hidden input field (GET requests).

Version 18 by hannes on 05. February 2008, 17:23

19* Continuation.nextId() - returns the ID for the next contiuation for cases where it isn't possible to use Continuation.nextUrl() (namely GET requests, as Continuation.nextUrl())and the continuation_id has to be set via hidden input field (GET requests).
20* Continuation.nextUrl() - returns the URL to the next continuation of the currently running action to be used in HTML POST forms and links. Note that the continuation doesn't exist yet until Continuation.nextPage() is called.

Version 17 by hannes on 05. February 2008, 17:21

17This adds three four static methods to the Continuation constructor:
19* Continuation.nextId() - returns the ID for the next contiuation for cases where it isn't possible to use Continuation.nextUrl() (namely GET requests, as Continuation.nextUrl()).

Version 16 by hannes on 05. February 2008, 17:18

50      res.debug("continuation Continuation invalid or expired. starting Starting over.");
52    // ...Continue rendering first page

Version 15 by hannes on 05. February 2008, 17:17

47      // Request has a continuation_id, but we landed at the beginning
50      // Do what needs to be doneres.debug("continuation invalid or expired. starting over.");
54    // From now here on, req.data.continuation_id is expected to be set

Version 14 by hannes on 05. February 2008, 17:05

7Rhino continuations only work in interpreter mode with the compiler disabled, iso make sure that you have the following in your app.e. with optlevel -1.properties:
8
9  rhino.optlevel = -1

Version 13 by hannes on 05. February 2008, 16:55

41This has the great benefit that trying to run a non-existing continuation (either because the link has been passed outside the originating session, or because the session has expired, or because the client does not support cookies) will actually result in the right page action being invoked - it will simply result in the action to be started from the beginning. So in order to detect all these cases, it is sufficient to test for a <code>continuation_id</code> parameter at the very beginning of the action:

Version 12 by hannes on 05. February 2008, 16:31

17* Continuation.nextUrl() - This returns the URL to the next continuation of the currently running action to be used in HTML forms and links. Note that the continuation doesn't exist yet until Continuation.nextPage() is called.
18* Continuation.nextPage() - This actually suspends execution and stores the suspended action in the user's session.
19* Continuation.resume() - This must be called in the onRequest() method of the current object in order to allow the continuation to be resumed. 

Version 11 by hannes on 05. February 2008, 16:29

24    res.write(<form method="post" action={ Continuation{Continuation.nextUrl() }>nextUrl()}>

Version 10 by hannes on 05. February 2008, 16:28

41This has the great benefit that trying to run a non-existing continuation (either because the link has been passed outside the originating session, or because the session has expired, or because the client does not support cookies) will actually result in the right page being invoked - it will simply result in the action to be started from the beginning. So in order to detect all these cases, it is sufficient to test for a <code>continuation_id</code> parameter at the very beginning of the action:

Version 9 by hannes on 05. February 2008, 16:28

17* Continuation.nextUrl() - This returns the URL to the next continuation of the currently running action. The URL can action to be used in HTML forms and links. Note that the continuation doesn't exist yet until Continuation.nextPage() is called.
37When running the example, you will notice that the continuations have the same URI path as the original action, just with a <code>continuation_id</code> query parameter added. This has the great benefit that trying to run a non-existing continuation (either because the link has been passed outside the originating session, or because the session has expired, or because the client does not support cookies) will actually result in the right page being invoked - it will simply result in the action to be started from the beginning. So in order to detect all these cases, it is sufficient to test for a <code>continuation_id</code> parameter at the beginning of the action:added:
38
39  /test.continuation?continuation_id=at5fgn5zz18g
40
41This has the great benefit that trying to run a non-existing continuation (either because the link has been passed outside the originating session, or because the session has expired, or because the client does not support cookies) will actually result in the right page being invoked - it will simply result in the action to be started from the beginning. So in order to detect all these cases, it is sufficient to test for a <code>continuation_id</code> parameter at the beginning of the action:

Version 8 by hannes on 05. February 2008, 16:25

43      // or the link comes from another session. Do what needs
44      // Do what needs to be done.

Version 7 by hannes on 05. February 2008, 16:24

39    function continuation_action()
40        if (req.data.continuation_id)
41            // Request has a continuation_id, but we landed at the
42            // beginning of the action. Either the session timed out,
43            // or the link comes from another session. Do what needs
44            // to be done.
45        }
46        // ...
47        Continuation.nextPage();
48        // From now on, req.data.continuation_id is expected to be set
41    // ...
42    Continuation.nextPage();
43    // From now on, req.data.continuation_id is expected to be set
44  }

Version 6 by hannes on 05. February 2008, 16:23

11The following framework makes use of these features script is a first prototype for adding Continuation support to allow storing suspended functions in the user's session object and resuming them at a later time:Helma 1.7 web framework.
15This adds three static methods to the Continuation constructor:
16
17* Continuation.nextUrl() - This returns the URL to the next continuation of the currently running action. The URL can be used in HTML forms and links.
18* Continuation.nextPage() - This actually suspends execution and stores the suspended action in the user's session.
19* Continuation.resume() - This must be called in the onRequest() method of the current object in order to allow the continuation to be resumed.
20
30This action displays three pages: the first renders a form, the second a link, and the third will show a message containing the string entered in the first page. 
31
32When running the example, you will notice that the continuations have the same URI path as the original action, just with a <code>continuation_id</code> query parameter added. This has the great benefit that trying to run a non-existing continuation (either because the link has been passed outside the originating session, or because the session has expired, or because the client does not support cookies) will actually result in the right page being invoked - it will simply result in the action to be started from the beginning. So in order to detect all these cases, it is sufficient to test for a <code>continuation_id</code> parameter at the beginning of the action:
33
34    function continuation_action() {
35        if (req.data.continuation_id) {
36            // Request has a continuation_id, but we landed at the
37            // beginning of the action. Either the session timed out,
38            // or the link comes from another session. Do what needs
39            // to be done.
40        }
41        // ...
42        Continuation.nextPage();
43        // From now on, req.data.continuation_id is expected to be set
44    }

Version 5 by hannes on 05. February 2008, 16:09

9Rhino continuations can be made While adding continuation and callback support to work quite easily in existing Helma 1.6releases has been a bit of a hack, using for example the callback feature from Gobi's Markup.js. Interestinglyrecent Helma snapshots have added features to make that easier, namely the req/res references work correctly out introduction of the box for resumed continuations, probably due to the way Rhino implements dynamic scopes (i*req.euri|https://dev. the per-thread scope is looked up at runtime anyway)helma.org/trac/helma/changeset/8774* and *req.actionProcessor|https://dev.helma.org/trac/helma/changeset/8775*.
11What needs more work is serialization support. Persistent HopObjects shouldn't be included in a serialized continuation, so we need The following framework makes use of these features to convert Nodes into NodeHandles allow storing suspended functions in the output stream, and convert back to Nodes in the input stream. The latter currently fails in user's session restore because it requires object and resuming them at a Transactor thread. For global references we need to make sure they're excluded from serialization. Helma 1.7 seems like a good timeframe to fix these issues.later time:
12
13<% this.attachments %>
14
15Here's an example action that makes use of this framework:
16
17  function test_continuation_action() {
18    res.write(<form method="post" action={ Continuation.nextUrl() }>
19                <input name="foo"/>
20                <input type="submit"/>
21              </form>);
22    Continuation.nextPage();
23    var foo = req.data.foo;
24    res.write('<a href="' + Continuation.nextUrl() + '">click here</a>');
25    Continuation.nextPage();
26    res.write("you said: " + foo);
27  }
28
29This action displays three pages: the first renders a form, the second a link, and the third will show a message containing the string entered in the first page.
30
31An area that still needs work is serialization support, as continuations currently will not work in conjunction with persistent sessions. Persistent HopObjects shouldn't be included in a serialized continuation, so we need to convert Nodes into NodeHandles in the output stream, and convert back to Nodes in the input stream. The latter currently fails in session restore because it requires a Transactor thread. For global references we need to make sure they're excluded from serialization. Helma 1.7 seems like a good timeframe to fix these issues.

Version 4 by hannes on 05. February 2008, 10:58

13Note: as of this writing, continuation support is broken in Rhino HEAD. The fix is quite trivial, see bug 403604. <https://bugzilla.mozilla.org/show_bug.cgi?id=403604>
14

Version 3 by hannes on 21. December 2007, 18:33

1Jetty === Rhino Continuations
2http://docs.codehaus.org/display/JETTY/Continuations
3This is not a "real" continuation as this isn't supported by Java. Instead, it relies on "that all actions taken by a filter or servlet before a call to suspend(long) are either idempotent (can be retried) or are made conditional on isPending() so they are not performed on retried requests".
4http://jetty.mortbay.com/apidocs/org/mortbay/util/ajax/Continuation.html
3Rhino Continuations (suspend continuations allow to capture the state of a complete running script state): to be resumed later on.
4
5Does not reflect current implementation, but this is the best I could find.
7Rhino and Jetty continuations can be used alone or only work in combination to create various interesting tricks:interpreter mode with the compiler disabled, i.e. with optlevel -1.
9* Send back a page and continue on Rhino continuations can be made to work quite easily in Helma 1.6, using for example the same spot callback feature from Gobi's Markup.js. Interestingly, the next time req/res references work correctly out of the client sends a requestbox for resumed continuations, probably due to the way Rhino implements dynamic scopes (i.e. the per-thread scope is looked up at runtime anyway).
10* Keep connection open and for use by other threads of control
11* Keep connection open for use by same thread of controlWhat needs more work is serialization support. Persistent HopObjects shouldn't be included in a serialized continuation, so we need to convert Nodes into NodeHandles in the output stream, and convert back to Nodes in the input stream. The latter currently fails in session restore because it requires a Transactor thread. For global references we need to make sure they're excluded from serialization. Helma 1.7 seems like a good timeframe to fix these issues.
12
13Note: as of this writing, continuation support is broken in Rhino HEAD. The fix is quite trivial, see bug 403604. <https://bugzilla.mozilla.org/show_bug.cgi?id=403604>
14
15=== Jetty Continuations
16
17Jetty continuations are a mechanism to keep HTTP connections pending without having a Java thread associated with the request.
18
19http://docs.codehaus.org/display/JETTY/Continuations
20
21This is not a "real" continuation as this isn't supported by Java. Instead, it relies on "that all actions taken by a filter or servlet before a call to suspend(long) are either idempotent (can be retried) or are made conditional on isPending() so they are not performed on retried requests".
22
23http://jetty.mortbay.com/apidocs/org/mortbay/util/ajax/Continuation.html
24
25Jetty continuations are a means to allow AJAX polling without a thread penalty.

Version 2 by hannes on 16. November 2006, 01:50

1Jetty Continuations (suspend HTTP connections): http://docs.codehaus.org/display/JETTY/Continuations
2http://docs.codehaus.org/display/JETTY/Continuations
8
9Rhino and Jetty continuations can be used alone or in combination to create various interesting tricks:
10
11* Send back a page and continue on the same spot the next time the client sends a request
12* Keep connection open and for use by other threads of control
13* Keep connection open for use by same thread of control

Version 1 by hannes on 16. November 2006, 01:44

1Jetty Continuations (suspend HTTP connections): http://docs.codehaus.org/display/JETTY/Continuations
2This is not a "real" continuation as this isn't supported by Java. Instead, it relies on "that all actions taken by a filter or servlet before a call to suspend(long) are either idempotent (can be retried) or are made conditional on isPending() so they are not performed on retried requests".
3http://jetty.mortbay.com/apidocs/org/mortbay/util/ajax/Continuation.html
3Rhino Continuations (suspend script state):
4http://wiki.apache.org/cocoon/RhinoWithContinuations
5Does not reflect current implementation, but this is the best I could find.