Prevalent Continuations

by Ken MacLeod

Control Flow is free!

After some late night hacking sessions, I've been able to rip Cocoon's Control Flow component free of Cocoon. I removed all dependencies on Cocoon and Avalon and pared my standalone version of Control Flow down to only 14 classes and a couple of JavaScript functions.

Below is the simple JavaScript code that I'm using to test Control Flow. This code will eventually run on the server side and will send a web page to the user when it needs input. The forwardAndWait() method puts the name of the page or Struts forward into a 'tray' object and suspends execution. Eventually, it will suspend execution of the script, call a JSP page or a Struts forward, and wait for the response to go out and the request to come back in.

function test(tray) 
{
   log.info("I called my script!");
   forwardAndWait(tray, "page1.html");
    
   log.info("I'm back in the script");
   forwardAndWait(tray, "page2.html");

   log.info("all done!");
}

Below is the code I'm using to run and test this script. Step #1 sets up the 'tray' that I use to get the forward name and continuation id out of the JavaScript world. I introduced the tray concept, and I don't really like it but I'm not sure how else to get the values I need out of JavaScript. Step #2 and #4 are the interesting bits. Step #2 calls the JavaScript method, which executes and then suspends the script execution inside the 1st JavaScript forwardAndWait() call. Step #4 resumes execution of the script using the continuation id found in the tray.

JavaScriptInterpreter interp = new JavaScriptInterpreter();      
interp.initialize();     
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\src\\flow\\system.js");
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\tests\\flow\\test.js");
      
Scriptable s = interp.enterContext();
      
// 1. setup tray param to hold forward
List params = new LinkedList();
List tray = new LinkedList();
params.add(new Argument("tray", tray));

// 2. call function
interp.callFunction("test", params);
     
// 3. funcion suspended, now tray should contain forward name
assertTrue(((String)tray.get(0)).equals("page1.html"));
// and the continuation id
String kontid = (String)tray.get(1);
      
// 4. resume exection of script using that contination id
interp.handleContinuation(kontid, new LinkedList());
      
// 5. function suspeded again, now tray should contain second forward name
assertTrue(((String)tray.get(0)).equals("page2.html"));
      
// 6. resume function, so it may complete execution
kontid = (String)tray.get(1);
interp.handleContinuation(kontid, new LinkedList());
      
interp.exitContext(s);

And below is the debug output from running the test code above.

JS-INFO: I called my script!
JS-DEBUG: WK: Just Created New Continuation 4d281a763e7c1b3f5a7b4e244b2e224729112160
JS-INFO: I'm back in the script
JS-DEBUG: WK: Just Created New Continuation 877d715e813c5a7c4e7f1a56612826332f528167
JS-INFO: all done!

Next, I'll try to implement the same NumberGuess example from the Control Flow tutorial, but with no Cocoon - only JSP and Servlets.

TriJUG tonight: David Geary talks JSF.

Poised to become the preeminent--not to mention standard--Java Web application framework, JavaServer Faces is the next big thing for server-side Java. Come find out what all the fuss is about in this cutting-edge session given by a member of the JSF Expert Group. Learn what JSF has to offer, how it compares to Struts, and how you can start using it today.
For more info and directions: TriJUG JSF Talk Announcement

Struts Flow

I'm having too much fun hacking apart Cocoon's uber cool Control Flow component to even think about blogging right now. I want to experiment with Control Flow in a simple Struts-based app, but at this point I'm still trying to get my standalone verson of Control Flow working in a simple unit test. If and when I come up for air, I promise a full report.


RSS Quiz


Thou shalt separate business logic from display.

Terence Parr, Enforcing Model-View Separation in Template Engines (PDF): Without exception, programmers espouse separation of logic and display as an ideal principle. In, practice, however, programmers and engine producers are loath to enforce separation, fearing loss of power resulting in a crucial page that they cannot generate while satisfying the principle.
Excellent paper, found via Bill de hOra - a good read for any web developer.

1st Struts-Faces nightly

found via Andrew Kuzmin's weblog

Roller 0.9.8.2 out shortly.

Since the Roller 0.9.8.1 release, I have made a number of fixes in the stable ROLLER_098_BRANCH to support JRoller including: additional database indexes for performance, referential integrity fixes, and RSS encoding fixes. Rick Ross will be happy to hear that, with the latest round of fixes, I have finally killed the dayhits rollover bug. I have deployed Roller 0.9.8.2 to JRoller and if all goes well over the next 24 hours, I'll release it on SourceForge.

In other news: Roller 0.9.9 is progressing nicely and is probably less than a month off. See also: Roller's JIRA roadmap.

Thanks Jaap!

Shortly after I internationalized the Roller JSP pages, Jaap van der Molen sent me a complete Dutch translation and an offer to update it as needed. Thanks Jaap!


Hard to imagine a worse model for UI development than HTTP.

