IcedTea-Web
NetX

net.sourceforge.jnlp.runtime
Class JNLPRuntime

java.lang.Object
  extended by net.sourceforge.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.


Field Summary
static java.lang.Object initMutex
          mutex to wait on, for initialization
static java.lang.String STDERR_FILE
           
static java.lang.String STDOUT_FILE
           
 
Constructor Summary
JNLPRuntime()
           
 
Method Summary
static void disableExit()
          Disables applets from calling exit.
static ApplicationInstance getApplication()
          Return the current Application, or null if none can be determined.
static DeploymentConfiguration getConfiguration()
          Gets the Configuration associated with this runtime
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 boolean getForksAllowed()
          Returns true if the current runtime will fork
static java.util.List<java.lang.String> getInitialArguments()
           
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 SecurityDialogMessageHandler getSecurityDialogHandler()
           
static java.awt.Image getWindowIcon()
          Returns the window icon.
static void initialize(boolean isApplication)
          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 boolean isUnix()
           
static boolean isVerifying()
          Returns whether we are verifying code signing.
static boolean isWebstartApplication()
          Returns true if a webstart application has been initialized, and false for a plugin applet.
static boolean isWindows()
           
static void markNetxRunning()
          Indicate that netx is running by creating the JNLPRuntime#INSTANCE_FILE and acquiring a shared lock on it
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 setForksAllowed(boolean value)
           
static void setHeadless(boolean enabled)
          Sets whether the JNLP client will use any AWT/Swing components.
static void setInitialArgments(java.util.List<java.lang.String> args)
           
static void setRedirectStreams(boolean redirect)
          Sets whether the standard output/error streams should be redirected to the loggging files.
static void setSecurityEnabled(boolean enabled)
          Sets whether to enable the secure runtime environment.
static void setVerify(boolean enabled)
          Sets whether we will verify code signing.
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
 

Field Detail

initMutex

public static java.lang.Object initMutex
mutex to wait on, for initialization


STDERR_FILE

public static final java.lang.String STDERR_FILE
See Also:
Constant Field Values

STDOUT_FILE

public static final java.lang.String STDOUT_FILE
See Also:
Constant Field Values
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(boolean isApplication)
                       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 should be called from the main AppContext/Thread.

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

Parameters:
isApplication - is true if a webstart application is being initialized
Throws:
java.lang.IllegalStateException - if the runtime was previously initialized

getConfiguration

public static DeploymentConfiguration getConfiguration()
Gets the Configuration associated with this runtime

Returns:
a DeploymentConfiguration object that can be queried to find relevant configuration settings

isWebstartApplication

public static boolean isWebstartApplication()
Returns true if a webstart application has been initialized, and false for a plugin applet.


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.


isVerifying

public static boolean isVerifying()
Returns whether we are verifying code signing.


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

setVerify

public static void setVerify(boolean enabled)
Sets whether we will verify code signing.

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

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

getSecurityDialogHandler

public static SecurityDialogMessageHandler getSecurityDialogHandler()
Returns:
the SecurityDialogMessageHandler that should be used to post security dialog messages

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

disableExit

public static void disableExit()
Disables applets from calling exit. Once disabled, exit cannot be re-enabled for the duration of the JVM instance


getApplication

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


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

setRedirectStreams

public static void setRedirectStreams(boolean redirect)
Sets whether the standard output/error streams should be redirected to the loggging files.

Throws:
java.lang.IllegalStateException - if the runtime has already been initialized

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

getForksAllowed

public static boolean getForksAllowed()
Returns true if the current runtime will fork


setForksAllowed

public static void setForksAllowed(boolean value)

isWindows

public static boolean isWindows()
Returns:
true if running on Windows

isUnix

public static boolean isUnix()
Returns:
true if running on a Unix or Unix-like system (including Linux and *BSD)

setInitialArgments

public static void setInitialArgments(java.util.List<java.lang.String> args)

getInitialArguments

public static java.util.List<java.lang.String> getInitialArguments()

markNetxRunning

public static void markNetxRunning()
Indicate that netx is running by creating the JNLPRuntime#INSTANCE_FILE and acquiring a shared lock on it


IcedTea-Web
NetX

Submit a bug or feature