Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Back 2 Browser Bytecode Translator
* Copyright (C) 2012-2018 Jaroslav Tulach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. Look for COPYING file in the top folder.
* If not, see http://opensource.org/licenses/GPL-2.0.
*/
package org.apidesign.bck2brwsr.launcher.fximpl;
import java.io.BufferedReader;
import java.io.Reader;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TooManyListenersException;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
import org.netbeans.html.boot.impl.FindResources;
import org.netbeans.html.boot.impl.FnUtils;
import org.netbeans.html.boot.spi.Fn;
/**
*
* @author Jaroslav Tulach
*/
public final class JVMBridge {
static final Logger LOG = Logger.getLogger(JVMBridge.class.getName());
private final WebEngine engine;
private final ClassLoader cl;
private final WebPresenter presenter;
private static ClassLoader[] ldrs;
private static ChangeListener onBck2BrwsrLoad;
JVMBridge(WebEngine eng) {
this.engine = eng;
final ClassLoader p = JVMBridge.class.getClassLoader().getParent();
this.presenter = new WebPresenter();
this.cl = FnUtils.newLoader(presenter, presenter, p);
}
public static void registerClassLoaders(ClassLoader[] loaders) {
ldrs = loaders.clone();
}
public static void addBck2BrwsrLoad(ChangeListener l) throws TooManyListenersException {
if (onBck2BrwsrLoad != null) {
throw new TooManyListenersException();
}
onBck2BrwsrLoad = l;
}
public static void onBck2BrwsrLoad() {
ChangeListener l = onBck2BrwsrLoad;
if (l != null) {
l.changed(null, null, null);
}
}
public final static class NewInstance {
private final Class> clazz;
NewInstance(Class> clazz) {
this.clazz = clazz;
}
public String getName() {
return this.clazz.getName();
}
public Object newInstance() throws ReflectiveOperationException {
return this.clazz.newInstance();
}
}
public Object loadClass(String name) throws ClassNotFoundException {
Fn.activate(presenter);
Class> clazz = Class.forName(name, true, cl);
return new NewInstance(clazz);
}
private final class WebPresenter implements Fn.Presenter,
FindResources, Fn.ToJavaScript, Fn.FromJavaScript, Executor, Fn.KeepAlive {
private final Set