reuseLogostLogotudLogorewerseLogo modelplexLogo
gearsBG
Reuseware Composition Framework
Components, Modules, Aspects or something new?
Introduce new Composition Techniques into your Language of Choice with Reuseware!

Aspect Weaving Example: Design Patterns as Aspects

This description uses the Ecore implementation of the Class Weaving composition system. The project (see link above) also contains the same example realised in UML and Java.

In this concrete example for the Aspect Weaving composition system the core is an Ecore model of a file system:

A core model
A core model

It consists of a central management class (FileSystem) and the classes FSFile and FSFolder, representing files and folders respectively. The model does not define how objects in the running system communicate. This 'communication aspect' is described in a separate model fragment.

An advice model
An advice model

Here we describe the communication in terms of the observer pattern. We have two classes defining the concepts of Observers and Subjects. It is defined in the composition system how classes are woven: If a class from an advice model should be woven into a class from a core model, it means that all references and operations have to be copied there. In addition, all reference pointing to other advice classes need to be redirected to the corresponding core classes.

To define a concrete composition, Reuseware's composition program editor can be used. We can for instance define two subject/observer relationships: one between FileSystem and File, one between FileSystem and Folder

The composition program
The composition program

The composed model looks as follows:

The composed model
The composed model

The communication aspect could now be easily exchanged. For instance, the example download contains a communication aspect modeled using the Mediator design pattern

The Observer aspect can be reused in different models or at different point cuts in a model. If the FileSystem core, for instance, also defines Views, the Observer aspect can also be used to describe communication between Files/Folders and Views.

Retrieved from "http://www.reuseware.org/index.php/Aspect_Weaving"

This page has been accessed 434 times. This page was last modified 08:59, 29 May 2009.