![]() ![]() |
||||
|
||||
This
section describes how to create a simple plug-in for OSATE that counts the number of
components in an AADL model. Creating a plug-in requires knowledge about Eclipse, the
AADL meta model, and the OSATE APIs. Here we close the section with a brief summary of
the major topics. |
||||
An
OSATE plug-in is written as an Eclipse plug-in project. Plug-in projects have a
plugin.xml file that describes the appearance and structure of the plug-in. We use
it to
declare our plug-ins dependencies on other plug-ins, to declare an Eclipse action, and to
declare and Eclipse action set to contain our action in the eclipse user interface.
By
default, a plug-in depends on the plug-ins org.eclipse.ui and org.eclipse.core.runtime.
An OSATE plug-in should also declare that it depends on edu.cmu.sei.aadl.model and
org.eclipse.emf.ecore so that it can use the AADL meta model, and edu.cmu.sei.osate.ui
so that it can access the abstract action implementations..
Our
plug-in uses Eclipses SWT framework to open a simple dialog box to display results. The
static method MessageDialog.openInformation() display a simple dialog box displaying
information results. Class MessageDialog also has the methods openError and
openWarning, among others, that are useful for interacting with users of a plug-in. |
||||
The
AADL meta model is modeled using the Eclipse Modeling Framework (EMF). The
model is split across seven EMF Ecore packages: core, component, connection, feature, flow,
instance, and property. These package correspond to a suite of Java packages
edu.cmu.sei.aadl.model.core, edu.cmu.sei.aadl.model.core.impl,
edu.cmu.sei.aadl.model.core.util, edu.cmu.sei.aadl.model.component,
edu.cmu.sei.aadl.model.component.impl, edu.cmu.sei.aadl.model.component.util,
edu.cmu.sei.aadl.model.connection, edu.cmu.sei.aadl.model.connection.impl,
edu.cmu.sei.aadl.model.connection.util, etc. that are in the Eclipse plug-in
edu.cmu.sei.aadl.model.
EMF
generates a switch class for each Ecore package. This class is in the corresponding
Java util package, and contains a case method for each class declared in the package.
The
case methods understand the class hierarchy, and fall through to super classes if the case
method returns null. OSATE provides a compound switch class
edu.cmu.sei.aadl.model.util.AadlProcessingSwitch that coordinates the use of switches
across all the Ecore packages as well as including model traversal functionality (see below).
This
section does not cover the meta model in any depth, but the model statistics plug-in tests
against the ComponentType and ComponentImpl classes, which are the super types of the
more specific component type and component implementation classes, respectively. The
model statistics plug-in counts the different categories of instantiated components in the instance
model. Unlike the declarative model, which has a different class for each component category,
the instance model has only one class for representing an instantiated component:
ComponentInstance. To determine the category of the component, the category
attribute
must be consulted using ComponentInstance.getCategory(). This method returns an
instance of ComponentyCategory, a class that implements the EMF enumeration pattern. In
actuality, we test against the integer values of the enumeration elements using a normal Java
switch statement:
switch (obj.getCategery().getValue()
{
case ComponentCategory.THREAD:
break;
case ComponentCategory.PROCESS:
break;
// etc.
} |
||||
The
OSATE API provides many classes that customize the functionality of Eclipse and EMF
APIs to better support AADL models. The class
edu.cmu.sei.aadl.model.util.ForAllAObject encapsulates model traversal functionality. The
model statistics plug-in uses the traversal method processPreOrderAll to perform pre-order
traversals starting at a specific root object and the traversal method
processPreOrderAllDeclarativeModels to perform a pre-order traversal of all the
declarative model structures in the Eclipse workspace. This class is described in more detail
in
Section 4.3 AADL Model Traversal Support. The model statistics analysis is implemented
as an extension of the class AadlProcessingSupport, a subclass of ForAllAObject, that
delegates to EMF switch classes as the models are traversed. The method initSwitches is
overridden to create to appropriate switch class implementations for the analysis.
OSATE
provides implementations of IWorkbenchWindowActionDelegate that make it
easier to create an OSATE-specific action. The class
edu.cmu.sei.aadl.model.pluginsupport.AaxlReadOnlyAction may be extended to define
an action that does not persist any changes made to models as a side-effect of the action. The
class AaxlModifyAction, a subclass of AaxlReadOnlyAction, does persist any changes
made as a side-effect. The body of the action is defined by implementing the method
doAaxlAction(AObject o) which is passed the currently selected model object.
AaxlReadOnlyAction also defines methods that make it simple to deposit markers on model
objects for result reporting: reportInfo, reportWarning, and reportError.
These methods
take as parameters the model object on which to place the marker and the string message to
associate with the marker. |
||||