jaroslav@356: /** jaroslav@356: * Back 2 Browser Bytecode Translator jaroslav@356: * Copyright (C) 2012 Jaroslav Tulach jaroslav@356: * jaroslav@356: * This program is free software: you can redistribute it and/or modify jaroslav@356: * it under the terms of the GNU General Public License as published by jaroslav@356: * the Free Software Foundation, version 2 of the License. jaroslav@356: * jaroslav@356: * This program is distributed in the hope that it will be useful, jaroslav@356: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@356: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@356: * GNU General Public License for more details. jaroslav@356: * jaroslav@356: * You should have received a copy of the GNU General Public License jaroslav@356: * along with this program. Look for COPYING file in the top folder. jaroslav@356: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@356: */ jaroslav@356: package org.apidesign.bck2brwsr.vmtest; jaroslav@356: jaroslav@356: import org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher; jaroslav@356: jaroslav@356: /** jaroslav@356: * jaroslav@356: * @author Jaroslav Tulach jaroslav@356: */ jaroslav@356: final class Launcher { jaroslav@356: private final String sen; jaroslav@356: private Bck2BrwsrLauncher launcher; jaroslav@356: jaroslav@356: Launcher() { jaroslav@356: this(null); jaroslav@356: } jaroslav@356: Launcher(String sen) { jaroslav@356: this.sen = sen; jaroslav@356: } jaroslav@356: jaroslav@356: synchronized Bck2BrwsrLauncher clear() { jaroslav@356: Bck2BrwsrLauncher l = launcher; jaroslav@356: launcher = null; jaroslav@356: return l; jaroslav@356: } jaroslav@356: jaroslav@356: synchronized Bck2BrwsrLauncher.MethodInvocation addMethod(Class clazz, String name) { jaroslav@356: if (launcher == null) { jaroslav@356: launcher = new Bck2BrwsrLauncher(); jaroslav@368: launcher.setTimeout(180000); jaroslav@356: if (sen != null) { jaroslav@356: launcher.setScriptEngineName(sen); jaroslav@356: } jaroslav@356: } jaroslav@356: return launcher.addMethod(clazz, name); jaroslav@356: } jaroslav@356: jaroslav@356: void exec() throws Exception { jaroslav@356: Bck2BrwsrLauncher l = clear(); jaroslav@356: if (l != null) { jaroslav@356: l.execute(); jaroslav@356: } jaroslav@356: } jaroslav@356: jaroslav@356: }