Ripla

Rich Platform project for Java web applications.

This project is maintained by aktion-hip

Create an Application Bundle

The application class

The application’s main bundle is a bundle containing a class deriving from and extending org.ripla.web.RiplaApplication. Because RiplaApplication extends com.vaadin.ui.UI, your application becomes a Vaadin UI too.

In a minimal application, everything is done by default. Most probably, however, you want to override at least RiplaApplication.getAppConfiguration(). This method returns a org.ripla.interfaces.IAppConfiguration object. With such an object, you can configure your Ripla application (e.g. the ID of the default skin, the welcome message etc.). See DemoApplication.java for an example.

OSGi HttpService configuration

Ripla uses Vaadin 7 to render the web page, i.e. the user interface in the browser. Vaadin uses conventional servlet technology. To run Vaadin in a OSGi environment, Ripla uses Lunifera.org as bridge. Lunifera.org is leveraging the OSGi Declarative Services model for registering servlets at an application container. Therefore, you have to write an OSGi component description. In this file, you have to specify your application component as factory component with org.lunifera.web.vaadin.UI/my.UI as factory name and with your application class as implementation class. 

The following example OSGI-INF/myapp.xml specifies an application running e.g. as http://localhost:8080/myapp:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" 
     factory="org.lunifera.web.vaadin.UI/org.example.MyApplication" immediate="false" name="org.example.ui">
   <implementation class="org.example.MyApplication"/>
</scr:component>

In addition, you have to write a configuration (with the name lunifera.vaadin.application.factory_myapp.cfg) e.g. in the config directory:

# configuration to start a vaadin service
lunifera.web.vaadin.name=MyApp
lunifera.web.vaadin.uialias=myapp
lunifera.web.vaadin.widgetset=com.vaadin.DefaultWidgetSet

For that the context knows about the lunifera configuration, you have to add a reference to your MANIFEST.MF:

Lunifera-Config: config

Component description

The Ripla platform defines various extension points where you can dynamically plug in functionality. These extension points again use the OSGi Declarative Services approach. RiplaApplication is designed as consumer for all these services. Therefore, RiplaApplication contains the bind methods needed for that the service runtime can inject the service instances as soon as a bundle is registered providing an implementaion of such a service.

By extending RiplaApplication, you don't have to bother about service injection. The only thing you have to do is to write an OSGi component description declaring your application class as implementation class for the services you want to consume. Else, the OSGi container won't inject the services into your application.

See OSGI-INF/demo.xml for an example:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" 
      factory="org.lunifera.web.vaadin.UI/org.ripla.web.demo.DemoApplication" immediate="false" name="org.ripla.web.demo.ui">
   <implementation class="org.ripla.web.demo.DemoApplication"/>
   <reference cardinality="1..n" interface="org.osgi.service.prefs.PreferencesService" 
      bind="setPreferences" unbind="unsetPreferences" name="preferences" policy="dynamic"/>
   <reference cardinality="0..n" interface="org.osgi.service.useradmin.UserAdmin" 
      bind="setUserAdmin" unbind="unsetUserAdmin" name="useradmin" policy="dynamic"/>
   <reference bind="registerMenuContribution" unbind="unregisterMenuContribution" cardinality="0..n" 
      interface="org.ripla.services.IExtendibleMenuContribution" name="extendibleContributions" policy="dynamic"/>   
   <reference bind="registerPermission" unbind="unregisterPermission" cardinality="0..n" 
      interface="org.ripla.services.IPermissionEntry" name="permissions" policy="dynamic"/>
   <reference bind="setConfiAdmin" unbind="unsetConfiAdmin" cardinality="1..1" 
      interface="org.osgi.service.cm.ConfigurationAdmin" name="configAdmin" policy="static"/>
</scr:component>

In this example, org.ripla.web.demo.DemoApplication is prepared to consume multiple implementations of the org.ripla.web.services.IUseCase service (to note only one). As soon as such an implementation is registered at the OSGi container, it will be injected using the method RiplaApplication.addUseCase().

Note: don't forget to add a Service-Component element to your bundle's MANIFEST.MF. E.g. for the demo example above:

Service-Component: OSGI-INF/demo.xml

Having implemented your application class and written the component description, you're ready to implement the use cases providing your application's business logic.