aboutsummaryrefslogtreecommitdiffstats
path: root/netx/jogamp/plugin/jnlp/App3Launcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'netx/jogamp/plugin/jnlp/App3Launcher.java')
-rw-r--r--netx/jogamp/plugin/jnlp/App3Launcher.java94
1 files changed, 55 insertions, 39 deletions
diff --git a/netx/jogamp/plugin/jnlp/App3Launcher.java b/netx/jogamp/plugin/jnlp/App3Launcher.java
index 1d0b9c6..dc44499 100644
--- a/netx/jogamp/plugin/jnlp/App3Launcher.java
+++ b/netx/jogamp/plugin/jnlp/App3Launcher.java
@@ -30,9 +30,6 @@ import java.util.Map;
import jogamp.applet.App3Context;
import jogamp.plugin.jnlp.runtime.Applet3Instance;
-
-import com.jogamp.plugin.applet.Applet3;
-
import net.sourceforge.jnlp.AppletDesc;
import net.sourceforge.jnlp.ApplicationDesc;
import net.sourceforge.jnlp.JARDesc;
@@ -44,17 +41,19 @@ import net.sourceforge.jnlp.PluginBridge;
import net.sourceforge.jnlp.PropertyDesc;
import net.sourceforge.jnlp.ResourcesDesc;
import net.sourceforge.jnlp.StreamEater;
-import net.sourceforge.jnlp.util.JarFile;
import net.sourceforge.jnlp.cache.CacheUtil;
import net.sourceforge.jnlp.cache.UpdatePolicy;
import net.sourceforge.jnlp.runtime.ApplicationInstance;
-import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.runtime.JNLPClassLoader;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.services.InstanceExistsException;
import net.sourceforge.jnlp.services.ServiceUtil;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
+import net.sourceforge.jnlp.util.JarFile;
import net.sourceforge.jnlp.util.logging.OutputController;
+import com.jogamp.plugin.applet.Applet3;
+
/**
* Launches JNLPFiles either in the foreground or background.<p>
*
@@ -75,7 +74,7 @@ public class App3Launcher {
/*package*/static final ThreadGroup mainGroup = new ThreadGroup(R("LAllThreadGroup"));
public static ThreadGroup getMainGroup() { return mainGroup; }
-
+
/** the handler */
private LaunchHandler handler = null;
@@ -212,8 +211,6 @@ public class App3Launcher {
* @throws LaunchException if an error occurred while launching (also sent to handler)
*/
public ApplicationInstance launch(JNLPFile file) throws LaunchException {
- TgThread tg;
-
mergeExtraInformation(file, extra);
JNLPRuntime.markNetxRunning();
@@ -233,32 +230,51 @@ public class App3Launcher {
OutputController.getLogger().log(e);
}
}
-
+ // NOTE: TgThread usage is synchronized .. (no performance gain, on the contrary)
if (file instanceof PluginBridge) {
- tg = new TgThread(file, true);
- }
- else {
- tg = new TgThread(file);
- }
+ // NOTE: Skip TgThread, since same thread group
+ // We are also operating on a dedicated thread already!
+ // - Thread Applet3Panel.loaderThread in Applet3Panel.run() on Applet3Panel.handle
+ // - Applet3Panel.handle: Applet3Panel, NetxApplet3Panel: createAppletThread()
+ // FIXME: tg = new TgThread(file, true);
+ try {
+ // Do not create new AppContext if we're using NetX and icedteaplugin.
+ // The plugin needs an AppContext too, but it has to be created earlier.
+ JNLPRuntime.setDefaultDownloadIndicator(null);
+ return getApplet(file, ((PluginBridge)file).codeBaseLookup());
+ } catch (LaunchException ex) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
+ // Exit if we can't launch the application.
+ if (exitOnFailure) {
+ JNLPRuntime.exit(1);
+ }
+ throw ex;
+ } catch (Throwable ex) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex);
+ throw new RuntimeException(ex);
+ }
+ } else {
+ // NOTE: TgThread b/c of the thread group only ?
+ TgThread tg = new TgThread(file);
+ tg.start();
- tg.start();
+ try {
+ tg.join();
+ } catch (InterruptedException ex) {
+ //By default, null is thrown here, and the message dialog is shown.
+ throw launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCSystem"), R("LThreadInterrupted"), R("LThreadInterruptedInfo")));
+ }
- try {
- tg.join();
- } catch (InterruptedException ex) {
- //By default, null is thrown here, and the message dialog is shown.
- throw launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCSystem"), R("LThreadInterrupted"), R("LThreadInterruptedInfo")));
- }
+ if (tg.getException() != null) {
+ throw tg.getException();
+ } // passed to handler when first created
- if (tg.getException() != null) {
- throw tg.getException();
- } // passed to handler when first created
+ if (handler != null) {
+ // FIXME handler.launchCompleted(tg.getApplication());
+ }
- if (handler != null) {
- // FIXME handler.launchCompleted(tg.getApplication());
+ return tg.getApplication();
}
-
- return tg.getApplication();
}
@@ -361,7 +377,7 @@ public class App3Launcher {
}
}
-
+
/**
* Launches the JNLP file in a new JVM instance. The launched
* application's output is sent to the system out and it's
@@ -447,7 +463,7 @@ public class App3Launcher {
private JNLPFile fromUrl(URL location) throws LaunchException {
try {
JNLPFile file = new JNLPFile(location, parserSettings);
-
+
boolean isLocal = false;
boolean haveHref = false;
if ("file".equalsIgnoreCase(location.getProtocol()) && new File(location.getFile()).exists()) {
@@ -596,11 +612,11 @@ public class App3Launcher {
if (!file.isApplet()) {
throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplet"), R("LNotAppletInfo")));
}
-
+
if (handler != null) {
handler.launchInitialized(file);
}
-
+
Applet3Instance applet = null;
try {
ServiceUtil.checkExistingSingleInstance(file);
@@ -678,7 +694,7 @@ public class App3Launcher {
ThreadGroup group = Thread.currentThread().getThreadGroup();
- // appletInstance is needed by ServiceManager when looking up
+ // appletInstance is needed by ServiceManager when looking up
// services. This could potentially be done in applet constructor
// so initialize appletInstance before creating applet.
appletInstance = new Applet3Instance(file, group, loader, null);
@@ -693,7 +709,7 @@ public class App3Launcher {
// Finish setting up appletInstance.
appletInstance.setApplet(applet);
appletInstance.getAppletEnvironment().setApplet(applet);
-
+
setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), appletInstance.getClassLoader());
return appletInstance;
@@ -771,10 +787,10 @@ public class App3Launcher {
private LaunchException launchError(LaunchException ex) {
return launchError(ex, null);
}
-
+
private LaunchException launchError(LaunchException ex, Applet3Instance applet) {
if (applet != null) {
- SplashUtils.showErrorCaught(ex, applet);
+ SplashUtils.showErrorCaught(ex, applet);
}
if (handler != null) {
handler.launchError(ex);
@@ -805,7 +821,7 @@ public class App3Launcher {
* for the application, applet, or installer in its thread group.
*/
private class TgThread extends Thread { // ThreadGroupThread
- private JNLPFile file;
+ private final JNLPFile file;
private ApplicationInstance application;
private LaunchException exception;
private boolean isPlugin = false;
@@ -830,7 +846,7 @@ public class App3Launcher {
/** FIXME: Non plugin context
if (context && !isPlugin) {
SunToolkit.createNewAppContext();
- }
+ }
doPerApplicationAppContextHacks();
*/
@@ -877,6 +893,6 @@ public class App3Launcher {
};
-
+
}