home
products
education
support
partners
company

introduction

get started

articles

manual

tutorials

reference docs

case studies

knowledge base

goodies

screenshots

demos

echoes

Carousel zone




home

forums

downloads

bugs

mailing list
XUI Zone - manual

number of ratings 0
average rating 0.00

7 Running Applications

Within Carousel starting an application is handled by NetBeans. Outside of NetBeans several methods can be used to start-up Carousel applications depending upon how the applications will be deployed. All of these start-up sequences start by invoking the XApplet class and eventually follow a generic initialization process. Some minor variations are accommodated by the XApplet class to handle the different ways of setting start-up parameters and the differences in the classloaders.

When starting a Carousel application the choice of the XApplet class is important as this dictates whether or not the Carousel framework constructs Swing or AWT components. If the net.xoetrope.awt.XApplet class is used then AWT components are used, whereas if the net.xoetrope.swing.XApplet version is used Swing components are constructed.

In the examples above it will be assumed that AWT is being used, but the examples will work just as well with Swing if the Swing version of XApplet is substituted.

For the purposes of simplicity it will be assumed in the following discussions and examples that Java is installed as default and that Java can be started without additional modification of the environment or path.

Command-line startup sequence for applications

To start an application from the command line it is only necessary to invoke the XApplet class.

Code Sample 7-1 - Command Line startup command

java net.xoetrope.awt.XApplet startup.properties

where startup.properties is the name of the initialization file (which if omitted will default to startup.properties ). The application can take one additional parameter, the default package name.

The default package name for an application is normally set by whichever version of the XApplet is used to start the application ('net.xoetrope.awt' for the net.xoetrope.awt.AXpplet class and 'net.xoetrope.swing' for the net.xoetrope.swing.XApplet class). It is very rare that this parameter would need to be set as the application will automatically set the appropriate default value.

Note that the startup file is generated by Carousel each time the project is built, however Carousel actually stores the values is the project.xui file for its own use.

Java Web Start Start-up Sequence

To run a Carousel application as a Java Web Start application several preparatory steps are required. Firstly, the application must be packaged as an appropriate set of Jar files.

Next the application Jar files and resources must be signed and placed on a server configured to serve JNLP files. In particular, pay attention to how the mime-type is set for your particular server. In some cases the mime-type can be set by using dynamic content on the server such as JSPs or ASPs instead of vanilla HTML.

Once the Jars files are on the server the JNLP file can be configured. Here's an example:

Code Sample 7-2 - Java Web Start (JNLP) startup code





Carousel 1.0
My Company












To actually launch the Web Start Application it is then just a question of invoking the JNLP file. Normally this is done by embedding the link in an HTML page.

Normally it is also the practice to check that JWS is installed and display an appropriate error message if it is not. Sun's JWS web pages give examples and documentation of how to do this.

HTML/Applet Start-up Sequence

The HTML initialization sequence is like the JNLP in some ways except of course that it is an applet that is being started and not an application. Security settings are also different for applets depending on the environment in which they run.

The HTML fragment required for an applet if as follows:

Code Sample 7-3 - Basic applet tag

build/distrib.jar" code=net.xoetrope.awt.XApplet>

Again the Jar file should be signed for distribution and placed on the webserver.

Generic Initialization

Once the XApplet class has been invoked the initialization of the application/applet is pretty much the same regardless of how it was started. The sequence (and purpose of each step) is as follows:

1. Register the component factories. The registration process involves reading the ' NumComponentFactories ' parameter from the start-up file and then reading, instantiating and registering the number of component factories listed in the start-up file. Implicitly either an AWT or Swing component factory is already registered

2. Setup the project class. The project class maintains references to all the other resources, managers and factories used by the application. The project manager class can be accessed through a static accessor method and with this mechanism any resource can be easily obtained from the project without the need to carry references to the various objects.

3. Setup the page manager. The page manager controls the application display areas and acts as a broker for displaying frames and pages. The page manager also provides some navigation and page history support. At this point the content is also setup by specifying a frameset (if any) with the ' Frames ' parameter and the content with the ' StartClass ' parameter.

4. Setup the resource access. The resource access provides a simple method of loading resources and hides details of the various classloaders, paths and so on. Resource access is managed by the XProject instance which does some caching of resources such as images that are frequently reused.

5. Setup the style manager. This class loads style information from a file indicated by the 'styleFile' parameter in the start-up file. Styles can be used to configure fonts and colors in a consistent manner.

6. Size the main window. The startup parameters ' ClientWidth ' and ' ClientHeight ' are used to set the size of the main application window. The main window (in the case of an application) can also be centred by setting the start-up property ' CenterWin ' to true.

7. Set the layout. Assuming that some content was configured the application/applet is now laid out. This process will position the various elements of a frameset and the content of the frames or the content of the main window if no frameset is being used.

8. Add a shutdown hook. A shutdown hook is largely used for debug purposes to allow output of logging information. Shutdown hooks were not available on earlier JDKs so this feature may not be in use on all environments (particularly embedded platforms)

9. Display the main window. The application is now ready to display and the main window is shown. If you need to display a splash screen one good place to initiate its display (without subclassing XApplet ) is when the first page is created, by embedding code in that page's pageCreated or pageActivated method.

Startup file stubs

Carousel creates a number stubs of the startup file whenever a project is generated. These files are found in the root directory of the project and are regenerated each time the project is generated.

comments


If you were logged in you could rate this article or add a comment.