org.ocd.shell
Class Shell

java.lang.Object
  |
  +--org.ocd.shell.Shell
All Implemented Interfaces:
java.io.Serializable

public final class Shell
extends java.lang.Object
implements java.io.Serializable

The Shell is the main entry point to the environment. by launching the Shell through the main method the environment is initialized. The Shell environment has been written to take advantage of features provided by the netx JNLP implementation and therefore will not work with other JNLP implementations.

First the shell processes the command line arguments. The arguments on the command line should be of the form -argname argvalue. Boolean arguments can just be specified by using -argname and there value will be set to true. For example:

-arg1 value1 -arg2 -arg3 value3

Would produce the argument values of arg1=value1, arg2=true, arg3=value3. Each startup arg is placed in the shell properties with the ARGS_PROPERTY_PREFIX appended to each argument name so for the above example the shell properties would contain:

shell.arg1 = value1
shell.arg2 = true
shell.arg3 = value3

Where shell. is the ARGS_PROPERTY_PREFIX. Any shell property can be retrieved by calling Shell.getProperty()

The only required argument is the envdir argument. This argument tells the shell where all of the environment files for this application are stored.

Boot Process

When the shell is started it first executes the boot.jnlp file. The boot.jnlp file should be located in the codebase dir where the shell was started from. The boot.jnlp file can also be specified using the -boot shell argument. The boot.jnlp file could execute any JNLP application but it is recommended that it launch the ServiceStarter application which should be passed a list of services to start. If the boot.jnlp is not found in the default location then it is skipped. If it was specified using the -boot option and cannot be found then an exception will be thrown and the shell application will terminate.

Once the boot process is complete then the shell will execute the startup.jnlp file. This file works just like the boot.jnlp file and should also be located in the shell's codebase dir. The startup.jnlp file can also be specified using the -startup shell argument. The startup.jnlp file is required and if it is not located in the codebase directory or specified using the -startup argument then an exception will be thrown.

Once the startup has completed the shell will check to see if there are any visible UI Windows. If no User Interface windows can be found then the shell will terminate. This helps ensure that the shell application will at least present the user with a minimal UI. This behavior can be turned off by using the -noui shell argument.

Services

The services that are started using the Service Starter are simple java applications. More information about Services can be found by reading the ServiceStarter documentation.

Argument Summary

 -envdir (local dir)    (Required) Environment Directory for this Application
 -boot (url)            URL of boot.jnlp file. Defaults to boot.jnlp in this Application's CodeBase
 -startup (url)         URL of startup.jnlp file. Defaults to startup.jnlp in this Application's CodeBase
 -splash (url)          URL of Splash Screen Image. Defaults to splash.png in this Application's CodeBase
 -noui                  Does not require that the Application create a User Interface

Version:

Author:
drichan
See Also:
Serialized Form

Field Summary
static java.lang.String ARGS_PROPERTY_PREFIX
           
static java.lang.String ENV_DIR_ARG
           
static java.lang.String NO_UI_ARG
           
 
Method Summary
 void addShellListener(IShellListener pListener)
          Add a Listener to be notified when the Shell Session has booted, started, or ended.
 void endSession(boolean force)
          End The Shell Session
 boolean getBooleanProperty(java.lang.String pName, boolean pDefault)
          Get a shell property as a boolean value
 java.io.File getEnvdir()
          Returns the envdir.
 java.lang.String getProperty(java.lang.String pName)
          Get a shell property
 java.lang.String getProperty(java.lang.String pName, java.lang.String pDefault)
          Get a shell property
static Shell getShell()
          Get the Current Shell
 javax.swing.JPanel getSplashPanel()
          Get the Shell's Splash Panel
 boolean hasBooted()
          Return true if this Shell Session has been Booted
 boolean hasStarted()
          Return true if this Shell Session has been Started
static void main(java.lang.String[] args)
          Main Method of the Shell Should only be called once.
 void removeShellListener(IShellListener pListener)
          Remove a Shell Listener
 void setProperty(java.lang.String pName, java.lang.String pValue)
          Set a shell property
protected  void startServiceException(java.lang.Throwable pExp)
          This is called if there is an Exception handled by the ServiceStarter when booting and Starting the Shell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARGS_PROPERTY_PREFIX

public static final java.lang.String ARGS_PROPERTY_PREFIX

ENV_DIR_ARG

public static final java.lang.String ENV_DIR_ARG

NO_UI_ARG

public static final java.lang.String NO_UI_ARG
Method Detail

main

public static void main(java.lang.String[] args)
Main Method of the Shell Should only be called once. This method creates a shell singleton. Calling main more then once from the same classloader will have no effect.
Parameters:
args - Arguments for Shell

getEnvdir

public java.io.File getEnvdir()
Returns the envdir.

hasBooted

public boolean hasBooted()
Return true if this Shell Session has been Booted

hasStarted

public boolean hasStarted()
Return true if this Shell Session has been Started

addShellListener

public void addShellListener(IShellListener pListener)
Add a Listener to be notified when the Shell Session has booted, started, or ended.
Parameters:
listener - to add

removeShellListener

public void removeShellListener(IShellListener pListener)
Remove a Shell Listener
Parameters:
listener - to remove

getSplashPanel

public javax.swing.JPanel getSplashPanel()
Get the Shell's Splash Panel
Returns:
JPanel where the Splash Image is Painted

endSession

public void endSession(boolean force)
End The Shell Session
Parameters:
force - if true does not ask the user if the shell session should end

getShell

public static Shell getShell()
Get the Current Shell

getBooleanProperty

public boolean getBooleanProperty(java.lang.String pName,
                                  boolean pDefault)
Get a shell property as a boolean value
Parameters:
name - of the property
default - value
Returns:
value or default value if not found

getProperty

public java.lang.String getProperty(java.lang.String pName,
                                    java.lang.String pDefault)
Get a shell property
Parameters:
name - of the property
default - value
Returns:
value or default if not found

getProperty

public java.lang.String getProperty(java.lang.String pName)
Get a shell property
Parameters:
name - of the property
Returns:
value

setProperty

public void setProperty(java.lang.String pName,
                        java.lang.String pValue)
Set a shell property
Parameters:
name - of the property
value - of Property

startServiceException

protected void startServiceException(java.lang.Throwable pExp)
This is called if there is an Exception handled by the ServiceStarter when booting and Starting the Shell