diff options
Diffstat (limited to 'netx/net')
7 files changed, 125 insertions, 53 deletions
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java index 6e07b22..6076267 100644 --- a/netx/net/sourceforge/jnlp/Launcher.java +++ b/netx/net/sourceforge/jnlp/Launcher.java @@ -31,8 +31,8 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; -import net.sourceforge.jnlp.util.JarFile; +import net.sourceforge.jnlp.util.JarFile; import net.sourceforge.jnlp.cache.CacheUtil; import net.sourceforge.jnlp.cache.UpdatePolicy; import net.sourceforge.jnlp.runtime.AppletInstance; @@ -44,9 +44,10 @@ import net.sourceforge.jnlp.services.ServiceUtil; import javax.swing.SwingUtilities; import javax.swing.text.html.parser.ParserDelegator; + import net.sourceforge.jnlp.splashscreen.SplashUtils; import net.sourceforge.jnlp.util.logging.OutputController; - +import sun.awt.AppContext; import sun.awt.SunToolkit; /** @@ -67,6 +68,8 @@ public class Launcher { /** shared thread group */ /*package*/static final ThreadGroup mainGroup = new ThreadGroup(R("LAllThreadGroup")); + + public static ThreadGroup getMainGroup() { return mainGroup; } /** the handler */ private LaunchHandler handler = null; @@ -521,12 +524,16 @@ public class Launcher { // When the application-desc field is empty, we should take a // look at the main jar for the main class. if (mainName == null) { - JARDesc mainJarDesc = file.getResources().getMainJAR(); - File f = CacheUtil.getCacheFile(mainJarDesc.getLocation(), null); + final JARDesc mainJarDesc = file.getResources().getMainJAR(); + final File f = CacheUtil.getCacheFile(mainJarDesc.getLocation(), null); if (f != null) { - JarFile mainJar = new JarFile(f); - mainName = mainJar.getManifest(). - getMainAttributes().getValue("Main-Class"); + final JarFile mainJar = new JarFile(f); + try { + mainName = mainJar.getManifest(). + getMainAttributes().getValue("Main-Class"); + } finally { + mainJar.close(); + } } } @@ -767,7 +774,7 @@ public class Launcher { JNLPClassLoader loader = JNLPClassLoader.getInstance(file, updatePolicy); ThreadGroup group = Thread.currentThread().getThreadGroup(); - ApplicationInstance app = new ApplicationInstance(file, group, loader); + ApplicationInstance app = new ApplicationInstance(file, group, loader, AppContext.getAppContext()); loader.setApplication(app); return app; diff --git a/netx/net/sourceforge/jnlp/PluginParameters.java b/netx/net/sourceforge/jnlp/PluginParameters.java index fa4e8fa..c3a958c 100644 --- a/netx/net/sourceforge/jnlp/PluginParameters.java +++ b/netx/net/sourceforge/jnlp/PluginParameters.java @@ -80,7 +80,7 @@ public class PluginParameters { * * @return the underlying hashtable. */ - Hashtable<String, String> getUnderlyingHashtable() { + public Hashtable<String, String> getUnderlyingHashtable() { return parameters; } @@ -134,6 +134,10 @@ public class PluginParameters { return getDefaulted("code", ""); } + public String getIsApplet3() { + return getDefaulted("is_applet3", "false"); + } + public String getJNLPHref() { return get("jnlp_href"); } diff --git a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java index 757a9f7..49947ff 100644 --- a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java +++ b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java @@ -19,6 +19,7 @@ package net.sourceforge.jnlp.runtime; import java.applet.*; import java.awt.*; +import sun.awt.AppContext; import net.sourceforge.jnlp.*; import net.sourceforge.jnlp.util.logging.OutputController; @@ -45,7 +46,7 @@ public class AppletInstance extends ApplicationInstance { * Create a New Task based on the Specified URL */ public AppletInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Applet applet) { - super(file, group, loader); + super(file, group, loader, AppContext.getAppContext()); this.applet = applet; @@ -67,7 +68,7 @@ public class AppletInstance extends ApplicationInstance { * */ public AppletInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Applet applet, Container cont) { - super(file, group, loader); + super(file, group, loader, AppContext.getAppContext()); this.applet = applet; this.environment = new AppletEnvironment(file, this, cont); } diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java index 0258840..a16b0b5 100644 --- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java @@ -16,7 +16,7 @@ package net.sourceforge.jnlp.runtime; -import java.awt.Window; +// import java.awt.Window; import java.io.File; import java.net.URL; import java.security.AccessControlContext; @@ -25,17 +25,17 @@ import java.security.CodeSource; import java.security.PrivilegedAction; import java.security.ProtectionDomain; -import javax.swing.event.EventListenerList; - -import sun.awt.AppContext; +// FIXME replace - currently unused +// import javax.swing.event.EventListenerList; import net.sourceforge.jnlp.JNLPFile; import net.sourceforge.jnlp.PropertyDesc; import net.sourceforge.jnlp.SecurityDesc; import net.sourceforge.jnlp.ShortcutDesc; import net.sourceforge.jnlp.config.DeploymentConfiguration; -import net.sourceforge.jnlp.event.ApplicationEvent; -import net.sourceforge.jnlp.event.ApplicationListener; +// FIXME replace - currently unused +// import net.sourceforge.jnlp.event.ApplicationEvent; +// import net.sourceforge.jnlp.event.ApplicationListener; import net.sourceforge.jnlp.security.SecurityDialogs; import net.sourceforge.jnlp.security.SecurityDialogs.AccessType; import net.sourceforge.jnlp.util.logging.OutputController; @@ -56,13 +56,16 @@ public class ApplicationInstance { // installed by the application. /** the file */ - private JNLPFile file; + private final JNLPFile file; /** the thread group */ - private ThreadGroup group; + private final ThreadGroup group; /** the classloader */ - private ClassLoader loader; + private final ClassLoader loader; + + /** whether or not this application is signed */ + private final boolean isSigned; /** * Every application/applet gets its own AppContext. This allows us to do @@ -71,51 +74,55 @@ public class ApplicationInstance { * event queue (safely) and (possibly) more.<p> * * It is set to the AppContext which created this ApplicationInstance + * + * Either {@link sun.awt.AppContext} or .. + * + * FIXME: Add proper interface */ - private AppContext appContext; + private final Object appContext; /** whether the application has stopped running */ private boolean stopped = false; - /** weak list of windows opened by the application */ - private WeakList<Window> weakWindows = new WeakList<Window>(); + /** weak list of UI window objects opened by the application */ + private WeakList<Object> weakWindows = new WeakList<Object>(); /** list of application listeners */ - private EventListenerList listeners = new EventListenerList(); - - /** whether or not this application is signed */ - private boolean isSigned = false; + // FIXME replace - currently unused + // private EventListenerList listeners = new EventListenerList(); /** * Create an application instance for the file. This should be done in the * appropriate {@link ThreadGroup} only. */ - public ApplicationInstance(JNLPFile file, ThreadGroup group, ClassLoader loader) { + public ApplicationInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Object appContext) { this.file = file; this.group = group; this.loader = loader; this.isSigned = ((JNLPClassLoader) loader).getSigning(); - this.appContext = AppContext.getAppContext(); + this.appContext = appContext; } /** + // FIXME replace - currently unused * Add an Application listener - */ public void addApplicationListener(ApplicationListener listener) { listeners.add(ApplicationListener.class, listener); } - /** * Remove an Application Listener - */ public void removeApplicationListener(ApplicationListener listener) { listeners.remove(ApplicationListener.class, listener); } + */ /** * Notify listeners that the application has been terminated. */ protected void fireDestroyed() { + /** + // FIXME replace - currently unused + * Object list[] = listeners.getListenerList(); ApplicationEvent event = null; @@ -125,6 +132,7 @@ public class ApplicationInstance { ((ApplicationListener) list[i]).applicationDestroyed(event); } + */ } /** @@ -280,9 +288,13 @@ public class ApplicationInstance { try { // destroy resources - for (Window w : weakWindows) { - if (w != null) - w.dispose(); + for (Object w : weakWindows) { + if (w != null) { + // FIXME! + if( w instanceof java.awt.Window ) { + ((java.awt.Window)w).dispose(); + } + } } weakWindows.clear(); @@ -339,7 +351,7 @@ public class ApplicationInstance { * Adds a window that this application opened. When the * application is disposed, these windows will also be disposed. */ - protected void addWindow(Window window) { + public void addWindow(Object window) { weakWindows.add(window); weakWindows.trimToSize(); } @@ -351,7 +363,11 @@ public class ApplicationInstance { return isSigned; } - public AppContext getAppContext() { + /** + * Returns either {@link sun.awt.AppContext} or .. + * FIXME: Add proper interface + */ + public Object getAppContext() { return appContext; } diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java index c9d7397..b69d36c 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java @@ -16,7 +16,6 @@ package net.sourceforge.jnlp.runtime; -import java.awt.EventQueue; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -42,14 +41,16 @@ import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; -import javax.swing.JOptionPane; -import javax.swing.UIManager; -import javax.swing.text.html.parser.ParserDelegator; +// import javax.swing.JOptionPane; +// import javax.swing.UIManager; +// import javax.swing.text.html.parser.ParserDelegator; + + +import jogamp.plugin.jnlp.runtime.JNLP3SecurityManager; import net.sourceforge.jnlp.DefaultLaunchHandler; import net.sourceforge.jnlp.GuiLaunchHandler; import net.sourceforge.jnlp.LaunchHandler; -import net.sourceforge.jnlp.Launcher; import net.sourceforge.jnlp.browser.BrowserAwareProxySelector; import net.sourceforge.jnlp.cache.CacheUtil; import net.sourceforge.jnlp.cache.DefaultDownloadIndicator; @@ -92,7 +93,7 @@ public class JNLPRuntime { private static ResourceBundle resources; /** the security manager */ - private static JNLPSecurityManager security; + private static JNLP3SecurityManager security; /** the security policy */ private static JNLPPolicy policy; @@ -223,15 +224,17 @@ public class JNLPRuntime { ServiceManager.setServiceManagerStub(new XServiceManagerStub()); // ignored if we're running under Web Start policy = new JNLPPolicy(); - security = new JNLPSecurityManager(); // side effect: create JWindow + // security = new JNLPSecurityManager(); // side effect: create JWindow + security = new JNLP3SecurityManager(); // side effect: create JWindow + /** FIXME AWT try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); - } - + } doMainAppContextHacks(); + */ if (securityEnabled) { Policy.setPolicy(policy); // do first b/c our SM blocks setPolicy @@ -322,7 +325,7 @@ public class JNLPRuntime { /** * This must NOT be called form the application ThreadGroup. An application - * can inject events into its {@link EventQueue} and bypass the security + * can inject events into its {@link java.awt.EventQueue} and bypass the security * dialogs. * * @return a {@link SecurityDialogMessageHandler} that can be used to post @@ -341,18 +344,20 @@ public class JNLPRuntime { * Performs a few hacks that are needed for the main AppContext * * @see Launcher#doPerApplicationAppContextHacks - */ + * + * FIXME AWT private static void doMainAppContextHacks() { - /* + * * With OpenJDK6 (but not with 7) a per-AppContext dtd is maintained. * This dtd is created by the ParserDelgate. However, the code in * HTMLEditorKit (used to render HTML in labels and textpanes) creates * the ParserDelegate only if there are no existing ParserDelegates. The * result is that all other AppContexts see a null dtd. - */ + * new ParserDelegator(); } + */ /** @@ -379,9 +384,10 @@ public class JNLPRuntime { //all exceptions are causing InstantiatizationError so this do it much more readble OutputController.getLogger().log(OutputController.Level.ERROR_ALL, t); OutputController.getLogger().log(OutputController.Level.WARNING_ALL, Translator.R("RFailingToDefault")); + /* FIXME AWT if (!JNLPRuntime.isHeadless()){ JOptionPane.showMessageDialog(null, getMessage("RFailingToDefault")+"\n"+t.toString()); - } + } */ //try to survive this unlikely exception config.resetToDefaults(); } finally { @@ -707,6 +713,7 @@ public class JNLPRuntime { */ public synchronized static void markNetxRunning() { if (fileLock != null) return; + FileInputStream is = null; try { String message = "This file is used to check if netx is running"; @@ -723,7 +730,7 @@ public class JNLPRuntime { } } - FileInputStream is = new FileInputStream(netxRunningFile); + is = new FileInputStream(netxRunningFile); FileChannel channel = is.getChannel(); fileLock = channel.lock(0, 1, true); if (!fileLock.isShared()){ // We know shared locks aren't offered on this system. @@ -741,6 +748,12 @@ public class JNLPRuntime { } } catch (IOException e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); + } finally { + if( null != is ) { + try { + is.close(); + } catch (IOException e) { } + } } Runtime.getRuntime().addShutdownHook(new Thread("JNLPRuntimeShutdownHookThread") { diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java index 762bb91..5b6f2b0 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java @@ -442,7 +442,8 @@ class JNLPSecurityManager extends AWTSecurityManager { */ return mainAppContext; } else { - return app.getAppContext(); + // FIXME: Remove AWT dependencies! + return (AppContext) app.getAppContext(); } } diff --git a/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java b/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java index b43476e..8825183 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java +++ b/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java @@ -36,6 +36,8 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package net.sourceforge.jnlp.splashscreen; +import jogamp.plugin.jnlp.runtime.Applet3Environment; +import jogamp.plugin.jnlp.runtime.Applet3Instance; import net.sourceforge.jnlp.runtime.AppletEnvironment; import net.sourceforge.jnlp.runtime.AppletInstance; import net.sourceforge.jnlp.runtime.Boot; @@ -83,17 +85,44 @@ public class SplashUtils { OutputController.getLogger().log(t); } } + public static void showErrorCaught(Throwable ex, Applet3Instance appletInstance) { + try { + showError(ex, appletInstance); + } catch (Throwable t) { + // prinitng this exception is discutable. I have let it in for case that + //some retyping will fail + OutputController.getLogger().log(t); + } + } public static void showError(Throwable ex, AppletInstance appletInstance) { if (appletInstance == null) { + OutputController.getLogger().log(ex); return; } AppletEnvironment ae = appletInstance.getAppletEnvironment(); showError(ex, ae); } + public static void showError(Throwable ex, Applet3Instance appletInstance) { + if (appletInstance == null) { + OutputController.getLogger().log(ex); + return; + } + Applet3Environment ae = appletInstance.getAppletEnvironment(); + showError(ex, ae); + } public static void showError(Throwable ex, AppletEnvironment ae) { if (ae == null) { + OutputController.getLogger().log(ex); + return; + } + SplashController p = ae.getSplashControler(); + showError(ex, p); + } + public static void showError(Throwable ex, Applet3Environment ae) { + if (ae == null) { + OutputController.getLogger().log(ex); return; } SplashController p = ae.getSplashControler(); @@ -102,6 +131,7 @@ public class SplashUtils { public static void showError(Throwable ex, SplashController f) { if (f == null) { + OutputController.getLogger().log(ex); return; } |