Class to Service Transformation Using Multiple Rules
This transformation converts an abstract model in which UML classes represent
high level classes to a more specific UML model where each high level class
in the abstract model is transformed into an interface, an implementation
class and a factory class.
The transformation accepts a top level UML class as the source and generates the above three
classes by carrying out the following mappings:
-
The attributes of the source class map to getter and setter methods in the
interface and the implementation class.
-
The public operations of the source class map to operations in the
interface.
-
The private and public operations of the source class map to operations
in the implementation class.
-
The attributes of the source class map to attributes of the implementation
class.
-
The factory class provides a method that creates and returns an instance of
the implementation class.
A top level class is a class that is contained directly in a package or a model.
An inner class which is contained in another class is not a top level class.
If you choose a model or a package as the source, the transformation
generates output classes for each of the top level classes in the model or
the package.
This transformation uses a set of rules and several transforms to carry out
the above mappings.
Running the Transformation
To run the transformation:
- Start the run-time workbench.
-
In the run-time workbench, create an UML model containing a class with a
few attributes and operations. This is your source model.
- In the run-time workbench, create another UML model with a package in it.
This is your target model.
-
Right-click a class, a package, or the model in the source model;
then click Transform > Run Transformation > Class to Service Multiple Rules.
-
In the Run Transform window, on the Target page, select the package in the
target model or the target model itself.
- Click Run.
The transformation generates the interface, implementation and factory classes
and places them in the specified target package. If you choose the target model
on the Target page, the transformation places the generated classes in a package
named, ClassToServiceOutput, in the target model.
Transformation Details
Transformation Source
This transformation accepts a UML model or a package or a top level class as
the source. It will not accept an inner class as a valid source.
Transformation Target
This transformation accepts a model or a package as its target.