Stateful aspects observe and react to program execution traces. A stateful aspect is defined through a pattern and an advice. A pattern specifies the program execution trace that must be matched, and an advice is the piece of code that is executed when the pattern is matched. The pattern of a stateful aspect can match multiple times in the same program execution trace, and therefore, the advice may be executed simultaneously (see Figure 1). Stateful aspect languages have numerous applications in domains like error detection, security, and modular definition of crosscutting concerns.
Several stateful aspect languages have been proposed (eg. Tracematches, Halo, Alpha, etc), specifically tailored to address a particular domain. Each one uses its own pattern language to define the join point trace pattern that should be matched by an aspect. In addition, every stateful aspect language has its semantics to define how the patterns are matched. However, most of pattern languages in these aspect languages are expressively limited, and their patterns are not first-class values, meaning that properties like the reuse, composition, and dynamic creations are not available. In addition, semantics of most these stateful aspect languages is fixed and common for all their aspects. This motivates the need of a stateful aspect language with an expressive pattern language and customizable stateful aspect semantics (see Figure 2). Concretely, we propose a model of a stateful aspect language (named ESA) that allows developers to:
- use a Turing complete language to define join point trace patterns. In addition, patterns are first-class values, bringing the benefits of the reuse, composition, and creation at runtime. In this paper, we use first-class functions to describe our pattern language, but other first-class abstractions might be used as well (eg. objects).
- customize the matching and advising semantics of every stateful aspect. In order to achieve this goal, we use open implementation guidelines.
We provide a concrete and practical implementation of ESA for JavaScript (see Try it on-line, Examples, and tetris pages). This implementation, named ESA-JS, currently supports Firefox, Safari, Opera, and Google Chrome without the need of an extension. We have applied this implementation in various scenarios like Modular and Flexible Causality Control on the Web (see the WeCa page). Apart form ESA-JS, we also provide ESA-AS3, an (incipient) implementation for ActionScript.
Some Questions
- Do you want to try ESA-JS now? Please, go to the try it on-line page.
- Do you need examples? You can find several running examples in this Web site: toy Web applications on the examples page, predefined examples on the try it on-line page, and the extension of the tetris game.
- Do you want to learn more? You can read our publications.
- Do you have any question? Please, do not hesitate to ask in our mailing list or just contact us (Paul, Éric, and Hiroaki).
- Do you want to use and test ESA-JS? Download it from here.
- What are WeCa and Matcher Cells? WeCa is a library that uses ESA-JS to control causality issues on the Web, and Matcher Cells is the algorithm used by ESA to match traces.
Credits
ESA is designed and implemented at the Pleiad and Pragmatic laboratories by Paul Leger & Hiroaki Fukuda, mainly under the supervision of Éric Tanter.