Abstract: Using Smalltalk to Redefine Web Development It would be hard to imagine a worse model for user interface development than HTTP. Would you use a GUI framework where every event from every widget in your application was handed to you at once, periodically, as a large hashtable full of strings? Where every time a single piece of data changed you had to regenerate a textual description of the entire interface? Where the event-based architecture was so strict that you couldn't ever, under any circumstances, open a modal dialog box and wait for it to return an answer?
[...]
For all its limitations, the web is fast becoming the most important deployment platform for many classes of application. The Java, Perl, PHP, and .NET worlds, to name a few, are pursuing it agressively. Many of us are going to have to play their game -- but we don't have to play by their rules.
That's part of the abstract for a talk on Seaside, a Smalltalk and continuation based web application development framework (via James Robertson's blog). Seaside is one of many continuation based frameworks. The more I read about these frameworks the more I become convinced that the holy grail of web development lies in the castle of continuations. I've previously mentioned the two Java entries in the quest for the grail: RIFE and Cocoon ControlFlow. I need to find some time to investigate these frameworks and figure out how they relate, if at all, to JSP and JSF.

Deadlines suck.

That's all.


7% of adults blogging?

Pew Internet Project Report

Another prediction.

I'm going to go out on a limb and make another prediction: Roller 0.9.9 will ship with a kick-ass (forgive me, I'm from North Carolina) Atom implementation that is not named after a washed-up SNL cast-off. Zing!

Clements thinks we are serious.

Clemens thinks we are all serious about this open source software thing. Ssssh! Don't tell him we are just doing it to cut off Microsoft's air supply. Oh, and by the way, as soon as Microsoft is out of business, one Roller license will cost you about $10,000/server.

Today we learn

- I'm guessing - about Mark's new job - a closely guarded secret as Mark put it on IRC. My prediction is that Mark will be working for OSAF on Chandler. Update: I was totally wrong. Congratulations to Mark on his new job at IBM.


Daddy, can I have a weblog?

Last weekend, my 7 year old son Alex, without any prompting from me - I swear, asked for his own weblog. Just about every day since, he has taken a little time after finishing his homework to do some blogging. He is not able to type very quickly, but he hunts down the keys he needs and gives each a solid tap. He can't spell all that well, but he is not afraid to spell things out phonetically. Luckily for him, his entries are so short that there is no need for formatting, but soon I imagine I'll have to set up a WYSIWYG editor for him or teach him some rudimentary HTML.

Andi and I have decided not to edit Alex's posts or correct his spelling and grammar errors. We want to be able to look back on his progress as a writer. We do sometimes add some notes in parentheses when his spelling is too hard to read. If you have read this far without hitting the back-button, then perhaps you are wondering just where Alex's weblog is. I keep it on a somewhat obscure server and to keep that server obscure, I'm not going to give you a link. Instead, I'm going to publish Alex's historic first week of weblog posts right here on my weblog. Enjoy!

Sunday - Locker dockers. Today I and my famliy went to mil brook hiy school. when we got home daddy lock us outside. flinliy we got in our home.I will see you soon today.

Saturday - duster busters. Today I got dust in my eyes in a tree. We watch a move (movie) of scooey-doo (scooby-doo). It is a good move.

Friday - too snowy. Today it is snowing 3 inchis high! We had a snowball fight. We made a fort. today linus has a weblog. Cats have a talie. Cats are diffrent colors. Luna is black and white. Cats have reytrackl clas (retractable claws).

Thursday - snowing. It is snowing outside! linus lovs the snow. I do too. How bowt you. Daddy said tomrrow we will have a snowball fight.

Tuesday - school. At school I had an ansebly (assemby) Linus got a reading t-shrit. Tonight Linus went to school to sing songs to their parints. I did not go.

Monday - school. Today I went to school. I made a clock that was coloerfull. It is filled up. I can not put one more coloer in it. then I got home. I cilmed a tree and made a amrgsc esit (emergency exit) if eneything hopons. last I did my homework. My homework for today was pick a book you have read. Then make a parugraph. I pick a book you have read. then make a pargragh. I picked the seakrits of droon (Secrets of Droon). Eric looks like harry potter in the move. My dad leat us see some of it. He is reading it too.

Sunday - My first weblog post. Today is my first day writing on a weblog. Today I went to my grandmother and grandpa's house. I got ice cream in the country. On the way home we played racer. How we play is if we pass cars we get points. Today we got 50 points.

I love it, but first, let me say that 1) I only locked Alex and Linus outside for a very short time and 2) the fact that we scored 50 points playing "racer" on the drive home from the country does not mean that I exceeded the speed limit at anytime. As you can probably tell, I'm a proud Daddy - a proud Daddy who will be reading his son's weblog very carefully.


Matt's Roller 0.9.9-dev demo server

Matt has set up a Roller demo server so that you can experiment with and comment on a recent build of Roller 0.9.9-dev. Thanks Matt. Most of the changes for Roller 0.9.9-dev are complete and now we are focusing on fixing bugs and cleaning up the UI.

Where is my Atom RSS feed?

Bruce Williams Has 'RSS' really become so common that it no longer refers to a particular technical specification, but instead refers to blog syndication generally? Has it really joined the ranks of Kleenex and Xerox?
Yep, that is correct. RSS has now joined the ranks of Kleenex, Xerox, and, I will add, Google. The original definition of RSS has now been overruled by common usage. RSS now means any sort of website or weblog syndication and in this new Atomic age, you'll find more and more people talking about their Atom RSS feeds.

« Previous page | Main | Next page »