Search in sources :

Example 1 with ScheduableTasksFilterFifo

use of abs.backend.java.scheduling.ScheduableTasksFilterFifo in project abstools by abstools.

the class Debugger method startABSRuntime.

/**
 * Used to start the ABS Runtime. If an earlier Runtime is present, it is shut down first.
 *
 * @param projectName
 * @param mainClassName
 * @param genPath
 * @param debuggerArgsSystemObserver
 * @param debuggerArgsTotalScheduler
 * @param debuggerIsInDebugMode
 * @param debuggerArgsRandomSeed
 * @param fliClassPath
 * @param outStream
 * @param ignoreMissingFLIClasses
 * @param useFifoSemantics
 * @throws InvalidRandomSeedException
 */
public static void startABSRuntime(final String projectName, final String mainClassName, final Path genPath, String debuggerArgsSystemObserver, String debuggerArgsTotalScheduler, boolean debuggerIsInDebugMode, String debuggerArgsRandomSeed, boolean terminateOnException, List<URL> fliClassPath, PrintStream outStream, PrintStream errStream, boolean ignoreMissingFLIClasses, boolean useFifoSemantics) throws InvalidRandomSeedException {
    if (DO_DEBUG)
        System.out.println("start internal debugger");
    final ABSRuntime r = new ABSRuntime();
    if (debuggerIsInDebugMode)
        r.enableDebugging(true);
    r.setOutStream(outStream);
    r.setErrStream(errStream);
    r.addFLIClassPath(fliClassPath);
    r.setIgnoreMissingFLIClasses(ignoreMissingFLIClasses);
    if (useFifoSemantics) {
        r.setScheduableTasksFilter(new ScheduableTasksFilterFifo());
    }
    r.terminateOnException(terminateOnException);
    boolean useOurScheduling = addSchedulingStrategy(debuggerArgsTotalScheduler, r);
    final boolean useOurSystemObserver = addSystemObservers(debuggerArgsSystemObserver, r);
    if (debuggerArgsRandomSeed != null && !debuggerArgsRandomSeed.isEmpty()) {
        String seedString = debuggerArgsRandomSeed.replace("-Dabs.randomseed=", "");
        Long seedNumber = getSeed(seedString);
        r.setRandomSeed(seedNumber);
    }
    final ThreadGroup tg = new ThreadGroup("ABS " + mainClassName);
    tg.setDaemon(true);
    final Thread debuggerRunner = new Thread(tg, new Runnable() {

        @Override
        public void run() {
            try {
                if (DO_DEBUG) {
                    System.out.println("Start ABSRuntime .. ");
                    System.out.println("path: " + genPath.toString());
                    System.out.println("name:" + mainClassName);
                }
                r.start(genPath.toFile(), mainClassName);
            } catch (ClassNotFoundException e) {
                exceptionHandling(e);
            } catch (InstantiationException e) {
                exceptionHandling(e);
            } catch (IllegalAccessException e) {
                exceptionHandling(e);
            }
        }

        private void exceptionHandling(final Exception e) {
            standardExceptionHandling(e);
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    showErrorMessage("Not able to start ABSRuntime.\n" + e.getMessage());
                }
            });
        }
    });
    if (useOurScheduling) {
        enableHightlighting();
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                try {
                    PlatformUI.getWorkbench().showPerspective(ABSDEBUGPERSPECTIVE_ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
                    getDebugger().initDebugger(projectName, r, debuggerRunner, useOurSystemObserver);
                    if (DebugUtils.getRunAutomatically()) {
                        DebugUtils.getSchedulerRef().resumeAutomaticScheduling();
                    }
                } catch (WorkbenchException e) {
                    standardExceptionHandling(e);
                    showErrorMessage("Could not open ABS debug perspective");
                }
            }
        });
    } else {
        debuggerRunner.start();
    }
}
Also used : ScheduableTasksFilterFifo(abs.backend.java.scheduling.ScheduableTasksFilterFifo) WorkbenchException(org.eclipse.ui.WorkbenchException) WorkbenchException(org.eclipse.ui.WorkbenchException) ABSException(abs.backend.java.lib.runtime.ABSException) ABSRuntime(abs.backend.java.lib.runtime.ABSRuntime)

Aggregations

ABSException (abs.backend.java.lib.runtime.ABSException)1 ABSRuntime (abs.backend.java.lib.runtime.ABSRuntime)1 ScheduableTasksFilterFifo (abs.backend.java.scheduling.ScheduableTasksFilterFifo)1 WorkbenchException (org.eclipse.ui.WorkbenchException)1