DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Dynamic modular Web Applications with Vaadin and OSGi

Dynamic modular Web Applications with Vaadin and OSGi

Kai Tödter user avatar by
Kai Tödter
·
Jan. 03, 11 · Java Zone · Interview
Like (0)
Save
Tweet
16.10K Views

Join the DZone community and get the full member experience.

Join For Free

I am a big fan of both OSGi and GWT (Google Web Toolkit). Unfortunately these two technologies don’t fit together very well. When you want to run OSGi on the server, RAP (Rich Ajax Platform) is one proven approach to go. While I like RAP a lot, you have to have quite a lot of Eclipse RCP know how for using it. Another alternative, if your want to run OSGi on the server and provide a modular, dynamic UI is Vaadin. Btw, Vaadin is the Finnish word for female reindeer. Vaadin is a server side RIA framework that uses GWT as rendering engine. In the last couple of days a played a bit around with Vaadin and I have to admit, I like it a lot. So, I wrote a little dynamic OSGi Vaadin demo (Download link and instructions are below). My goals for the demo were:

  • Provide Bundles that contribute directly to the web application’s UI
  • Just starting and stopping bundles should contribute/remove UI elements and functionality
  • I wanted to implement something similar to my dynamic Swing OSGi demo

Before I started with Vaadin, I found a few interesting reads and code sample regarding OSGi and Vaadin:

  • Chris Brind: “In Bed with Vaadin and OSGi“. I use Chris’ bundles in my demo.
  • Neil Bartlett: Vaadin OSGi bridge at GitHub
  • Petter Holmström: Creating a Modular Vaadin Application with OSGi

But back to the demo, here is a screen shot running the application in Firefox:

The idea is to support two kinds of UI contributions: views and actions. The views are inserted in a tab folder, the actions appear in the toolbar and the Action menu. I implemented a little OSGi agent as a view (Bundle View). This view shows a selection of bundles currently available. By checking/unchecking a bundle, it will be activated/stopped on the server side. If you press “Deselect All”, all bundles go to resolved state and all the UI contributions disappear immediately:

Of course you could start and stop bundles from the OSGi console directly, then you would have to refresh the browser to get the changes displayed. To get the demo running on your local machine, follow these steps:

  • Make sure you have an Eclipse IDE installed
  • Download the demo sources and target platform osgi-vaadin-demo.zip (6.8 MB)
  • Import all projects from the zip file into Eclipse
  • Open the project “com.siemens.ct.osgi.vaadin.target”
  • Double-click vaadin.target (That opens the target platform definition in an editor)
  • Click on “Set as Target Platform” in the right top corner of the editor
  • Now everything should compile
  • Start the Run Configuration “OSGi Vaadin Demo”
  • Open the following URL in your favorite browser “http://localhost/com.siemens.ct.osgi.vaadin.pm.main“
  • If everything went well, you see the demo in your browser
  • if you don’t want to run Jetty on the default port 80, add a VM argument in the launch configuration, e.g.: -Dorg.osgi.service.http.port=8080
  • Play around with it, activate/stop bundles and watch the console log

In the next weeks I plan to go a little bit more into details of the demo, how OSGi declarative services are used, how to contribute to Vaadin Themes, etc.

From http://www.toedter.com/blog/?p=412

Vaadin application Web Service

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Applying Kappa Architecture to Make Data Available Where It Matters
  • Pattern Matching for Switch
  • Adding Authentication to a Web Application with Auth0, React, and JWT
  • How to Leverage Method Chaining To Add Smart Message Routing in Java

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo