(this document is adapted from the message posted by stefanomazzocchi on the cocoon development mailing list)

While writing flowscripts, you realize how many things can be applied to many of the various flowscript functions that are called by the sitemap. In Linotype, I ended up using the ability that javascript gives you of using functions as native objects and then invoquing them by passing a modified argument vector.

It came to me that what I did with linotype was a really-poor-man interception mechanism. Interception is the ability to "intercept" a method call and execute some code before or after the execution of the intercepted method.

Interception is the simplest form of the aspect orientation.

Adding interception mechanism to the flowscript requires three changes, two in the FOM, one (more important!) in the javascript syntax:

  cocoon.apply("blah.js");

where "blah.js" contains the intercepting functions.

{{{ ...

{{{ function get*() {

}}}

the above seems rather accademic, so allow me to write an example where the use of aspect-oriented flowscript would shine.

Something that can be modelled very well as an aspect is authentication/authorization (aka login) because it's not something that is part of the webapp (at least, it shouldn't be!) but it's something that is "wrapped" around it to allow people to access it without the proper authorization.

With interception, it can be implemented as such

{{{ login.js

}}}

then, in your flowscript, you simply have to call the "apply" function to apply the aspects to your flowscript

{{{ yourstuff.js

}}}

InterceptedFlowscript (last edited 2009-09-20 23:41:06 by localhost)