Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "RAP/Running RAP on virgo"

< RAP
(Updated Runing RAP on Virgo for use with RAP 1.5 and Virgo 3.0.3.RELEASE)
Line 6: Line 6:
 
Now you have a third option because RAP runs on [http://eclipse.org/virgo/ Virgo]! Virgo is a full-featured OSGi based application server and is one of the shining new stars of the Eclipse ecosystem.  Previously, we weren't able to deploy RAP applications on this server because we were blocked by bugs relating to split packages.  However, over the last few weeks we worked together with the Virgo team to fix these issues and we are happy to report success.
 
Now you have a third option because RAP runs on [http://eclipse.org/virgo/ Virgo]! Virgo is a full-featured OSGi based application server and is one of the shining new stars of the Eclipse ecosystem.  Previously, we weren't able to deploy RAP applications on this server because we were blocked by bugs relating to split packages.  However, over the last few weeks we worked together with the Virgo team to fix these issues and we are happy to report success.
  
Here are the steps we used to deploy RAP on Virgo. We know the process can be improved, but just to give you an idea of how it works, try the following:
+
This guide shows how to develop RAP applications with Virgo. The first part guides you through the setup for a Virgo Server instance and how to extend it to become a RAP runtime. The second part is a short walkthrough of how to create a Hello World RAP application using the new RAP OSGi integration.
  
1. [http://www.eclipse.org/virgo/download Download the latest Virgo Kernel (2.1.0.RELEASE)][1] and unpack the downloaded archive to a directory (We'll use ${KERNEL_HOME} in this post).
+
<strong>Extend Virgo Kernel 3.0 to support the RAP Widget Toolkit 1.5</strong>
  
2. [http://eclipse.org/rap/downloads/ Download the latest RAP Runtime][2] and extract '''the RAP bundles only''' of the plugin folder into the Virgo repository:
+
Setup has become easier with the use of Jetty 8.1.3 and the RAP OSGi integration. If you're using Virgo 2.1.x and RAP 1.4 please follow the instructions [http://eclipsesource.com/blogs/2011/08/10/how-to-extend-the-virgo-jetty-server-to-support-the-rap-widget-toolkit/ How to extend the Virgo Jetty Server to support the RAP Widget Toolkit][1] and [http://eclipsesource.com/blogs/2010/10/28/running-rap-on-virgo/ Running RAP on Virgo][2].
<pre>unzip rap-runtime-1.4.0-R-20110614-2335.zip "eclipse/plugins/*rap*.jar" -x "eclipse/plugins/*source*" "eclipse/plugins/*junit*" -d /tmp
+
cp /tmp/eclipse/plugins/*.jar ${KERNEL_HOME}/repository/usr</pre>
+
  
2b. [http://eclipse.org/rap/downloads/1.3/ Download the RAP Runtime 1.3][2b] and extract the '''required Equinox bundles'''.
+
In the following installation we will provide a RAP runtime based on Virgo using an HttpService provided by Jetty. The runtime is built on top of a Virgo Kernel. Jetty, the HttpService and RAP are added as extensions described in [http://www.eclipse.org/virgo/documentation/virgo-documentation-3.0.0.x/docs/virgo-programmer-guide/html/ch04s03.html plan artifacts][3]. These plans are added to the list of initial artifacts. Let's get started:
<pre>unzip rap-runtime-1.3.2-R-20110216-1023.zip "eclipse/plugins/*.jar" -x "eclipse/plugins/*rap*" "eclipse/plugins/*source*" "eclipse/plugins/*junit*" -d /tmp
+
cp /tmp/eclipse/plugins/*.jar ${KERNEL_HOME}/repository/usr</pre>
+
  
3. '''(via OSGi console)''' Enable the OSGi console by configuring the User Region, Virgo's subsystem for managing user applications.
+
Download Virgo Kernel 3.0.3.RELEASE from [http://www.eclipse.org/virgo/download/ Virgo Releases][4] and install VK to a location of your choice. This location will be referenced as ${VIRGO_HOME} throughout the next steps.
Open $KERNEL_HOME/config/org.eclipse.virgo.kernel.userregion.properties and uncomment the osgi.console property:
+
  
<pre>...
+
The following bundles from the Jetty and Equinox project provide an OSGi HttpService:
# osgi console support
+
<pre lang="text">org.eclipse.jetty.continuation_8.1.3.v20120522.jar
osgi.console=2401
+
org.eclipse.jetty.http_8.1.3.v20120522.jar
</pre>
+
org.eclipse.jetty.io_8.1.3.v20120522.jar
4. '''(optional)''' Change the default port of the OSGi HttpService
+
org.eclipse.jetty.security_8.1.3.v20120522.jar
<pre>export JAVA_OPTS=-Dorg.osgi.service.http.port=10081</pre>
+
org.eclipse.jetty.server_8.1.3.v20120522.jar
5. Start the Virgo Kernel
+
org.eclipse.jetty.servlet_8.1.3.v20120522.jar
<pre>./startup.sh
+
org.eclipse.jetty.util_8.1.3.v20120522.jar</pre>
</pre>
+
  
<pre>...
+
<pre lang="text">javax.servlet_3.0.0.v201112011016.jar
[2010-10-28 11:43:23.767] Thread-2                      User region ready.
+
org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841.jar
</pre>
+
org.eclipse.equinox.http.servlet_1.1.300.v20120522-1841.jar</pre>
  
6. Virgo Plans[3] encapsulate the artifacts of an application as a single unit.  We've created a rap-demo.plan for you.  You can inspect and download from here:
+
Another two bundles for the RAP widget toolkit and it's OSGi integration.
[http://download.eclipsesource.com/~fwaibel/virgo/rap-demo.plan rap-demo.plan]
+
<pre lang="text">org.eclipse.rap.rwt_1.5.0.20120612-1458.jar
 +
org.eclipse.rap.rwt.osgi_1.5.0.20120612-1458.jar</pre>
  
7. Now add the downloaded rap-demo.plan to the pickup folder ${KERNEL_HOME}/pickup. You will see the following deployment:
+
The easiest way to get all those bundles is to download the [http://www.eclipse.org/downloads/download.php?file=/rt/rap/1.5/rap-runtime-1.5.0-R-20120612-1458.zip RAP runtime]. Otherwise please visit the projects download pages listed below:
<pre>&lt;HD0001I&gt; Hot deployer processing 'MODIFIED' event for file 'virgo-rap-demo.plan'.
+
&lt;DE0000I&gt; Installing plan 'virgo-rap-demo' version '1.3.1'.
+
&lt;DE0000I&gt; Installing plan 'vigo-equinox-extensions' version '3.6.1'.
+
&lt;DE0000I&gt; Installing plan 'virgo-rap-extensions' version '1.3.1'.
+
&lt;DE0000I&gt; Installing bundle 'org.eclipse.rap.demo' version '1.3.1.20100915-2301'.
+
&lt;DE0000I&gt; Installing bundle 'org.eclipse.osgi.services' version '3.2.100.v20100503'.
+
&lt;DE0000I&gt; Installing bundle 'org.eclipse.equinox.preferences' version '3.3.0.v20100503'.
+
&lt;DE0000I&gt; Installing bundle 'org.eclipse.equinox.app' version '1.3.1.R36x_v20100803'.
+
&lt;DE0000I&gt; Installing bundle 'org.eclipse.core.commands' version '3.6.0.I20100512-1500'.
+
...
+
&lt;DE0004I&gt; Starting bundle 'org.eclipse.rap.demo' version '1.3.1.20100915-2301'.
+
&lt;DE0005I&gt; Started bundle 'org.eclipse.rap.demo' version '1.3.1.20100915-2301'.
+
</pre>
+
  
8. '''(via OSGi console)''' You can now start the OSGi HttpService using the Equinox Console and start the HttpService manually
+
<ul>
<pre>user@hostname:~> telnet localhost 2401
+
<li>[http://www.eclipse.org/jetty/downloads.php Jetty Distributions from Eclipse Jetty Distributions from Eclipse][5]</li>
Trying ::1...
+
<li>[http://download.eclipse.org/equinox/drops/R-3.8-201206081400/index.php Equinox Integration Build: 3.8][6]</li>
Connected to localhost.
+
<li>[http://eclipse.org/rap/downloads/ RAP downloads][7]</li>
Escape character is '^]'.
+
</ul>
  
osgi> ss
+
Copy all the listed bundles into ${VIRGO_HOME}/repository/ext to make them available for use in plan artifacts. To extend the core functionality of Virgo add the plan artifacts [http://download.eclipsesource.com/~fwaibel/virgo/jetty-8.1.3.plan jetty-8.1.3.plan][8] and [http://download.eclipsesource.com/~fwaibel/virgo/rap-1.5.0.plan rap-1.5.0.plan][9] next to the downloaded bundles into ${VIRGO_HOME}/repository/ext.
...
+
33 &lt;&lt;LAZY&gt;&gt;    org.eclipse.equinox.http.jetty_2.0.0.v20100503
+
...
+
  
osgi> start 33
+
Add the two plan artifacts describing your extensions to the list of initial artifacts to your ${VIRGO_HOME}/config/org.eclipse.virgo.kernel.userregion.properties.
 +
<pre lang="text"># the next line must not be broken with back-slashes
 +
initialArtifacts = repository:plan/org.eclipse.virgo.kernel.userregion.springdm,repository:plan/org.eclipse.jetty,repository:plan/org.eclipse.rap.rwt</pre>
 +
<strong>NOTE:</strong>
 +
On Unix systems access to the HttpService default port is restricted (<1024). The HttpService port can be easily configured by adding a line similar to
 +
<pre lang="text">org.osgi.service.http.port=18080</pre>
 +
to the {VIRGO_HOME}/lib/org.eclipse.virgo.kernel.launch.properties. This is described in detail in the blog post: [http://codewax.org/osgi/extending-virgo-with-a-httpservice/ Extending Virgo with a HttpService.][10]
 +
 
 +
Fire up the Virgo instance by running ${KERNEL_HOME}/bin/startup.sh with the two new extensions and look for the script that shows that the plans defining the two extensions have been started:
 +
<pre lang="text">[2012-06-19 17:44:36.248] start-signalling-1            Started bundle 'org.eclipse.equinox.http.jetty' version '3.0.0.v20120522-1841'.
 +
[2012-06-19 17:44:36.249] start-signalling-1            Started plan 'org.eclipse.jetty' version '8.1.3'.
 +
[2012-06-19 17:44:36.361] system-artifacts              Installing plan 'org.eclipse.rap.rwt' version '1.5.0'.
 +
[2012-06-19 17:44:38.255] system-artifacts              Installing bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.324] system-artifacts              Installing bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.391] system-artifacts              Installed bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.394] system-artifacts              Installed bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.396] system-artifacts              Installed plan 'org.eclipse.rap.rwt' version '1.5.0'.
 +
[2012-06-19 17:44:38.451] system-artifacts              Starting plan 'org.eclipse.rap.rwt' version '1.5.0'.
 +
[2012-06-19 17:44:38.455] system-artifacts              Starting bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.461] start-signalling-1            Started bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.465] system-artifacts              Starting bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.629] start-signalling-1            Started bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'.
 +
[2012-06-19 17:44:38.631] start-signalling-1            Started plan 'org.eclipse.rap.rwt' version '1.5.0'.
 +
[2012-06-19 17:44:38.634] sync Event Dispatcher Thread  User region ready.</pre>
 +
<strong>Hello Virgo World</strong>
 +
 
 +
Now that the Virgo/RAP runtime is prepared it's a good time to setup your Eclipse / [http://wiki.eclipse.org/Virgo/Tooling Virgo tooling][11]. Then, you can follow the step by step guide to get the demo up and running on your own computer. This demo has been written using Spring Tool Suite 3.0.0.M2 with Eclipse Virgo Tools installed.
 +
 
 +
Use the Virgo Tools to create a Server definition pointing to the Virgo Kernel prepared in the section above.
 +
 
 +
Create a new OSGi bundle project with the New Bundle Project wizard to create a sample bundle project.
 +
 
 +
Find your Server in the Server view and open the context menu to "Add and Remove…" the created bundle project or simply drag'n'drop the project onto your freshly created server definition.
 +
 
 +
A final small step and we can start programming the actual RAP demo application. Make RWT known to your bundle by adding it as a dependency. The infrastructure bundle org.eclipse.rap.rwt.osgi is not a necessary dependency. It just works in the background and will connect our application to the HttpService once we have added our ApplicationConfiguration.
 +
 
 +
Now it's time for some Java hacking. Create a demo application,
 +
<pre lang="java">public class DemoApplication implements IEntryPoint {
 +
 
 +
@Override
 +
public int createUI() {
 +
Display display = new Display();
 +
Shell mainShell = new Shell(display, SWT.TITLE);
 +
mainShell.setText("RAP Virgo Demo");
 +
mainShell.setMaximized(true);
 +
mainShell.setLayout(new GridLayout());
 +
 
 +
Button button = new Button(mainShell, SWT.PUSH);
 +
button.setText("Hello Virgo world!");
 +
 
 +
mainShell.layout();
 +
mainShell.open();
 +
return 0;
 +
}
 +
}
 
</pre>
 
</pre>
9. And, finally point your browser to http://localhost:10081/rap?startup=controls ... you should find a tab '''ToolTip''' which is new in RAP 1.4.
+
and a basic configuration:
 +
<pre lang="java">public class DemoApplicationConfiguration implements ApplicationConfiguration {
  
10. That's it - RAP is now running on Virgo. We want to improve this process over time and, hope that you will share some ideas with us on how to do this.  You can respond to this blog or ping us on the RAP newsgroup.
+
@Override
 +
public void configure(Application application) {
 +
Map properties = new HashMap();
 +
properties.put(WebClient.PAGE_TITLE, "RAP Virgo Demo");
 +
application.addEntryPoint("/virgo_demo", DemoApplication.class, properties );
 +
}
  
PS -One alternative solution to starting the HttpService via the OSGi console is adding an <em>autostart</em> bundle to the plan:
+
}</pre>
 +
The demo application as well as the configuration should be self explanatory. We expect to see a button "Hello Virgo world!" registered at the web context path "/virgo_demo" in a browser with the title "RAP Virgo Demo." To make this happen we simply need to register our DemoApplicationConfiguration as an OSGi service.
  
1. '''(via autostart)''' Download the [http://download.eclipsesource.com/~fwaibel/virgo/org.equinoxosgi.core.autostart_1.0.0.jar org.equinoxosgi.core.autostart] bundle as used at http://equinoxosgi.org/ - starts all lazy bundles in the OSGi container.
+
There are many ways to do this. In this demo we create a Spring application context to register the configuration for us.
  
2. '''(via autostart)''' Add the autostart bundle to the downloaded plan before dropping into the pickup folder.
+
Create a new "Spring Bean Configuration File" with:
<pre> &lt;artifact type="bundle" name="org.equinoxosgi.core.autostart" version="[1.0.0, 2.0.0)" /&gt;
+
<ul>
 +
<li>A configuration bean</li>
 +
<li>and an OSGi service referencing the configuration bean.</li>
 +
</ul>
 +
 
 +
<pre lang="xml"><?xml version="1.0" encoding="UTF-8"?>
 +
<beans xmlns="http://www.springframework.org/schema/beans"
 +
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
  xmlns:osgi="http://www.springframework.org/schema/osgi"
 +
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 +
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 +
 +
    <bean id="simpleConfiguration" class="com.eclipsesource.rap.virgo.demo.DemoApplicationConfiguration" />
 +
 
 +
    <osgi:service ref="simpleConfiguration" interface="org.eclipse.rwt.application.ApplicationConfiguration" />
 +
</beans>
 
</pre>
 
</pre>
  
[1] Virgo Downloads - http://www.eclipse.org/virgo/download/
+
If your server is already running, saving this file will automatically trigger a redeployment of the demo bundle. The  org.eclipse.rap.rwt.osgi bundle will do the necessary steps and register the demo application at the HttpService that is already running. You should be able to observe a successful deployment in the Console view.
 +
 
 +
Check the result at [http://localhost:18080/virgo_demo localhost:18080/virgo_demo] ... Congratulations! You successfully deployed your first RAP application on Virgo!
 +
 
 +
--
 +
 
 +
[1] [http://eclipsesource.com/blogs/2011/08/10/how-to-extend-the-virgo-jetty-server-to-support-the-rap-widget-toolkit/ How to extend the Virgo Jetty Server to support the RAP Widget Toolkit]
 +
 
 +
[2] [http://eclipsesource.com/blogs/2010/10/28/running-rap-on-virgo/ Running RAP on Virgo]
 +
 
 +
[3] [http://www.eclipse.org/virgo/documentation/virgo-documentation-3.0.0.x/docs/virgo-programmer-guide/html/ch04s03.html Virgo Programmer Guide - Plans]
 +
 
 +
[4] [http://www.eclipse.org/virgo/download/ Virgo Releases]
 +
 
 +
[5] [http://www.eclipse.org/jetty/downloads.php Jetty Distributions from Eclipse]
 +
 
 +
[6] [http://download.eclipse.org/equinox/drops/R-3.8-201206081400/index.php Equinox Integration Build: 3.8]
 +
 
 +
[7] [http://eclipse.org/rap/downloads/ Eclipse RAP downloads]
 +
 
 +
[8] [http://download.eclipsesource.com/~fwaibel/virgo/jetty-8.1.3.plan Jetty 8.1.3 plan artefact]
  
[2] RAP Runtime - http://eclipse.org/rap/downloads/
+
[9] [http://download.eclipsesource.com/~fwaibel/virgo/rap-1.5.0.plan RAP 1.5 plan artefact]
[2b] RAP Runtime 1.3 - http://eclipse.org/rap/downloads/1.3/
+
  
[3] Virgo Documentation - Programmer Guide 4.3 Creating Plans - http://www.eclipse.org/virgo/documentation/
+
[10] [http://codewax.org/osgi/extending-virgo-with-a-httpservice/ Extending Virgo with a HttpService]
  
[4] Virgo Documentation - User Guide 11.1. Configuring the Virgo Kernel and User Region - http://www.eclipse.org/virgo/documentation/
+
[11] [http://wiki.eclipse.org/Virgo/Tooling Virgo/Tooling]

Revision as of 08:53, 4 July 2012

You used to have just two options for deploying a RAP application:

  • Packing your application into a WAR archive and deploying it on a standard servlet container such as Tomcat, or
  • Embedding the Application and a servlet container in a standalone Equinox instance.

Now you have a third option because RAP runs on Virgo! Virgo is a full-featured OSGi based application server and is one of the shining new stars of the Eclipse ecosystem. Previously, we weren't able to deploy RAP applications on this server because we were blocked by bugs relating to split packages. However, over the last few weeks we worked together with the Virgo team to fix these issues and we are happy to report success.

This guide shows how to develop RAP applications with Virgo. The first part guides you through the setup for a Virgo Server instance and how to extend it to become a RAP runtime. The second part is a short walkthrough of how to create a Hello World RAP application using the new RAP OSGi integration.

Extend Virgo Kernel 3.0 to support the RAP Widget Toolkit 1.5

Setup has become easier with the use of Jetty 8.1.3 and the RAP OSGi integration. If you're using Virgo 2.1.x and RAP 1.4 please follow the instructions How to extend the Virgo Jetty Server to support the RAP Widget Toolkit[1] and Running RAP on Virgo[2].

In the following installation we will provide a RAP runtime based on Virgo using an HttpService provided by Jetty. The runtime is built on top of a Virgo Kernel. Jetty, the HttpService and RAP are added as extensions described in plan artifacts[3]. These plans are added to the list of initial artifacts. Let's get started:

Download Virgo Kernel 3.0.3.RELEASE from Virgo Releases[4] and install VK to a location of your choice. This location will be referenced as ${VIRGO_HOME} throughout the next steps.

The following bundles from the Jetty and Equinox project provide an OSGi HttpService:

org.eclipse.jetty.continuation_8.1.3.v20120522.jar
org.eclipse.jetty.http_8.1.3.v20120522.jar
org.eclipse.jetty.io_8.1.3.v20120522.jar
org.eclipse.jetty.security_8.1.3.v20120522.jar
org.eclipse.jetty.server_8.1.3.v20120522.jar
org.eclipse.jetty.servlet_8.1.3.v20120522.jar
org.eclipse.jetty.util_8.1.3.v20120522.jar
javax.servlet_3.0.0.v201112011016.jar
org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841.jar
org.eclipse.equinox.http.servlet_1.1.300.v20120522-1841.jar

Another two bundles for the RAP widget toolkit and it's OSGi integration.

org.eclipse.rap.rwt_1.5.0.20120612-1458.jar
org.eclipse.rap.rwt.osgi_1.5.0.20120612-1458.jar

The easiest way to get all those bundles is to download the RAP runtime. Otherwise please visit the projects download pages listed below:

Copy all the listed bundles into ${VIRGO_HOME}/repository/ext to make them available for use in plan artifacts. To extend the core functionality of Virgo add the plan artifacts jetty-8.1.3.plan[8] and rap-1.5.0.plan[9] next to the downloaded bundles into ${VIRGO_HOME}/repository/ext.

Add the two plan artifacts describing your extensions to the list of initial artifacts to your ${VIRGO_HOME}/config/org.eclipse.virgo.kernel.userregion.properties.

# the next line must not be broken with back-slashes
initialArtifacts = repository:plan/org.eclipse.virgo.kernel.userregion.springdm,repository:plan/org.eclipse.jetty,repository:plan/org.eclipse.rap.rwt

NOTE: On Unix systems access to the HttpService default port is restricted (<1024). The HttpService port can be easily configured by adding a line similar to

org.osgi.service.http.port=18080

to the {VIRGO_HOME}/lib/org.eclipse.virgo.kernel.launch.properties. This is described in detail in the blog post: Extending Virgo with a HttpService.[10]

Fire up the Virgo instance by running ${KERNEL_HOME}/bin/startup.sh with the two new extensions and look for the script that shows that the plans defining the two extensions have been started:

[2012-06-19 17:44:36.248] start-signalling-1            Started bundle 'org.eclipse.equinox.http.jetty' version '3.0.0.v20120522-1841'. 
[2012-06-19 17:44:36.249] start-signalling-1            Started plan 'org.eclipse.jetty' version '8.1.3'. 
[2012-06-19 17:44:36.361] system-artifacts              Installing plan 'org.eclipse.rap.rwt' version '1.5.0'. 
[2012-06-19 17:44:38.255] system-artifacts              Installing bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.324] system-artifacts              Installing bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.391] system-artifacts              Installed bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.394] system-artifacts              Installed bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.396] system-artifacts              Installed plan 'org.eclipse.rap.rwt' version '1.5.0'. 
[2012-06-19 17:44:38.451] system-artifacts              Starting plan 'org.eclipse.rap.rwt' version '1.5.0'. 
[2012-06-19 17:44:38.455] system-artifacts              Starting bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.461] start-signalling-1            Started bundle 'org.eclipse.rap.rwt' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.465] system-artifacts              Starting bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.629] start-signalling-1            Started bundle 'org.eclipse.rap.rwt.osgi' version '1.5.0.20120605-1606'. 
[2012-06-19 17:44:38.631] start-signalling-1            Started plan 'org.eclipse.rap.rwt' version '1.5.0'. 
[2012-06-19 17:44:38.634] sync Event Dispatcher Thread  User region ready.

Hello Virgo World

Now that the Virgo/RAP runtime is prepared it's a good time to setup your Eclipse / Virgo tooling[11]. Then, you can follow the step by step guide to get the demo up and running on your own computer. This demo has been written using Spring Tool Suite 3.0.0.M2 with Eclipse Virgo Tools installed.

Use the Virgo Tools to create a Server definition pointing to the Virgo Kernel prepared in the section above.

Create a new OSGi bundle project with the New Bundle Project wizard to create a sample bundle project.

Find your Server in the Server view and open the context menu to "Add and Remove…" the created bundle project or simply drag'n'drop the project onto your freshly created server definition.

A final small step and we can start programming the actual RAP demo application. Make RWT known to your bundle by adding it as a dependency. The infrastructure bundle org.eclipse.rap.rwt.osgi is not a necessary dependency. It just works in the background and will connect our application to the HttpService once we have added our ApplicationConfiguration.

Now it's time for some Java hacking. Create a demo application,

public class DemoApplication implements IEntryPoint {

	@Override
	public int createUI() {
		Display display = new Display();
		Shell mainShell = new Shell(display, SWT.TITLE);
		mainShell.setText("RAP Virgo Demo");
		mainShell.setMaximized(true);
		mainShell.setLayout(new GridLayout());

		Button button = new Button(mainShell, SWT.PUSH);
		button.setText("Hello Virgo world!");

		mainShell.layout();
		mainShell.open();
		return 0;
	}
}

and a basic configuration:

public class DemoApplicationConfiguration implements ApplicationConfiguration {

	@Override
	public void configure(Application application) {
		Map properties = new HashMap();
		properties.put(WebClient.PAGE_TITLE, "RAP Virgo Demo");
		application.addEntryPoint("/virgo_demo", DemoApplication.class, properties );
	}

}

The demo application as well as the configuration should be self explanatory. We expect to see a button "Hello Virgo world!" registered at the web context path "/virgo_demo" in a browser with the title "RAP Virgo Demo." To make this happen we simply need to register our DemoApplicationConfiguration as an OSGi service.

There are many ways to do this. In this demo we create a Spring application context to register the configuration for us.

Create a new "Spring Bean Configuration File" with:

  • A configuration bean
  • and an OSGi service referencing the configuration bean.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
    <bean id="simpleConfiguration" class="com.eclipsesource.rap.virgo.demo.DemoApplicationConfiguration" />

    <osgi:service ref="simpleConfiguration" interface="org.eclipse.rwt.application.ApplicationConfiguration" />
</beans>

If your server is already running, saving this file will automatically trigger a redeployment of the demo bundle. The org.eclipse.rap.rwt.osgi bundle will do the necessary steps and register the demo application at the HttpService that is already running. You should be able to observe a successful deployment in the Console view.

Check the result at localhost:18080/virgo_demo ... Congratulations! You successfully deployed your first RAP application on Virgo!

--

[1] How to extend the Virgo Jetty Server to support the RAP Widget Toolkit

[2] Running RAP on Virgo

[3] Virgo Programmer Guide - Plans

[4] Virgo Releases

[5] Jetty Distributions from Eclipse

[6] Equinox Integration Build: 3.8

[7] Eclipse RAP downloads

[8] Jetty 8.1.3 plan artefact

[9] RAP 1.5 plan artefact

[10] Extending Virgo with a HttpService

[11] Virgo/Tooling

Back to the top