Homepage

netx.jnlp.runtime
Class JNLPRuntime

java.lang.Object
  extended by netx.jnlp.runtime.JNLPRuntime

public class JNLPRuntime
extends java.lang.Object

Configure and access the runtime environment. This class stores global jnlp properties such as default download indicators, the install/base directory, the default resource update policy, etc. Some settings, such as the base directory, cannot be changed once the runtime has been initialized.

The JNLP runtime can be locked to prevent further changes to the runtime environment except by a specified class. If set, only instances of the exit class can exit the JVM or change the JNLP runtime settings once the runtime has been initialized.

Version:
$Revision: 1.19 $
Author:
Jon A. Maxwell (JAM) - initial author

Constructor Summary
JNLPRuntime()
           
 
Method Summary
static ApplicationInstance getApplication()
          Return the current Application, or null if none can be determined.
static java.io.File getBaseDir()
          Return the base directory containing the cache, persistence store, etc.
static java.io.File getDefaultBaseDir()
          Returns the system default base dir for or if not set, prompts the user for the location.
static DownloadIndicator getDefaultDownloadIndicator()
          Returns the default download indicator.
static LaunchHandler getDefaultLaunchHandler()
          Returns the default launch handler.
static UpdatePolicy getDefaultUpdatePolicy()
          Returns the default update policy.
static java.lang.String getMessage(java.lang.String key)
          Returns the localized resource string identified by the specified key.
static java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
          Returns the localized resource string using the specified arguments.
static PropertiesFile getProperties()
          Return a PropertiesFile object backed by the runtime's properties file.
static java.awt.Image getWindowIcon()
          Returns the window icon.
static void initialize()
          Initialize the JNLP runtime environment by installing the security manager and security policy, initializing the JNLP standard services, etc.
static boolean isDebug()
          Return whether debug statements for the JNLP client code should be printed.
static boolean isHeadless()
          Returns whether the JNLP client will use any AWT/Swing components.
static boolean isInitialized()
          Returns whether the JNLP runtime environment has been initialized.
static boolean isSecurityEnabled()
          Returns whether the secure runtime environment is enabled.
static void setBaseDir(java.io.File baseDirectory)
          Sets the base directory containing the cache, persistence store, etc.
static void setDebug(boolean enabled)
          Sets whether debug statements for the JNLP client code should be printed to the standard output.
static void setDefaultDownloadIndicator(DownloadIndicator indicator)
          Sets the default download indicator.
static void setDefaultLaunchHandler(LaunchHandler handler)
          Sets the default launch handler.
static void setDefaultUpdatePolicy(UpdatePolicy policy)
          Sets the default update policy.
static void setExitClass(java.lang.Class exitClass)
          Set a class that can exit the JVM; if not set then any class can exit the JVM.
static void setHeadless(boolean enabled)
          Sets whether the JNLP client will use any AWT/Swing components.
static void setSecurityEnabled(boolean enabled)
          Sets whether to enable the secure runtime environment.
static void setWindowIcon(java.awt.Image image)
          Sets the window icon that is displayed in Java applications and applets instead of the default Java icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNLPRuntime

public JNLPRuntime()
Method Detail

isInitialized

public static boolean isInitialized()
Returns whether the JNLP runtime environment has been initialized. Once initialized, some properties such as the base directory cannot be changed. Before


initialize

public static void initialize()
                       throws java.lang.IllegalStateException
Initialize the JNLP runtime environment by installing the security manager and security policy, initializing the JNLP standard services, etc.

This method cannot be called more than once. Once initialized, methods that alter the runtime can only be called by the exit class.

Throws:
java.lang.IllegalStateException - if the runtime was previously initialized

getWindowIcon

public static java.awt.Image getWindowIcon()
Returns the window icon.


setWindowIcon

public static void setWindowIcon(java.awt.Image image)
Sets the window icon that is displayed in Java applications and applets instead of the default Java icon.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

isHeadless

public static boolean isHeadless()
Returns whether the JNLP client will use any AWT/Swing components.


setHeadless

public static void setHeadless(boolean enabled)
Sets whether the JNLP client will use any AWT/Swing components. In headless mode, client features that use the AWT are disabled such that the client can be used in headless mode (java.awt.headless=true).

Throws:
java.lang.IllegalStateException - if the runtime was previously initialized

getBaseDir

public static java.io.File getBaseDir()
Return the base directory containing the cache, persistence store, etc.


setBaseDir

public static void setBaseDir(java.io.File baseDirectory)
Sets the base directory containing the cache, persistence store, etc.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

isSecurityEnabled

public static boolean isSecurityEnabled()
Returns whether the secure runtime environment is enabled.


setSecurityEnabled

public static void setSecurityEnabled(boolean enabled)
Sets whether to enable the secure runtime environment. Disabling security can increase performance for some applications, and can be used to use netx with other code that uses its own security manager or policy. Disabling security is not recommended and should only be used if the JNLP files opened are trusted. This method can only be called before initalizing the runtime.

Parameters:
enabled - whether security should be enabled
Throws:
java.lang.IllegalStateException - if the runtime is already initialized

getDefaultBaseDir

public static java.io.File getDefaultBaseDir()
Returns the system default base dir for or if not set, prompts the user for the location.

Returns:
the base dir, or null if the user canceled the dialog
Throws:
java.io.IOException - if there was an io exception

setExitClass

public static void setExitClass(java.lang.Class exitClass)
Set a class that can exit the JVM; if not set then any class can exit the JVM.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

getApplication

public static ApplicationInstance getApplication()
Return the current Application, or null if none can be determined.


getProperties

public static PropertiesFile getProperties()
Return a PropertiesFile object backed by the runtime's properties file.


isDebug

public static boolean isDebug()
Return whether debug statements for the JNLP client code should be printed.


setDebug

public static void setDebug(boolean enabled)
Sets whether debug statements for the JNLP client code should be printed to the standard output.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

setDefaultUpdatePolicy

public static void setDefaultUpdatePolicy(UpdatePolicy policy)
Sets the default update policy.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

getDefaultUpdatePolicy

public static UpdatePolicy getDefaultUpdatePolicy()
Returns the default update policy.


setDefaultLaunchHandler

public static void setDefaultLaunchHandler(LaunchHandler handler)
Sets the default launch handler.


getDefaultLaunchHandler

public static LaunchHandler getDefaultLaunchHandler()
Returns the default launch handler.


setDefaultDownloadIndicator

public static void setDefaultDownloadIndicator(DownloadIndicator indicator)
Sets the default download indicator.

Throws:
java.lang.IllegalStateException - if caller is not the exit class

getDefaultDownloadIndicator

public static DownloadIndicator getDefaultDownloadIndicator()
Returns the default download indicator.


getMessage

public static java.lang.String getMessage(java.lang.String key)
Returns the localized resource string identified by the specified key. If the message is empty, a null is returned.


getMessage

public static java.lang.String getMessage(java.lang.String key,
                                          java.lang.Object[] args)
Returns the localized resource string using the specified arguments.

Parameters:
args - the formatting arguments to the resource string

Homepage