Hi Miles,
you are right. The Wiki page should be updated. With RAP 1.5 there is an OSGi integration available which I successfully use with Virgo Kernel 3.0.3.RELEASE.
Extend your Virgo installation with Jetty 8.1.3 HttpService:
<plan name="org.eclipse.jetty" version="8.1.3" scoped="false" atomic="true" ...>
<artifact type="bundle" name="javax.servlet" version="[3, 4)" />
<artifact type="bundle" name="org.eclipse.jetty.util" version="[8.1.3, 9)" />
<artifact type="bundle" name="org.eclipse.jetty.io" version="[8.1.3, 9)" />
<artifact type="bundle" name="org.eclipse.jetty.http" version="[8.1.3, 9)" />
<artifact type="bundle" name="org.eclipse.jetty.servlet" version="[8.1.3, 9)" />
<artifact type="bundle" name="org.eclipse.equinox.http.servlet" version="[1.1.300, 2)" />
<artifact type="bundle" name="org.eclipse.equinox.http.jetty" version="[3.0.0, 4)" />
</plan>
Don't forget to specify the HTTP port in lib/org.eclipse.virgo.kernel.launch.properties:
org.osgi.service.http.port=18080
And add RAP plus the OSGi integration:
<plan name="org.eclipse.rap.rwt" version="1.5.0" scoped="false" atomic="true" ...>
<artifact type="bundle" name="org.eclipse.rap.rwt" version="[1.5, 2)" />
<artifact type="bundle" name="org.eclipse.rap.rwt.osgi" version="[1.5, 2)" />
</plan>
Now you are able to write an EntryPoint, configure and register your RAP application as an OSGi service:
package org.example.rap.helloworld;
import org.eclipse.rwt.lifecycle.IEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class EntryPoint implements IEntryPoint {
public int createUI() {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new GridLayout( 1, false ) );
Button button = new Button( shell, SWT.PUSH );
button.setText( "Hello Virgo world!" );
shell.pack();
shell.open();
return 0;
}
}
package com.eclipsesource.demo.rap.virgodemo;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.rwt.application.Application;
import org.eclipse.rwt.application.ApplicationConfiguration;
import org.eclipse.rwt.client.WebClient;
import org.example.rap.helloworld.EntryPoint;
public class SimpleConfiguration implements ApplicationConfiguration {
public void configure(Application application) {
Map<String, String> properties = new HashMap<String, String>();
properties.put(WebClient.PAGE_TITLE, "simple RAP test");
application.addEntryPoint("/simple", EntryPoint.class, properties );
}
}
<?xml version="1.0" encoding="UTF-8"?>
...
<bean id="simpleConfiguration" class="com.eclipsesource.demo.rap.virgodemo.SimpleConfiguration" init-method="init" />
<osgi:service ref="simpleConfiguration" interface="org.eclipse.rwt.application.ApplicationConfiguration" />
</beans>
I'll try to migrate this setup to Virgo Kernel 3.5.0 and report back.
Hope this helps,
Florian