netx.jnlp.runtime

Class 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

Method Summary

static ApplicationInstance
getApplication()
Return the current Application, or null if none can be determined.
static File
getBaseDir()
Return the base directory containing the cache, persistence store, etc.
static 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 String
getMessage(String key)
Returns the localized resource string identified by the specified key.
static String
getMessage(String key, 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 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(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(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(Image image)
Sets the window icon that is displayed in Java applications and applets instead of the default Java icon.

Method Details

getApplication

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

getBaseDir

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

getDefaultBaseDir

public static 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

getDefaultDownloadIndicator

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

getDefaultLaunchHandler

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

getDefaultUpdatePolicy

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

getMessage

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

getMessage

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

getProperties

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

getWindowIcon

public static Image getWindowIcon()
Returns the window icon.

initialize

public static void initialize()
            throws 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.


isDebug

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

isHeadless

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

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

isSecurityEnabled

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

setBaseDir

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

setDebug

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

setDefaultDownloadIndicator

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

setDefaultLaunchHandler

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

setDefaultUpdatePolicy

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

setExitClass

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

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).

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

setWindowIcon

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