The OSGi Alliance is working towards the release of the R7 version of the OSGi specifications. enRoute will be updated to align with R7 so please expect significant changes to enRoute examples and website content. Current enRoute website content and repos will be deprecated, though they will remain available for the foreseeable future. Migration guidance will be provided for users with current enRoute based applications and systems. Please e-mail any questions to the developer mailing list (email@example.com) or in confidence to firstname.lastname@example.org.
This section is an entry to the hopefully growing collection of examples that OSGi enRoute provides. If you want to develop an additional example, please submit a PR.
The examples are all in a workspace that you can clone from Github. Some examples are combined together, others have their own workspace. It is highly suggested to clone the workspace and play with the example.
This example is quite large since it was used in the 2015 IoT Contest. The OSGi IoT Trains SDK is a way to write software for a Lego® train track used in the OSGi IoT Contest. The SDK is an OSGi enRoute workspace with a number of projects. The SDK is a self contained environment that contains everything to run an emulator with custom or example bundles.
Sometimes one could wonder what the initial designers of OSGi were smoking when designing the core APIs. Though the APIs were top from a point of view of specification, consistency, clarity, and power, they sucked quite badly because they required lots of boiler plate. Fortunately, Declarative Services changed all that. DS combines the awesome power of OSGi and type safe Java with the friendliness of a script language.
This project shows lots of examples of what you can do with OSGi Declarative Services.
This example has been donated by Amit Kumar Mondal. It shows how to use OSGi enRoute to turn on a LED over MQTT using the Eclipse server and a Raspberry Pi. It requires the IoT Tutorial as a base. Very interesting if you are into IoT. (Realize that looking at the predictions IoT is soon into you.)
This example is currently work in progress. It shows the progress on a project to make a full blown CRUD example with OSGi enRoute. Though OSGi enRoute contains a lot of excellent parts to do this, it shamefully lacks a database abstraction. (The reason is the highly sensitive nature of databases in Java.) Chuck Boecking, whois an expert in ERP is using an open source Mongo db bundle to build the example.
Chuck also delivered an excellent video about the subject. Highly recommended.
The OSGi Configuration Admin is a a significant part of the reason why OSGi is so powerful. Its primary trick is to reverse the normal flow where an app looks for configuration to a model where the app is called with the configuration. (Another don’t call us, we’ll call you!) However, this novel approach is often not well understood. Add to that the subtle difference between factories and singletons and you’ve got a lot of confused people. This example shows lots of examples on an OSGi enRoute GUI.
How often did you write a browser application and wished you could easily get the events from the server? Your sorrows are over! OSGi enRoute contains a helper bundle (osgi.enroute.easse.simple.adapter) that makes it trivial to receive the events from Event Admin the browser as Server Sent Events. The OGSi enRoute perspective has an example project to demonstrate how awesome this support is.
Though the beaming up of the methods is extremely pleasant, it does cause a bit of a problem in initialization before those methods have arrived. This example shows you in detail how to setup the Angular initialization code to make it work.
This project demonstrates the use of the OSGi enRoute REST API. This API allows you to write POJO code that is mapped to REST with JSON as payload. The project shows in the RestApplication class a number of examples that manipulate a history. All the examples are turned into a web page that allows you to execute them easily with a mouse click.
If you intend to use REST as the transport between your back-end and front-end then you might want to checkout JSON RPC.
The OSGi enRoute Scheduler API is quite awe inspiring. It heavily uses the Promises and lambdas to make async programming simple in OSGi. It supports all the important features like deadlines, delays, and Cron like scheduling. This example is a GUI that calls lots of examples in the back end. It is a really nice way to explore the Scheduler API.
A large part of a web site usually consists of static resources like images, scripts, html, etc. These resources must be mapped to a proper path on the local webserver. The webserver can provide this feature by mapping a folder in the bundle to a path (i.e. the URL) on the webserver.
The webserver therefore provides the possibility to wrap the web resources in bundles and use the OSGi dependency model to create a coherent set. This set can then be included as a single file in the web application’s HTML.This is called web resources.
This example helped a person that wanted to solve a problem in an elegant way but did not find appropriate pieces yet. He described the problem as follows:
I want to create some abstraction for a little data management system which should be connected to different data backends at the same time (e.g. S3, Dropbox, local/network filesystem, ...). Now let's consider a simple example of the logic involving the following standard CRUD operations (because I want to publish that in a single ReST endpoint):
The example shows a solution to the classic dispatch problem. In this case we need to dispatch the operations on a BLOB (Binary Large Object).
A quite simplistic example GUI application that reads the properties from framework and shows them on the UI. The properties are accessed using a REST API. Small and maybe not that useful but it is a skeleton of a REST application so that might be interesting.
A bnd workspace that shows the different possibilities of the Maven Bnd Repository plugin.
VAADIN is a very nice library for Java developers that want to stay in Java for their UI. This example provides a small glue library that makes it possible to use Vaadin with services instead of the creation of classes by name which is the default mode. Paul Fraser added the Vaadin address book example using DTOs and proper services.