jaroslav@370: /** jaroslav@370: * Back 2 Browser Bytecode Translator jaroslav@370: * Copyright (C) 2012 Jaroslav Tulach jaroslav@370: * jaroslav@370: * This program is free software: you can redistribute it and/or modify jaroslav@370: * it under the terms of the GNU General Public License as published by jaroslav@370: * the Free Software Foundation, version 2 of the License. jaroslav@370: * jaroslav@370: * This program is distributed in the hope that it will be useful, jaroslav@370: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@370: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@370: * GNU General Public License for more details. jaroslav@370: * jaroslav@370: * You should have received a copy of the GNU General Public License jaroslav@370: * along with this program. Look for COPYING file in the top folder. jaroslav@370: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@370: */ jaroslav@370: package org.apidesign.bck2brwsr.launcher; jaroslav@370: jaroslav@371: import java.util.concurrent.CountDownLatch; jaroslav@371: import java.util.concurrent.TimeUnit; jaroslav@371: jaroslav@370: /** jaroslav@370: * jaroslav@370: * @author Jaroslav Tulach jaroslav@370: */ jaroslav@370: public final class MethodInvocation { jaroslav@371: final CountDownLatch wait = new CountDownLatch(1); jaroslav@370: final String className; jaroslav@370: final String methodName; jaroslav@371: private String result; jaroslav@371: private Exception exception; jaroslav@370: jaroslav@370: MethodInvocation(String className, String methodName) { jaroslav@370: this.className = className; jaroslav@370: this.methodName = methodName; jaroslav@370: } jaroslav@371: jaroslav@371: void await(long timeOut) throws InterruptedException { jaroslav@371: wait.await(timeOut, TimeUnit.MILLISECONDS); jaroslav@371: } jaroslav@371: jaroslav@371: void result(String r, Exception e) { jaroslav@371: this.result = r; jaroslav@371: this.exception = e; jaroslav@371: wait.countDown(); jaroslav@371: } jaroslav@370: jaroslav@370: @Override jaroslav@370: public String toString() { jaroslav@370: if (exception != null) { jaroslav@370: return exception.toString(); jaroslav@370: } jaroslav@370: return result; jaroslav@370: } jaroslav@370: jaroslav@370: }