SPin is a prototype implementation of our Architecture Stratification concept. It is available as a plugin for the CASE-Tool Fujaba and can be installed from within Fujaba:
Fujaba supports Story Driven Modelling (SDM), which can be used for model transformation. SPin's Transformation Rules are defined using SDM diagrams. A few transformation rules are bundled with the SPin plugin, one of them is "Singleton":
The Fujaba project 'Singleton.fpr.gz' containing the rule can be found in the 'rules' directory (within 'Fujaba 4.3/plugins/spin'). Open it using 'Open Project' and open the apply SDM diagram found under 'Activity Diagrams' -> 'RRSingleton'.
The bundled rules have already been added to the transformation rule library. New or updated rules are automatically exported to this location, if the 'export rule(s)' context menu is used. The project also contains an example diagram where the transformation rule can be applied. Open 'Class diagrams' -> 'Example' from the left side browser.
SPin extends the built in UML metamodel of Fujaba with annotation elements, which are similar to UML collaborations. Here the class 'MySingletonClass' has been annotated with 'Singleton'. Additional annotation parameters can be specified using the Annotation Editor which can be openend from the context menu.
To execute the transformation, choose 'Refine annotation' from the annotation context menu. The resulting class diagram should look like this.
As can be seen, a private constructor and a 'get'-method has been added automatically in order to implement the singleton design pattern.