7. Prototype Implementation
7.1.1. FESAS Development Tool
The FESAS Development Tool supports developing the functional logics of MAPE components in Java. Developers can use an existing Eclipse installation and solely have to add the FESAS Development Tool plug-in. The process for using the FESAS Development Tool is divided into five steps: (i) creating a FESAS project, (ii) initializing a logic element and its metadata file, (iii) writ- ing source code and testing the functionality, (iv) preparing the elements for the repository, and (v) committing the prepared elements to the FESAS Repository. Figure 7.3 shows the different steps and the corresponding dialogs in Eclipse. Next, this section provides general implementation details for the FESAS Devel- opment Tool. Afterwards, it illustrates the implementation of the five steps for development.
As the plug-in is integrated as menu bar into the Eclipse IDE, developers can use all known features, such as syntax highlighting, on-the-fly compilation, and simplified integration of libraries. All functionality of the plug-in is controlled via the menu bar or context menus. Therefore, extension points are specified for each entry of the FESAS Development Tool menu group. Each of these extension points is linked to a class that extends the org.eclipse.jface.dialogs.Dialog class for building a dialog in Eclipse. For implementation of a dialog, the method createDialogArea(..) is overwritten for specifying the look-a-like of the dialog.
7.1. Implementation of the FESAS IDE Java RMI connection Transfer logic package Repository stores logic Start the main
method Dialog: Select functional logics Dialog: Define test parameters Create test environment Dialog: Define project data Setup project using wizard
Add pom and properties Calculate dependencies Pack classes and metadata Pack classes
and pom.xml Mavenvariant Dialog: Define metadata Setup class Setup metadata json Setup Maven modules Setup metadata json Original version Original version Maven variant
Figure 7.3.: Different steps of the workflow with the FESAS Development Tool mapped to the menu entries. The first step for configuration of the tool is omitted.
Additionally, at least the method okPressed() is implemented to handle the ac- tion when the developer clicked the dialog’s OK button. These handlers might rely on additional functionality, e.g., to set up a functional logic or the test environ- ment. Additional handlers are implemented for updating of the dialog triggered by user input or handling an abortion. The plug-in relies on Eclipse functionality and uses the GUI, the project wizard as well as the Java developer tools. Fur- ther, it extends the Java perspective with a view for the metadata of functional logics and integrates custom elements. In the following, this section describes the different activities of using the plug-in as well as their implementation.
As prerequisite, a developer has to create a FESAS project, which is a cus- tomized Maven project. The plug-in configures this project, i.e., it defines the dependencies to the FESAS Middleware Maven library in the Maven pom.xml of the project, sets the properties, and creates all relevant folders as well as the
7.1. Implementation of the FESAS IDE
package structure. The process is integrated into the Eclipse Project Wizard for creating a new project, i.e., it is identical to the creation of any other project in Eclipse, however, it is triggered by the menu bar of the plug-in. Next, the developer has to generate a logic element, e.g., for the SmartHighway system, this could be a planning logic that calculates a speed limit depending on the current traffic situation. The developer specifies the metadata of the functional logic which is used by the repository to identify the purpose of the functional logic.
1 public class CLASSNAME extends AbstractLogic implements LOGIC_INTERFACE { 2 3 public CLASSNAME() { 4 super(); 5 SUPPORTED_INFORMATION_TYPES 6 this.informationType = OWN_INFORMATION_TYPE; 7 type = LogicType.LOGIC_TYPE; 8 shortName = "CLASSNAME"; 9 } 10
11 public void initializeLogic(HashMap<String, String> properties)
12 { [...] // code removed } 13
14 public String callLogic(IKnowledgeRecord data) { 15 if (data instanceof KnowledgeRecord) {
16 if (data.getData() instanceof OBJECT) { [...] // code removed } 17 return "Not the expected data type! It is: " + data.getData().
getClass().getSimpleName();
18 }
19 return "Not a KnowledgeRecord! It is: " + data.getClass().
getSimpleName();
20 }
21 [...] // code removed
22 }
Listing 7.1: Template for a functional logic (omitting comments with instruction for developers). All terms in capital letters (except of OBJECT) are wildcards, which are substituted with the
information captured in the creation dialog. The method
7.1. Implementation of the FESAS IDE
The tool initializes a Java source code file as well as a JSON file that contains the metadata. For both files, templates exist. These templates contain wildcards for the information captured by the plug-in through a dialog. Listing 7.1 shows such a template for the functional logic. The template is a Java class that contains different wildcards written in capital letters. These wildcards are substituted by the metadata, e.g., the wildcard CLASSNAME is substituted by the name of the functional logic, the wildcard SUPPORTED_INFORMATION_TYPES by an array with all supported information types as specified in the creation dialog. The FESAS View extends the Eclipse GUI and offers an overview on the metadata of a selected functional logic source code file.
Further, developers can start a system for testing. Using dialogs in Eclipse, the developer configures the relevant subset of MAPE components as well as defines sample data for simulating input of managed resources. Therefore, developers have to specify the components they would like to test and add the input data. As an example for the SmartHighway system, the analyzer and planner can be spec- ified as functional logics that should be tested and the output of the monitor in form of traffic flows can be coded as sample data. The FESAS Development Tool uses pre-defined Java classes as templates and generates the test environment. The test system provides the debugging support known from Eclipse as it can be executed as Java program. This allows detecting errors early in the development process without the need to set up the full SAS.
After finishing the implementation and testing phase, the FESAS Develop- ment Tool packs the code into archive files. We implemented two different proto- types which can be used depending on the type of FESAS Repository implemen- tation. For the first prototype, the archive file contains the metadata as JSON file and the functional logic as well as files containing referenced code, so called dependencies, as Java byte code. The plug-in calculates the dependencies using
the ASM ClassReader library5. Therefore, the class file of the functional logic
is loaded and the plug-in searches recursively in the byte code for any related classes that are not part of the Java library or FESAS libraries through analyz- ing the imports, related classes, as well as referenced libraries. The plug-in adds all identified dependencies to the archive file.
5ASM ClassReader website: http://asm.ow2.org/asm33/javadoc/user/org/objectweb
/asm/ClassReader.html
7.1. Implementation of the FESAS IDE
So far, this section has described the prototype presented in [225]. We built a second prototype which relies on the Maven structure for analyzing the depen- dencies of a functional logic. First, this prototype builds one Maven module for the functional logic, one for dependencies classes that is used for all functional logics, and one parent module that combines a functional logic module with its dependencies. Second, this prototype reads the pom files from the parent devel- opment project and, through that, from the functional logic and related projects with dependencies. Third, it generates an aggregated pom file that integrates all dependencies specified in Maven. This enables the repository of the FESAS Mid- dleware at deployment to load all Maven dependencies directly from a Maven repository, hence, the resulting archive file is smaller. User-defined classes are in- tegrated into the archive file similar to the former described version of the plug-in, however, they have to be specified in the project of the functional logic or the dedicated dependency project (which is set up by the FESAS Development Tool). Using the plug-in, a developer sends the functional logics to the FESAS Repos- itory using a connection via Java RMI. Developers can specify the connection to the FESAS Repository in a configuration file. A SAS that runs the FESAS Mid- dleware loads the code from the repository as described in Section 7.3.1. With the help of the FESAS Design Tool, which is described in the next section, the system designer writes the configuration files that specify which logic should be loaded at system deployment.