Xito Bootstrap Developers Guide: Prepared By: Deane Richan
Xito Bootstrap Developers Guide: Prepared By: Deane Richan
Developers Guide
prepared by: Deane Richan
These three high level goals can be described simply as: Remote Launching, Secure
Execution, and Shared VM. In addition, an important aspect of the approach followed
by the BootStrap is seamless native integration, both in terms of user interface and
functionality.
This document describes how developers can use the BootStrap to deploy their
applications and create execution environments that take advantage of BootStrap's
built-in abilities.
BootStrap Architecture
The Xito BootStrap is the entry point to the larger Xito platform. Although BootStrap is
designed to boot the Xito platform it can be used to boot any application or set of
application services.
The BootStrap initializes the environment, sets up the security manager, and then loads
a set of services. Services are just Java Applications and don't require any specific
interface implementation.
The BootStrap launches services and applications into a single Java virtual machine.
This reduces memory requirements of all applications and services running in the
environment, and also enables very quick execution of downloaded applications.
1
requirements and allows untrusted code to run along side trusted code. However
sharing a VM requires applications to cooperate with relation to the VM resources.
Applications that want full control over the virtual machine can be launched into a new
VM instance from the bootstrap.
Applications and services running in the BootStrap are designed to be executed directly
from a web server. Therefore there is no installation required for services or
applications. They are also always up to date because they are running from remote
servers.
A caching mechanism is used in the BootStrap to cache Java applications and service
resources on the local hard drive so that they do not need to be downloaded each time
they are executed. Also the local cache enables applications to be executed when the
client is not connected to the network, a feature not available for traditional HTML
based web applications. This network launching functionality allows applications
deployed through Xito to have the benefits of a web application and also the benefits of
a rich client application.
The following diagram describes the major components of the Xito Platform.
The Xito BootStrap is the entry point to the platform. The BootStrap is a Java
2
Application that initializes the environment, reads system properties, starts a Security
Manager, and then executes a set of services.
The BootStrap also handles all loading of application resources and execution of
applications. It provides this functionality through four main components: Service
Manger, Cache Manager, ClassLoaders and Executable Descriptors. A separate
Launching Service is provided to perform more complex application launching such as
Java Applets or JNLP based Java applications.
Bootstrap also contains a win32 native executable that can be used to launch the
application on Windows platforms. The native exe can be renamed to what ever
application name the developer wants for their application.
BootStrap Installation
System Requirements
JRE 1.4.2+
Windows, MacOSX, Linux x86
Note: BootStrap has been primarily written and tested on the Windows Platform.
MacOSX and Linux should also work but testing efforts have not been completed on
those platforms.
License
Xito BootStrap is distributed under the Common Development and Distribution
License (CDDL) version 1.0. See: http://www.sun.com/cddl/cddl.html for more
information.
Unzip the BootStrap into a directory of your choosing. The following files are included:
Filename Description
boot.jar Main Jar of the BootStrap environment
boot.properties BootStrap properties to initialize this
environment
boot_services.xml List of Boot Services
sample.jar Jar of Sample Service
3
Filename Description
sample.srv Sample Service Descriptor
start_services.xml List of Startup Services
bootstrap.exe Win32 Launcher
bootstrap_console.exe Win32 Launcher with console output
license.html CDDL License Info
Note: The bootstrap.exe and bootstrap_console.exe are provided with the Win32
bootstrap release. These executables will attempt to locate the Java VM using the
Windows Registry and then boot the environment. They can be renamed to your
application name if you prefer.
To test the installation of the BootStrap run one of the native EXEs or at a command
prompt in the bootstrap directory execute: java -jar boot.jar
You will first be prompted to configure your Proxy Server. This will just occur the first
time you execute this application configuration.
After you configure the Proxy Settings for your machine the Sample Service should
execute. This sample Service is a simple application launcher that will launch the Java
4
SwingSet from the Sun web servers or launch the Asteroids games from the Xito web
server.
When executing any code under Bootstrap that does not exist in the boot directory, the
user will be prompted to grant permissions to that application or service.
With the sample application if the user chooses to launch asteroids or SwingSet they
will be prompted to grant permissions to those applications.
Note: SwingSet will not execute correctly if it is not granted All Permissions. The
Asteroids sample application will execute if it is denied permissions but will be running
in a restricted environment. The Asteroids window will contain a restricted content
warning banner and its full screen mode will be disabled.
5
Illustration 3Sample Permissions dialog for launching Asteroids
Using this dialog the user can view the code source of the application and whether it
was signed and by whom. They can then Allow the permission or Deny it.
6
Boot Sequence of a BootStrap Application
To launch a BootStrap configured application you simply execute the BootStrap using:
This will start the boot process using the following sequence:
example:
If the bootdir is not a valid directory then the boot process will fail with an error.
Read boot.properties
After the bootdir is located a boot.properties file is read from that directory. A
boot.properties file must exist. If it does not the boot process will fail with an
error.
Read logging.properties
If a logging.properties file is found in the bootdir it will be processed to configure
the logging settings of the environment. BootStrap uses the built in
7
java.util.logging package for log messages. For information on configuring the
logging.properties file see the Java Logging API documentation in the class:
java.util.logging.LogManager
Proxy Configuration
The first time the application is executed the user will be prompted for a Proxy
Configuration. This prompt is skipped if proxy settings are already contained in
the boot.properties
Service Startup
The services are then started using the boot_services.xml and start_services.xml
files located in the bootdir. These files list the service applications or a single
application that should be started by the bootstrap.
All Boot Services must execute without exception for the environment to boot. All
Startup Services are considered optional and therefore don't need to execute
successfully for the boot process to succeed.
UI Check
Because BootStrap is a client execution framework the assumption is that a GUI
will be presented to the user by one of the running services. When BootStrap
has finished launching all services it will attempt to determine if a UI Window has
been created. It does this by creating a timer to check for a UI Window after 20
seconds of the Services being started. If a UI window can not be found then the
Boot process will fail with an Error. This behavior can be turned off by running
BootStrap in the nogui mode.
After the services are started the environment has been booted and should be up and
running.
8
Configuring BootStrap
The main Bootstrap configuration consists of three separate configuration files. These
include: boot.properties, boot_services.xml and start_services.xml.
These files specify how the environment is to initialize and what services should be
started. Also a limited number of Startup Arguments can be passed on the command
line.
Startup Arguments
The following startup arguments can be passed to the bootstrap command line.
Argument Description
-bootdir Directory where the boot files will reside
-nogui Defaults to false. If true then Bootstrap will not
display any UI Prompts or messages. See
boot.nogui boot property for more
information
-minmode Start the environment in minimum mode. This
will cause only boot_services to be started and
only those flagged as:
<minimum-srv>true</minimum-srv> in the
boot_services.xml file
Configuring boot.properties
The boot.properties settings contains options to configure the BootStrap
environment. The file can also contain any Java System property because all
settings in the boot.properties file will be loaded into System.properties. The file
should be located in the boot dir of the application.
The following boot.properties settings can be specified in the file
Property Description
app.name (required) The app.name property specifies
the name of this application. This name should
be a short variable style name. For example if
your application is called “ACME SQL Editor”
then the app.name property should be
something like: acme_sql_editor
9
Property Description
app.display.name (Optional) The app.display.name is used to
display the name of your application in
prompts or other UI elements. This defaults to
the value of app.name if not specified. Using
the example from app.name you could specify
the app.display.name to be “ACME SQL
Editor”
app.icon (Optional) The default Icon that is used for all
UI windows in the environment. This icon will
replace the normal Java Icon unless you
explicitly specify your window icons in your
java code. This setting is a URL location that
is considered to be relative to the bootdir.
app.base.dir (Optional) The directory where this application
stores all of its settings: Preferences, Security
Permissions, Cache etc. By default this
directory will be {user.home}/.{app.name}
10
Property Description
boot.use.cache (Optional) Defaults to true. Setting this to false
will cause the Cache Manager to not store
downloaded resources in the local cache.
boot.cache.dir (Optional) This is the directory where the
cache manager will stored downloaded
resources. This directory will default to
{app.base.dir}/cache
boot.proxy.prompt (Optional) Defaults to true. If this setting is set
to false then the user will not be prompted for
Proxy settings on the first launch.
native.laf (Optional) Defaults to true. By default
bootstrap will use the native platforms look and
feel for its GUI. Setting this to false will cause
Java to use its default look and feel which is
usually the Swing Metal Look and Feel.
As the table above describes the only setting that is required is the app.name. All other
settings are optional.
11
Launching BootStrap from Java WebStart
The Xito BootStrap is designed to work in place of the Java WebStart therefore
launching a BootStrap based application from WebStart is error prone. However at
times it may be useful to have WebStart launch your application. Therefore starting with
the 1.0.1 release, the ability to launch a BootStrap based application environment from
WebStart is now supported.
The functionality in the BootStrap to enable this is called QuickLaunch. Basically you
can provide a JNLP file that will launch the BootStrap. When BootStrap sees that it has
been launched by a JNLP Client such as WebStart it will tricker the BootStrap to go into
QuickLaunch Mode.
While in QuickLaunch Mode the BootStrap will obtain a list of Boot Files to install on the
client from the server and will cache and copy these files to the local machine. It will
then launch a new instance of the BootStrap based on these copied files.
To use QuickLaunch you need a JNLP file that webstart can use to launch the
BootStrap. The BootStrap distribution contains a sample JNLP file for this purpose
called quick_launch.jnlp.
12
Sample quick_launch.jnlp file:
The code base should be the location on the webserver you have placed your boot.jar
and boot.properties files.
You can also modify the <property name=”quicklaunch.app.display.name”> to change
the name of the application that the BootStrap will use while its in QuickLaunch mode.
13
Sample quick_file_list.txt:
boot.jar
boot.properties
xito_16.png
The files boot.jar and boot.properties are required. These are the minimum files that
you need to start the BootStrap. The files listed should be placed on the webserver
relative to the codebase specified in the JNLP file. Lines starting with # are considered
comments in this file.
boot.services.url=http://xito.test/test_app/boot_services.xml
startup.services.url=http://xito.test/test_app/start_services.xml
quicklaunch.install.dir=Xito
14
Once the files have been copied to the install directory BootStrap will launch the
boot.jar that it copied to the install directory using a new Java VM process. The VM will
be the same version that was used by the WebStart application.
From this point execution resembles the normal BootStrap boot process.
15
Boot and Startup Services
After the Boot process has configured the environment, and setup the cache manager
and security manager, it will boot a set of specified Services. Services are simply Java
applications that have been configured to be started by the BootStrap. There are two
sets of Services: boot services and startup services. Boot Services are required to
execute with out exception for the environment to boot successfully. Startup Services
are started after Boot Services and do not have to start successfully for the
environment to complete the boot process. In other words, Boot Services are required
services and Startup Services are optional services.
Note: If the environment is in minmode only boot services specified as minimum
services will be started. Startup Services will be skipped.
There are four settings that can be specified for each service, two are required. They
are
16
Element Description
name (Required) This is a name of the service.
The name should follow Java's package
naming structure. The name will uniquely
identify the service to the Service Manager
and be use to resolve dependent services
class dependences.
display-name (Optional) A Descriptive Name of This
service
minimum-srv (Optional) If set to true then this service
will be started if BootStrap is in minmode.
Min mode can be configured by passing a
-minmode command line argument. The
default is false.
href (Required) A URL pointing to a Service
Descriptor .srv file for this Service. The
URL can be absolute or relative to this
services.xml file
The Service Manager will iterate through each <service> element and load each
service in turn. The <href> element should point to a valid Service Descriptor XML file
for each Service. By convention each individual Service Descriptor file should have a .
srv extension.
17
<classpath>
<service-ref name="test.shared.service"/>
<lib path="sample.jar"/>
</classpath>
</service>
18
Element Description
lib (Optional)This element must reside under
a classpath element and names a jar
library that should be included in the
classpath. The attribute path is used to
name the path to the jar file. The path can
be absolute or relative to this Service
Descriptor file. If the element is used
under a native-libs element the attribute:
os can be used with the value “windows”,
“mac”, or “linux”
service-ref (Optional) This element must reside
under a classpath element and names a
service that should be included in this
services classpath. The attribute name is
used to name a service that should be
included. The service that is name must
have been already started by the service
manager.
Each service is configured to require All Permissions. Therefore when services are
launched from locations other then the bootdir the user will be prompted to grant the
service permissions.
To create a service the developer simply needs to write a standard Java Application
with a main method. Bundle that application into a jar and then create a Service
Descriptor file for it. Then list the service in either the boot or startup list of services. No
interfaces or BootStrap APIs need to be used.
initService Method
If the main Service class has implemented an initService method of the
19
signature:
public static void initService(ServiceDesc service)
Then the ServiceManager will call this method on your service just prior to calling
the static main method. The passed ServiceDesc object can be used to obtain
information about this service description which your Service can use to
dynamically alter the behavior of the service.
StartupListener
A StartupListener can be registered with the ServiceManager so that it can be
notified about the boot process taking place. An example of such a
StartupListener could be a SplashScreen service that listens for each Service
Starting and displays a message showing which services are starting.
To install a StartupListener implement the org.xito.boot.StartupListener
interface in a class and install the listener into the ServiceManager in the
initService or main method of the service, using this method:
ServiceManager.getManager().addStartupListener(myListener);
20
Launcher API
The Launcher API can be used by a service, or any application running in BootStrap, to
launch additional applications. Also any other utility API's provided by the BootStrap
including reflectKit and Dialog Manager can be used by services or applications.
The BootStrap supplied launcher apis can launch any basic java application taking
advantage of BootStrap Cache and Security Manager etc. A separate Launcher Service
is available separate from the BootStrap that adds support for launching Java Applets,
or JNLP (Web Start) applications.
The following code shows an example of launching a simple application from within a
BootStrap Service or application:
21
try {
AppDesc appDesc = new AppDesc("Asteroids", "Asteroids");
String codebase = "http://xito.sourceforge.net/apps/games/asteroids/";
appDesc.addURL(new URL(codebase+"asteroids.jar"));
appDesc.setPermissions(appDesc.getAllPermissions());
appDesc.setMainClass("org.xito.asteroids.MainApp");
appDesc.setNewAppContext(true);
AppLauncher launcher = new AppLauncher();
launcher.launchBackground(appDesc);
}
catch(Exception e) {
//Show user error
}
The constructor of AppDesc takes two String parameters the first is the Application
Name, the second is the Display name of the Application. These are used in security
dialogs and error messages.
When specifying the permissions the application will require, you should currently use 1
of 2 options either appDesc.setPermissions(AppDesc.getAllPermissions()) or
appDesc.setPermissions(AppDesc.getRestrictedPermissions())
When using the AppLauncher class to launch the application described by the AppDesc
you can call 1 of 3 methods they are described below:
22
Proxy Server Configuration
Because BootStrap is designed to run applications over the Internet or local network the
configuration of Proxy settings by users that need them becomes an important aspect
of the user interface. Bootstrap provides built in proxy configuration for your application
environment so you don't need to worry about it for your applications.
The first time the BootStrap environment is executed BootStrap checks to see if a
proxy.properties file exists in the app.base.dir. If the file exists Bootstrap will load the
settings in the file and continue booting the services. If the file does not exist and if the
boot.proxy.prompt is set to true (the default), BootStrap will prompt the user for their
proxy settings.
The following dialog shows the options available:
This Proxy Configuration is a thin wrapper around the Java Proxy implementation. Java
uses a set of System.properties that determine the proxy configuration. If the user
specifies Proxy Settings in the dialog BootStrap will write those settings into the
required System.properties.
The default setting is just set to: “I don't use a Proxy Server” in this case the user simple
hits OK and the environment continues to boot. If the user hits Cancel the environment
23
will boot but they will be prompted again next time the environment is launched.
If the boot.propeties setting of boot.proxy.prompt is set to false or the boot.properties
file contains proxy settings hard coded in it the proxy prompt will not appear.
Note: Any application that has permission can cause the Proxy Prompt to reappear by
calling the org.xito.boot.ProxyConfig.getProxyConfig().showProxyDialog();
24
Security Configuration
Java Security is one of the most powerful features of the Java Architecture and has
been pushed to the sideline by most Java Developers. Often Java Developers dislike
Security Managers and quickly try to determine ways to turn them off so that the do not
need to worry about security concerns in their applications. In general this is a mistake.
Java Security is the developers friend and will make your applications safer and your
users accept your applications easier.
The Security Manager and user interface for the security policies provided in Xito
Bootstrap are designed to be easy to use by end users and enhance your applications,
not hinder them. For this reason it is highly recommended that if you are using
BootStrap to boot your own application environment you not disable the security
manager.
That said, it is possible to disable the built in BootSecurityManager. The only valid
reason for doing this is if you plan on implementing your own Security Manager in one
of the boot services.
To disable the built in security you can specify: boot.no.security=true in the
boot.properties file. However if you take this option and then fail to install a Security
Manager in one of the Boot Services the BootStrap will warn your users that there is no
Security Manager installed with the following Alert Dialog:
Because of these restrictions the only way to run BootStrap based applications without
a security warning is to disable the built-in security manager in boot.properties and then
implement and install your own Security Manager. In summary, it it best to work in the
boundaries of BootStrap's default security environment.
25
Security Policy
Java Security Functionality is out of the scope of this document. Sun has published
many documents concerning Java Security Architecture and these documents should
be consulted for an in depth understanding of Security features in Java.
Xito Bootstrap attempts to make Security easy to understand for developers deploying
applications on top of the bootstrap.
In general the following Security Policy rules are implemented in the BootStrap:
1. All Permissions specified in Java's default java.policy file are honored.
2. All Code that resides in the boot directory of bootstrap are granted All
permissions.
3. All Other code that requests all Permissions will require the User to Grant those
permissions.
4. Code that has not be granted All Permissions will run in a Restricted
Permission Mode.
It is envisioned that the majority of service and application code running on top of
BootStrap will be downloaded and executed from the Internet or some other local
network server. Therefore, the vast majority of application code running within the
BootStrap environment will fall under rule: 3 or 4 above.
The easiest way to ensure that your application has All Permissions without causing the
Security Prompt to occur is to place your code in the boot dir of the BootStrap. This will
cause the code to be run under rule 2 of the policy.
The assumption with granting all code in the boot dir with All Permissions is that the
user has gone through the work to download and install your application “bootstrap”
onto their computer. Therefore code that has been bundled along with bootstrap and
placed in the boot dir should also have the same permissions that bootstrap itself
enjoys. Of course deploying your application in such a way requires that users
download new versions of your bootstrap based app each time you make changes.
Having bootstrap launch your application over the net removes this issue, and is the
preferred way to use BootStrap with your applications.
26
Description: This is basically a sentence that describes what the user is being asked to
do. An example description is:
Would you like to Grant: (All Permissions) to code source: http://host/.../myapp.jar
for “My Application”
Signed By: If the application code has been signed the prompt will display who it is
signed by and whether the certificate used to sign the code is valid. Valid certificates
are not expired and signed by a valid root certificate authority. Detailed information
about the certificate can be found by clicking view certificate on the security prompt
dialog.
Grant Options: The user will be given the following grant options:
Option Description
Just this once, for this code source Grant permissions to the code source for
just this Execution.
Just this once, for this application Grant permissions to this code source and
other code sources for this application for
just this Execution
Always, for this application Grant permissions to this code source and
other code sources for this application for
this and all future sessions
Always, for code sources signed with this Grant permissions to this code source and
certificate any other code sources signed by this
certificate for this and all future sessions
If the user chooses Allow the security permission will be granted with the option they
specified. If the user chooses Deny the application will be given Restricted Permissions
an application should be designed so that it can run with Restricted Permissions or in
the least case inform the user that it can't run in restricted permissions and exit.
27
Restricted Permissions
When applications are run in the Restricted environment they are granted only a
handful of permissions. These are basically the same permissions that un-signed
applets receive when they are running on a web page. The following table lists the
permissions that are granted in Restricted Mode:
Permission Implication
java.net.SocketPermission("localhost:1024-", "listen") The application can listen to any
Socket on the localhost on port
1024-65535
RuntimePermission("stopThread") The application can stop threads it
creates
28
Permission Implication
PropertyPermission("java.version", "read") The application can Read all these
PropertyPermission("java.vendor", "read") System Properties
PropertyPermission("java.vendor.url", "read")
PropertyPermission("java.class.version", "read")
PropertyPermission("os.name", "read")
PropertyPermission("os.version", "read")
PropertyPermission("os.acrch", "read")
PropertyPermission("file.separator", "read")
PropertyPermission("path.separator", "read")
PropertyPermission("line.separator", "read")
PropertyPermission("java.specification.version", "read")
PropertyPermission("java.specification.vendor", "read")
PropertyPermission("java.specification.name", "read")
PropertyPermission("java.vm.specification.version", "read")
PropertyPermission("java.vm.specification.vendor", "read")
PropertyPermission("java.vm.specification.name", "read")
PropertyPermission("java.vm.version", "read")
PropertyPermission("java.vm.vendor", "read")
PropertyPermission("java.vm.name", "read")
SocketPermission([CodeSource Host], "connect,accept") Application can make TCP/IP
connections to the host its code
was downloaded from.
FilePermission(CodeSource, "read") Application can read contents out
of its own code source jar.
All other Java API calls that require additional permissions such as accessing the local
hard drive, printing, connecting to your local network servers, connecting to random
Internet servers, or even exiting the VM will not be allowed and will cause a
SecurityException to be thrown. Well behaved applications should detect these
exceptions and enable their applications to run in a crippled mode or Display a warning
to the user and exit.
One of the Benefits of the Xito Bootstrap is its user friendly implementation of this
security environment making it possible for many applications to run in restricted mode
without a being a burden to the user. In fact application designers should consider
designing their applications to work in a restricted environment allowing end
users the assurance that the application won't do anything it is not suppose to.
Note: The separate Launcher Service provides the JNLP implementation of JNLP
29
Services that enable restricted applications to access the File System, Printer Services
etc in a controlled fashion. Your application can use these services to can access to
local resources without requesting your application have All Permissions.
30
Sharing Virtual Machine Issues
Xito BootStrap is designed to launch multiple applications in the same VM. Although in
practice the implementation works for the most part there are various issues that
developers should be made aware of while running in a Shared VM.
System.exit
Traditionally Java developers assume their applications are the only applications
running in a VM. Therefore their application will often create many Frames or Windows,
spawn several Threads and then when the user wants to exit the application the
developer simple calls System.exit(0).
On the surface this seems reasonable but in a shared VM world this behavior is not
desired.
In order to allow multiple applications to run in a single VM BootStrap SecurityManager
enforces that only a Single Class has the permission to exit the VM. By default this
class in the Boot class.
Because of this security implementation when any other application running in the
shared VM calls System.exit() a security exception will be thrown.
In general this approach is reasonable except when an application is running that does
not know that it is running in the BootStrap environment ie (most current applications).
For these applications the user will choose Exit from the UI and then the app will call
System.exit() a security exception will be thrown and the application would still be
running. Very frustrating to the end user. Because of this when such an application
attempts to call System.exit the SecurityManager will attempt to shutdown their
application through other means. It does this by keeping track of all Windows and
Frames the App has created and then calls dispose on each one. It also attempts to
keep track of all Threads started by the application and call stop on each one.
This approach is problematic especially the Thread.stop issue because this method has
been deprecated for being DeadLock prone.
Although this mechanism works for the most part it is much better if applications avoid
calling System.exit(). Rather then call System.exit applications should simply dispose of
their own windows and notify any running threads to die on their own. This way their
application will stop running without calling System.exit().
This is the best approach to take until Sun increases the ability of Java Applications to
run in a single VM or multiple VMs with low overhead.
As part of the Xito Bootstrap a special class called AppShutdownHelper has been
created to facilitate shutting down your application in Xito. This can be used with
reflection so that your application will perform the same while running in non Xito
platforms but will shutdown your application in Xito without calling System.exit.
31
In place of System.exit use the following code sample:
try {
Class.forName("org.xito.boot.AppShutdownHelper").newInstance();
}
catch(Exception exp) {
System.exit(0);
}
32