Dynamic and modular Web Applications with Equinox and Vaadin

  • 13,767 views
Uploaded on

This presentation introduces a little demo application that uses OSGi (Equixox) on the server. The demo uses Vaadin as UI technology and shows how you can create dynamicly changing UIs within a …

This presentation introduces a little demo application that uses OSGi (Equixox) on the server. The demo uses Vaadin as UI technology and shows how you can create dynamicly changing UIs within a server-side OSGi Web application.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
13,767
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
141
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Dynamische Webapplikationen mit Equinox und Vaadin Kai Tödter Siemens Corporate Technology
  • 2. Who am I? Software Architect/Engineer at Siemens Corporate Technology Eclipse RCP expert and OSGi enthusiast Open Source advocate Committer at e4 and Platform UI E-mail: kai.toedter@siemens.com Twitter: twitter.com/kaitoedter Blog: toedter.com/blog5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 2
  • 3. Outline Demo Server-side OSGi Vaadin Whiteboard Pattern OSGi Declarative Services (DS) Code deep dive Discussion5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 3
  • 4. Demo5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 4
  • 5. Download & Blog You can download the demo projects (6,8 MB, including the target platform) at http://www.toedter.com/download/vaadin/os gi-vaadin-demo.zip See also my blog “Dynamic modular Web Applications with Vaadin and OSGi” http://www.toedter.com/blog/?p=4125/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 5
  • 6. Server-side OSGiPicture fromhttp://www.sxc.hu/photo/10439235/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 6
  • 7. Server-side OSGi For this demo I use Equinox as OSGi container To run server-side Equinox there’s 2 choices:  Embed Equinox in a servlet container  Embed a HTTP server in Equinox5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 7
  • 8. Embed Equinox in a Servlet Container Needed bundles:  org.eclipse.equinox.servletbridge  org.eclipse.equinox.servletbridge.http  org.eclipse.equinox.http.servlet  [optional] org.eclipse.equinox.http.registry See http://www.eclipse.org/equinox/server/ http_in_container.php5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 8
  • 9. Embed Jetty in Equinox Needed bundles:  org.eclipse.equinox.http.jetty  org.eclipse.equinox.http.servlet  org.mortbay.jetty  org.apache.commons.logging  javax.servlet  [optional] org.eclipse.equinox.http.registry See http://www.eclipse.org/equinox/server/ http_in_equinox.php5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 9
  • 10. Hello, JAX! OSGi Servlet DemoPicture by Office Online, iStockPhotohttp://office.microsoft.com/en-us/images/results.aspx?qu=world#ai:MP900444203|5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 10
  • 11. 5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 11
  • 12. What is Vaadin? Server-based RIA Framework Uses Google Web Toolkit (GWT) as rendering engine Pure Java, no JavaScript, no configuration Rich widget set Out of the box OSGi support  Only one JAR file, already an OSGi bundle5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 12
  • 13. Demo5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 13
  • 14. The Whiteboard Pattern Problem: Often a service provides an implementation of the publisher/subscriber design pattern and provides methods to register listeners for notifications The OSGi service model provides a service registry with these notification mechanisms already! So:  Don’t get a service and register as listener  Be a service yourself and register with the OSGi service registry! 14
  • 15. Example: The Listener Pattern Clients use ApplicationService to register view and action contributions Client is responsible for handling dynamic behavior 15
  • 16. Example: The Whiteboard Pattern Clients register view and action contributions as services Application manager is responsible for handling dynamic behavior 16
  • 17. Whiteboard Pattern in Vaadin Demo The Action and View contribution managers are NOT services  Instead, they are wrapped in a OSGi Declarative Services (DS) component All action and view contributions are OSGi services and implement  IActionContribution  IViewContribution17
  • 18. OSGi Declarative Services Active Bundle Active Bundle Component Component Service Component Component Instance reference Instance provide Component Component Description Description5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 18
  • 19. Life Cycle DS-powered Bundle Service Component Runtime (SCR) Component Component Component create5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 19
  • 20. Declaring a Component Specify component description(s) via Service-Component manifest header Service-Component: OSGI-INF/treeView.xml Specify the implementation class <component xmlns="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="...TreeView"/> </component>5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 20
  • 21. Providing a Service Specify each service interface By default components providing a service are created on demand (lazy) <service> <provide interface="...IViewContribution"/> <provide interface="...IActionContribution"/> </service>5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 21
  • 22. Referencing Services Specify the service interface Specify bind and unbind methods Specify the cardinality <reference interface="...IPersonManager" bind="setPersonManager" unbind="removePersonManager" cardinality="1..1"/>5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 22
  • 23. Further Reading Chris Brind:  In Bed with Vaadin and OSGi  http://www.perplentropy.com/2010/02/in-bed-with- vaadin-and-osgi.html  I use Chris’ bundles in this demo Neil Bartlett:  Vaadin OSGi bridge at GitHub  https://github.com/njbartlett/VaadinOSGi Petter Holmström:  Creating a Modular Vaadin Application with OSGi  http://vaadin.com/wiki/- /wiki/Main/Creating%20a%20Modular%20Vaadin%20 Application%20with%20OSGi5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 23
  • 24. Putting it all together… Main demo application is a DS component  factory=vaadin.app => used Chris Brind’s implementation  0..n service references to  IViewContribution  IActionContribution Source code will be shown soon… 5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 24
  • 25. Resources, Images and Themes Resources (e.g. images) have to be put in a fragment with the com.vaadin bundle as host See project com.siemens.ct.osgi.vaadin.pm.theme5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 25
  • 26. Code Deep DivePicture fromhttp://www.sxc.hu/photo/11596135/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 26
  • 27. Picture fromhttp://www.sxc.hu/photo/9220045/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 27
  • 28. License This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License  See http://creativecommons.org/licenses/by-nc- nd/3.0/de/deed.en_US5/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 28
  • 29. Picture IndexMany thanks to the authors of the following pictures: Slide „Server-side OSGi“: http://www.sxc.hu/photo/1043923 Slide „Hello JAX!“: http://office.microsoft.com/en- us/images/results.aspx?qu=world#ai:MP900444203| Slide „Reindeer“ Animation: http://www.sxc.hu/photo/1138596 Slide „Code Browsing“: http://www.sxc.hu/photo/1159613 Slide “Discussion”: http://www.sxc.hu/photo/9220045/4/2011 © Kai Tödter and others, Licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 29