vaadin / vaadin-flow-karaf-example

An example project for an OSGi Vaadin app deployed on Karaf
The Unlicense
7 stars 5 forks source link
example karaf osgi vaadin

Example project for Vaadin Flow and Apache Karaf

This project demonstrates how you can build modular web applications using Vaadin Flow and Apache Karaf. The project can also be used as a starting point to create your own Vaadin Flow application bundle for Karaf.

For more Vaadin usage samples, you can go to vaadin.com/start.

To access the project directly from github, clone or download the repository and import the project to the IDE of your choice as a Maven project. You need to have 11 installed.

The project consist of four sub-projects:

The main-ui project contains the code for Web Application Bundle (WAB) which can be deployed to any OSGi container. This is also the Karaf feature that gets packaged during the build. The most relevant parts are two views that it contains:

The module also provides a simple menu and MainLayout for other bundles that can contribute views to the UI, and Vaadin boiler plate to configure app for PWA features, server push, missing views etc.

The greetservice-api project provides an API for a dummy service used by the main-ui project.

The greetservice-impl project provides an implementation for GreetService, that is defined and used by the MainView in the main-ui project. The main-ui does not depend on this bundle and it is not required to run the project. But deploying it separately affects how the application behaves.

The help-view is another optional bundle which contains an optional view (and a route target). It can be deployed or un-deployed at any time. The help view will be available in the main-ui project and its menu only if the help-view bundle is deployed.

Build and run a Vaadin web application OSGi bundle

The simplest way to start the project is run command mvn install to install project artifact and mvn -pl main-ui install -Prun to run Karaf OSGi container. After a while, the Vaadin UI will be available in http://localhost:8181. Note that this only deploys the main-ui bundle, and not the optional help-view or greetservice-impl bundles.

For more dynamic tutorial we suggest to follow these steps:

See readme files starter/README.md and help-view/README.md in the projects for further details.

Deploying Vaadin specific bundles to an OSGi container

Vaadin application generally contains dependencies to other bundles: e.g. Vaadin components like Button, TextField , etc. Every Vaadin component is based on a Web Component which is represented by frontend resources. All frontend resources are built into a bundle along with Vaadin WAB. As a result:

Limitations

Here is a list of things which are not currently supported:

:warning: At the moment, it is not possible to modify frontend resources on the fly (webpack dev server is not available at runtime). This means that for every frontend change, you have to rebuild the frontend bundle. (Issue for devmode)