netx.jnlp
Class Launcher

java.lang.Object
  |
  +--netx.jnlp.Launcher

public class Launcher
extends java.lang.Object

Launches JNLPFiles either in the foreground or background.

An optional LaunchHandler can be specified that is notified of warning and error condition while launching and that indicates whether a launch may proceed after a warning has occurred. If specified, the LaunchHandler is notified regardless of whether the file is launched in the foreground or background.

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

Constructor Summary
Launcher()
          Create a launcher with no handler.
Launcher(LaunchHandler handler)
          Create a launcher with an optional handler.
Launcher(LaunchHandler handler, UpdatePolicy policy)
          Create a launcher with an optional handler using the specified update policy.
 
Method Summary
protected  AppletInstance createApplet(JNLPFile file, boolean enableCodeBase)
          Create an AppletInstance.
protected  ApplicationInstance createApplication(JNLPFile file)
          Creates an Application.
protected  AppThreadGroup createThreadGroup(JNLPFile file)
          Create a thread group for the JNLP file.
 ApplicationInstance launch(JNLPFile file)
          Launches a JNLP file by calling the launch method for the appropriate file type.
 ApplicationInstance launch(java.net.URL location)
          Launches a JNLP file by calling the launch method for the appropriate file type.
protected  ApplicationInstance launchApplet(JNLPFile file, boolean enableCodeBase)
          Launches a JNLP applet.
protected  ApplicationInstance launchApplication(JNLPFile file)
          Launches a JNLP application.
 void launchBackground(JNLPFile file)
          Launches a JNLP file by calling the launch method for the appropriate file type in a different thread.
 void launchBackground(java.net.URL location)
          Launches the JNLP file at the specified location in the background by calling the launch method for its file type.
 void launchExternal(JNLPFile file)
          Launches the JNLP file in a new JVM instance.
 void launchExternal(java.net.URL location)
          Launches the JNLP file at the specified location in a new JVM instance.
protected  ApplicationInstance launchInstaller(JNLPFile file)
          Launches a JNLP installer.
 void setUpdatePolicy(UpdatePolicy policy)
          Sets the update policy used by launched applications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Launcher

public Launcher()
Create a launcher with no handler.

Launcher

public Launcher(LaunchHandler handler)
Create a launcher with an optional handler.
Parameters:
handler - the handler to use or null.

Launcher

public Launcher(LaunchHandler handler,
                UpdatePolicy policy)
Create a launcher with an optional handler using the specified update policy.
Parameters:
handler - the handler to use or null.
policy - the update policy to use.
Method Detail

setUpdatePolicy

public void setUpdatePolicy(UpdatePolicy policy)
Sets the update policy used by launched applications.

launch

public ApplicationInstance launch(JNLPFile file)
                           throws LaunchException
Launches a JNLP file by calling the launch method for the appropriate file type.
Parameters:
file - the JNLP file to launch
Returns:
the application instance
Throws:
LaunchException - if an error occurred while launching (also sent to handler)

launch

public ApplicationInstance launch(java.net.URL location)
                           throws LaunchException
Launches a JNLP file by calling the launch method for the appropriate file type.
Parameters:
location - the URL of the JNLP file to launch
Returns:
the application instance
Throws:
LaunchException - if there was an exception

launchBackground

public void launchBackground(JNLPFile file)
Launches a JNLP file by calling the launch method for the appropriate file type in a different thread.
Parameters:
file - the JNLP file to launch

launchBackground

public void launchBackground(java.net.URL location)
Launches the JNLP file at the specified location in the background by calling the launch method for its file type.
Parameters:
location - the location of the JNLP file

launchExternal

public void launchExternal(JNLPFile file)
                    throws LaunchException
Launches the JNLP file in a new JVM instance. The launched application's output is sent to the system out and it's standard input channel is closed.
Parameters:
file - the JNLP file to launch
Throws:
LaunchException - if there was an exception

launchExternal

public void launchExternal(java.net.URL location)
                    throws LaunchException
Launches the JNLP file at the specified location in a new JVM instance. The launched application's output is sent to the system out and it's standard input channel is closed.
Parameters:
location - the URL of the JNLP file to launch
Throws:
LaunchException - if there was an exception

launchApplication

protected ApplicationInstance launchApplication(JNLPFile file)
                                         throws LaunchException
Launches a JNLP application. This method should be called from a thread in the application's thread group.

launchApplet

protected ApplicationInstance launchApplet(JNLPFile file,
                                           boolean enableCodeBase)
                                    throws LaunchException
Launches a JNLP applet. This method should be called from a thread in the application's thread group.

The enableCodeBase parameter adds the applet's codebase to the locations searched for resources and classes. This can slow down the applet loading but allows browser-style applets that don't use JAR files exclusively to be run from a applet JNLP file. If the applet JNLP file does not specify any resources then the code base will be enabled regardless of the specified value.

Parameters:
file - the JNLP file
enableCodeBase - whether to add the codebase URL to the classloader

launchInstaller

protected ApplicationInstance launchInstaller(JNLPFile file)
                                       throws LaunchException
Launches a JNLP installer. This method should be called from a thread in the application's thread group.

createApplet

protected AppletInstance createApplet(JNLPFile file,
                                      boolean enableCodeBase)
                               throws LaunchException
Create an AppletInstance.
Parameters:
enableCodeBase - whether to add the code base URL to the classloader

createApplication

protected ApplicationInstance createApplication(JNLPFile file)
                                         throws LaunchException
Creates an Application.

createThreadGroup

protected AppThreadGroup createThreadGroup(JNLPFile file)
Create a thread group for the JNLP file.