Skip to content

JUnitSession_java_file

Antonin Abhervé edited this page Sep 3, 2020 · 1 revision
package org.modelio.JUnit.impl;


import java.util.Map;
import org.modelio.api.modelio.model.IModelingSession;
import org.modelio.api.module.context.IModuleContext;
import org.modelio.api.module.lifecycle.DefaultModuleLifeCycleHandler;
import org.modelio.api.module.lifecycle.ModuleException;
import org.modelio.vbasic.version.Version;

public class JUnitLifeCycleHandler extends DefaultModuleLifeCycleHandler {

    private JUnitModelChangeHandler modelChangeHandler = null;

        public JUnitLifeCycleHandler(final JUnitModule module) {
                super(module);
    }

    @Override
    public boolean start() throws ModuleException {
        IModuleContext context = this.module.getModuleContext();
        IModelingSession session = context.getModelingSession();
        modelChangeHandler = new JUnitModelChangeHandler();
        session.addModelHandler(modelChangeHandler);
        return super.start();
    }

    @Override
    public void stop() throws ModuleException {

        IModuleContext context = this.module.getModuleContext();
        IModelingSession session = context.getModelingSession();
        session.removeModelHandler(modelChangeHandler);
        modelChangeHandler = null;
         super.stop();
    }

    public static boolean install(String modelioPath, String mdaPath) throws ModuleException {
        return DefaultModuleLifeCycleHandler.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();
    }
}
Clone this wiki locally