RAP

Introduction

As you may know RAP (Remote Application Platform) is a technology that allows you to run an Eclipse RCP application over the web.

In order to obtain this goal you have to setup a specific RAP Target Platform, for instance the one that RAP itself provides once you install it.

However when you want to use an Eclipse RCP framework over the RAP Platform, you generally have to deal with dependencies, since not all Eclipse frameworks are ready-to-use with RAP, especially those related with the SWT layer.

EMF Parsley provides a proper RAP Target Platform that allows you to start leveraging Parsley potentials to the web the same way you have learned to do with desktop (RCP) development.

Setup

Installing the RAP Tools

To begin with, you need to install the RAP Tools into the IDE. This can be accomplished with the following steps:

  1. Help -> Install New Software ...
  2. select the main Eclipse Update site
  3. expand category "Web, XML, Java EE and OSGi Enterprise Development"
  4. select "RAP Tools" and complete the installation, restarting the IDE at the end
  5. after IDE restarts just close the Welcome page

Setup the EMF Parsley RAP Target Platform

After having installed EMF Parsley as described here and created a new workspace, you can setup the EMF Parsley RAP Target Platform in the following way:

  1. File -> New... -> Example...
  2. from Category "Emf Parsley Examples", select "Emf Parsley Rap Target Platform Example"
  3. press Next and Finish
  4. open the Target Definition file emf-parsely-rap.target
  5. wait until the "Resolving Target Definition" job is done (check the status bar)
  6. when finished, click on hyperlink "Set as Target Platform"

You will end up with a RAP-enabled workspace, enhanced by EMF and Parsley!

Examples

Running the Parsley RAP UI Example

Here is the fastest way to get a working web application with all the stuff put togheter:

  1. File -> New... -> Example...
  2. from Category "Emf Parsley Examples", select "Emf Parsley Rap Example"
  3. press Next and Finish
  4. expand plug-in "org.eclipse.emf.parsley.examples.rap.ui"
  5. right-click "Emf_Parsley_RAP_UI_Example.launch" and click "Run as" "Emf_Parsley_RAP_UI_Example"

What you will get is a web application that allows you to interact with the model instance as you would do in a desktop (RCP) environment.

In this web application you can see two views:

Of course, since this is a web application, you can also open a browser on another pc or device on the same network and type the address, replacing 127.0.0.1 with the IP of the machine where the application was launched.

Running the Parsley RAP CDO Example

The EMF default XMI persistence is certainly very handy to start with, but as soon as you want a more production-ready EMF persistence architecture, well, CDO is for sure the way to go. In fact with CDO you basically have an EMF model instance shared between clients, that also allows the clients to be synchronized with the model changes.

In this example, in order to keep things simple, we will use CDO with an in-memory store (MEMStore) whose contents will be lost once the server is stopped. However CDO can be configured for usage with RDBMS, Object-oriented or NO-SQL databases (see here for details)

To start with we need a CDO Server running and we can obtain it with an example plugin that can be used both in an RCP and in a RAP workspace.

  1. File -> New... -> Example...
  2. from Category "Emf Parsley Examples", select "Emf Parsley Cdo Server Example"
  3. press Next and Finish
  4. expand plug-in "org.eclipse.emf.parsley.examples.cdo.server"
  5. right-click "CDOServerExample.launch" and click "Run as" "CDOServerExample"
  6. a message on the Console "Repository[demo] started!" informs that the CDO Server instance is started!

Now we can create the web application that will use the CDO server just started.

  1. File -> New... -> Example...
  2. from Category "Emf Parsley Examples", select "Emf Parsley Rap Cdo Example"
  3. press Next and Finish

The plug-in projects created are:

Then let's start the application

  1. expand plug-in "org.eclipse.emf.parsley.examples.cdo.rap"
  2. right-click "EMF-Parsley_Library_RAP.launch" and click "Run as" "EMF-Parsley_Library_RAP"

If you happen to see this

just press the refresh button and should see the following

Now feel free to open the same address from more browsers window (yes, on different machines or devices, possibly) and see the power of this technology stack at work!