Note: This is about how to configure your RAP application in a
RAP with OSGi
orRWT Standalone
setup. When using a setup with Workbench,
see Branding
.
A RAP application consists of various parts, such as entrypoints, URL mappings,
themes, service handlers, etc.
All these parts constitute an
ApplicationConfiguration
. The configuration is like the blueprint for an application. Based on an
ApplicationConfiguration, the
framework can create and start an application instance. There can be more than one
application instances at
runtime, e.g. running on different network ports or different servlet contexts.
An
ApplicationConfiguration
is used to configure an application before it is started. For this step, RAP follows a callback approach to
leave the responsibility for creating and starting the application with the framework. Therefore, the
configuration must actively configure the application. To do so, it has one method
configure( Application )
. The framework provides a reference to the created
Application
as a parameter to this method. Here’s how a simple implementation looks like:
public class SimpleConfiguration implements ApplicationConfiguration {
public void configure( Application application ) {
application.addEntryPoint( "/simple", SimpleEntryPoint.class, null );
application.addEntryPoint( "/other", AnotherEntryPoint.class, null );
}
}
When using OSGi, the
ApplicationConfiguration
can be registered as a service. We recommend using OSGi declarative services (DS) like this:
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.example.SimpleConfiguration"/>
<service>
<provide interface="org.eclipse.rwt.application.ApplicationConfiguration"/>
</service>
</scr:component>
The bundle
org.eclipse.rap.rwt.osgi
will automatically start this application on every available HttpService. When using Equinox, don’t forget to
also include the
org.eclipse.equinox.ds
bundle.
When using RWT as a library in a traditional web application, i.e. without OSGi, you can register your
ApplicationConfiguration
in the
web.xml
by adding a
context-param
with the fully qualified class name of the implementation:
<context-param>
<param-name>org.eclipse.rap.applicationConfiguration</param-name>
<param-value>com.example.ExampleConfiguration</param-value>
</context-param>
You can always look up the param-name in the constant
ApplicationConfiguration#CONFIGURATION_PARAM
.
When an ApplicationConfiguration has been registered as described above, the application is automatically
started by the framework. Alternatively, it can also be started explicitly using an
ApplicationRunner
:
ApplicationConfiguration configuration = new SimpleConfiguration();
ApplicationRunner runner = new ApplicationRunner( configuration, servletContext );
runner.start();