Print
Demo applications

Introduction

This document aims to provide developers new to Loom with a few simple examples to help them getting started.

Instructions for installing Loom can be found in the Install document.

Loom comes with two small demo applications, HelloWorld and Distributed. The demos are packaged as SAR files. A SAR file is an archive for Loom applications which conveniently holds all the libraries and deployment information for the the given application. If you are familiar with J2EE EAR and WAR files you'll find them very similar.

Binaries

In binary releases the demos are included in the demo/ directory. To install them you just need to copy the .sar files to the apps/ directory and start loom.

Building from source

To build everything from source you need to follow these steps:

  • Check out Loom
  • Build Loom
  • Build the demos

The resulting artifacts are ready SAR files, one for each demo. They are copied to the distribution/deploy/demos directory.

All that is needed is for the SAR files to be dropped in the apps/ directory of a Loom distribution, plus a start/restart of Loom by executing the preferred script in the bin/ directory.

HelloWorld demo

Loom would not be a serious application if it did not have a HellWorld demo! It will allow you to verify that you've successfully built or installed Loom.

Fire up Loom by executing the run script in the bin/ directory. This will execute in the foreground so you can see the messages written to System.out.

Next point your favorite web browser to http://localhost:8999. If "localhost" isn't recognized by your system, replace it with "127.0.0.1".

If all goes well, you will see something like the following:

This shows that Loom has unpacked and launched the server application contained within the demo-helloworld.sar file. To stop Loom simply use CTRL-C on the console window. You can stop and start as many times as you need.

To study the HelloWorld demo in more detail go to its own guide.

Distributed demo

This demo application demonstrates that it is possible to make a server application that is dual mode. Dual mode here is the ability for the server application to run inside Loom and also stand-alone from the command line. The only difference is that the app needs to be zipped into two forms - the sar file for Loom and a jar file for standalone.

The build artifacts produced by this demo are

  1. demos/distributed/server/target/demo-distributed-server.sar - the server app in Loom form
  2. demos/distributed/server/target/demo-distributed-server-x.y.jar - the server app in standalone form
  3. demos/distributed/client/target/demo-distributed-client-x.y.jar - the client app

To run the Server app inside Loom drop the demo-distributed-server.sar in the Loom distribution apps directory (as done above), and restart Loom:

To run the Server app in standalone mode:

Finally use the client application to poke the server:

You should see the messages appear in the console windows in which the two servers are running.

Powered by Atlassian Confluence