A module contains :
-
A JUnitModule class that will represent your module at runtime. This class is called the main class of the Module. By convention it is always suffixed Module.
-
A JUnitSession class and an association. This class is in charge of the implementation of the Module Session Services detailed below. The association is a simple delegate from the Module main class to this JUnitSession class.
The UML model detailed diagram for these classes is presented below.
Module and Session
The operations defined in JUnitSession are automatically called according to the stat Module runtime states and events.
We won’t dive into the gory details of these methods. We will see later (§7.7)that the start method will attach the module event listener to the Modelio event dispatch system. For more information on these methods.
The implementation of session services for our JUnit module is very simple.
package org.sample.junit.impl; import java.util.Map; import com.modeliosoft.modelio.javadesigner.annotations.objid; import org.modelio.api.model.IModelingSession; import org.modelio.api.modelio.Modelio; import org.modelio.api.module.DefaultModuleSession; import org.modelio.api.module.ModuleException; import org.modelio.vbasic.version.Version; public class JUnitSession extends DefaultModuleSession { private JUnitModelChangeHandler modelChangeHandler = null; public JUnitSession(JUnitModule module) { super(module); } @Override public boolean start() throws ModuleException { IModelingSession session = Modelio.getInstance().getModelingSession(); modelChangeHandler = new JUnitModelChangeHandler(); session.addModelHandler(modelChangeHandler); return super.start(); } @Override public void stop() throws ModuleException { IModelingSession session = Modelio.getInstance().getModelingSession(); session.removeModelHandler(modelChangeHandler); modelChangeHandler = null; super.stop(); } public static boolean install(String modelioPath, String mdaPath) throws ModuleException { return DefaultModuleSession.install(modelioPath, mdaPath); } @Override public boolean select() throws ModuleException { return super.select(); } @Override public void upgrade(Version oldVersion, Map<String, String> oldParameters) throws ModuleException { super.upgrade(oldVersion, oldParameters); } @Override public void unselect() throws ModuleException { super.unselect(); } JUnitModelChangeHandler getModelChangeHandler() { // Automatically generated method. Please delete this comment before entering specific code. return this.modelChangeHandler; } void setModelChangeHandler(JUnitModelChangeHandler value) { // Automatically generated method. Please delete this comment before entering specific code. this.modelChangeHandler = value; } }