Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OSGi As An Embedded Rich Internet Application Engine


Published on

Thanks to the WebKit project, Opera and other browser technology pioneers, embedded browser and JavaScript engines have caught up with their desktop counterparts and have become powerful application runtimes. Rich Internet Applications (RIA) on a mobile device, a feasible option? Despite the browsers having become a great choice for you embedded app's UI, they have two major deficits:

* First, they lack access to to device features (location, messaging, address book, etc.) which typically add most part of your apps value.
* Secondly, modeling complex business logic in JavaScript is not really what you want to do. Here is where OSGi comes into play!

This presentation will introduce the concept of using OSGi as a "Server in your pocket". OSGi acts a runtime for your business logic while exposing device capabilities as well as your custom services to your RIAs running in the browser. By means of service remoting, the talk describes how OSGi middleware automatically translates OSGi Services into JASON web services available on your local server. The presentation will explain how this concept it realized on a set of carrier grade mobile handsets, will touch on lessons learned and will be complemented by life demos on Windows Mobile and Android devices.

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

OSGi As An Embedded Rich Internet Application Engine

  1. 1. OSGi as an embedded Rich Internet Application Engine<br />
  2. 2. Introduction to<br />Rich Internet Applications<br />(RIA)<br />
  3. 3. Rich Internet Applications<br />What are Rich Internet Apps (RIAs)?<br /><ul><li>Common base technologies:HTML, JavaScript, CSS, AJAX, Flash …
  4. 4. Frameworks:Adobe Air & Flex, Google WT, Gears, Yahoo Widgets…</li></li></ul><li>Rich Internet Applications<br />Why do we care?<br />Job demand for „RIA“<br />Job demand for „Adobe Flex“<br />
  5. 5. Rich Internet Applications<br />RIAs on PCs: A Happy World…<br />Source:<br />… same thing for Mobile? …<br />
  6. 6. Rich Internet Applications<br /><ul><li>Immature Technologies and Deployments
  7. 7. No integration with phone functions (i.e. location)
  8. 8. Data bandwidth, Offline Mode
  9. 9. Security, etc.</li></ul>… NO!!!<br />Source:<br />
  10. 10. Introduction to<br />Rich Internet MobileNet Applications<br />(RMA)<br />
  11. 11. Rich MobileNet Applications<br />Rich Internet Application: ”Fully featured software package that runs in a browser.”- from Loosely Coupled (<br />Movements to achieve “fully featured”:<br />Google Gears<br />OMTP BONDI<br />W3C Geolocation API<br />Incomplete/Work in progress<br />Specification work in BONDI ongoing<br />Implementations are browser and platform specific<br />
  12. 12. Rich MobileNet Applications<br />Traditional Approach to mobile Portals:<br />Web<br />Server<br />Web<br />Server<br />Web<br />Server<br />Location<br />PIM<br />Bluetooth<br />…<br />Browser<br />This persentation <br />is NOT about this<br />
  13. 13. The new approach: RMA<br />Rich MobileNet Applications<br />XYZ<br />Server<br />Web<br />Service<br />App<br />Service<br />Web<br />Server<br />Web<br />Server<br />Location<br />PIM<br />Bluetooth<br />…<br />Browser<br />Mobile OSGi<br />My Local Portal<br />
  14. 14. Server in the pocket concept<br />The role of mobile phones changes<br />Content is created on the go<br />Photos taken by camera phones<br />Blog entries written on smart phones<br />Data collected via sensors<br />Location information<br />Services are provided at the edge of the network<br />For example phone as a content (media) server<br />Ad hoc connectivity<br />Local networks, peer to peer etc.<br />Different realizations of the concept – or parts:<br />Mobile web server: Nokia MyMobilesite.Net<br />Personal web server: Opera Unite (<br />
  15. 15. OSGi – The Server In Your Pocket<br />HTTP Service: your personal web server<br />UPnP: for ad hoc connectivity and automatic configuration<br />Portability: runs on many different platforms (S60, WM, BREW, Android etc.)<br />Platform integration: existing Java APIs to access device functionality<br />Local web applications (widgets)<br />Remote Service Access: automatic export of services<br />
  16. 16. OSGi enabling BONDI<br />BONDI is an emerging standard for browser JavaScript extensions (mostly for access to phone features)<br />OSGi is a component and service runtime<br />OSGi can inject BONDI into browsers<br />OSGi<br />Browser<br />Java<br />JSR<br />JSR<br />JSR<br />JSR<br />JSR<br />API<br />API<br />API<br />API<br />API<br />Phone OS<br />Phone OS<br />
  17. 17. Services in your pocket<br />Horizontal services<br />Device integration or operator services<br />Shared by applications<br />Can be deployed post shipment<br />Application specific services:<br />Complex business logic implemented in Java<br />Can use the full power of Java<br />JEE-like 3-tier architecture in the device<br />Can leverage existing 3rd-party components<br />
  18. 18. Technology<br />
  19. 19. Remote Service Access - Architecture<br />UI Runtime <br />(e.g. Browser)<br />OSGi<br />Remote<br />Events<br />Event<br />Admin<br />Application<br />(e.g widget)<br />RSR<br />Convenience<br />Library <br />(e.g. JavaScript)<br />Service Registry<br />3. find<br />2. export<br />RSA<br />4. bind<br />Service<br />Service<br />Object<br />5. use<br />1. register<br />
  20. 20. Widgets<br />Locally installed web applications<br />Support for W3C Widget specification<br />Widget use HTML and CSS as the markup<br />Metadata provided in config.xml<br />Packaged as a ZIP<br />Widgets are fully manageable via OSGi<br />Secure widget execution: security context spans from OSGi to the Browser<br />
  21. 21. Remote Service Access<br />Based on Distributed OSGi concept<br />Bindings specified for JSON RPC – lightweight and fits JavaScript naturally<br />Services can be marked for export<br />Access point and skeleton automatically created<br />IDL: Java – simple mapping to JavaScript (with some restrictions)<br />Remote Service Registry (RSR)<br />Available at a well-know URL<br />Accessible via a well-known (JSON) web service interface<br />
  22. 22. Service Model<br />Asymmetric: service provider OSGi, service consumer UI Runtime<br />Synchronous method calls<br />Parameters passed by value<br />No callbacks, no listeners…<br />Event support: to prevent polling in the applications<br />Applications can subscribe to Event Admin topics<br />
  23. 23. Convenience Library<br />Remote Service Access is specified in terms of protocols and access points<br />Ensures interoperability with any UI Runtime<br />A JavaScript convenience library is provided for better developer experience<br />Simple API to access RSR – find and bind services<br />Automatically generates stubs for using bound services<br />Subscribe to remote events (listeners)<br />
  24. 24. How to make a remote service<br />So, how to create a remote service?<br />By flagging it “remotable”:<br />org.osgi.remote.publish=true<br />
  25. 25. Best design practices for remote services<br />Use simple types as parameters<br />Primitive types and their wrappers<br />Strings<br />JavaBeans<br />Classes with default constructor and public members<br />Maps<br />Arrays (homogeneous)<br />Synchronous methods should return quickly<br />If operation takes longer, use notifications<br />Session-oriented services<br />
  26. 26. Session oriented services<br />startSession: returns session ID<br />Session ID used to identify an Event Admin topic.<br />Notifications are delivered through that topic<br />Session ID is used in each service request to identify the session<br />asynchServiceMethod: returns request ID<br />Events related to this request carry the request ID<br />
  27. 27. Session oriented service example - Messaging<br />public interface MessagingService {<br />public String startSession();<br />publicvoidstopSession(String sessionId);<br />/**<br /> * Result will be delivered to: <br /> * /com/prosyst/service/MessagingService/&lt;sessionId&gt; topic.<br /> */<br />publicintsendSms(String sessionId, SMSMessage message, Map options);<br />}<br />public class SMSMessage {<br />public String[] recipients;<br />public String body;<br />public Map options;<br />}<br />Success Event attributes<br />Failure Event attributes<br /><ul><li>Session ID
  28. 28. Request ID
  29. 29. Type: “MessageResult”
  30. 30. Session ID
  31. 31. Request ID
  32. 32. Type: “MessageError”
  33. 33. Status: sent, pending, delivered or failed
  34. 34. Recipients
  35. 35. Name
  36. 36. ErrorMessage</li></li></ul><li>Demo Application – Meet Me Here!<br />
  37. 37. Demo – Meet Me Here!<br />Meet Me Here! is a simple web application<br />Select a contact from the device contact list and send him a message<br />The default message contains a Google Map URL with the current location of the user<br />Implemented as a widget and a service bundle to access device features<br />Three remote services: contacts, location, messaging<br />Installed from a single deployment package<br />
  38. 38. Service Lookup and Binding<br />&lt;script src=&quot;http://localhost/rsr/rsr_1.0.js&quot;&gt;<br />&lt;/script&gt;<br />&lt;script type=&quot;text/javascript&quot;&gt;<br />functionbindService(service) {<br />varsreg = RSR.find(service,null);<br />if( sreg ) {<br />returnRSR.bind(sreg[0]);<br /> } else {<br />alert(&quot;Can&apos;t find &quot; + service <br /> + &quot; service!&quot;);<br /> }<br />}<br />const LOCATION= <br />&quot;com.prosyst.demo.rma.LocationService&quot;;<br />varlocationService = <br />bindService(LOCATION);<br />packagecom.prosyst.demo.rma;<br />publicinterfaceLocationService {<br />public Location getLocation();<br />}<br />public class Activator implementsBundleActivator {<br />public void start(BundleContext context) throws Exception {<br />Hashtable props = newHashtable();<br />props.put( &quot;org.osgi.remote.publish&quot;, Boolean.TRUE);<br />this.locationService = newLocationServiceImpl(context);<br />context.registerService( LocationService.class.getName(), this.locationService, props);<br />…<br />
  39. 39. Service Usage<br />varmsg = &quot;Location service not available&quot;;<br />if( !locationService ) {<br />locationService = <br />bindService(LOCATION_SERVICE);<br />}<br />var location = false;<br />if( locationService ) {<br />location = locationService.getLocation();<br />}<br />if( location ) {<br />msg = &quot;Meet Me Here: &quot; + &quot;; + location.latitude + &quot;, &quot; + location.longitude;<br />}<br />varsmsMessage =<br />document.getElementById(&quot;smsMessage&quot;);<br />smsMessage.value = msg;<br />packagecom.prosyst.demo.rma;<br />publicinterfaceLocationService {<br />public Location getLocation();<br />}<br />public class Location {<br />public double latitude;<br />public double longitude;<br />public double altitude;<br />public long timestamp;<br />}<br />
  40. 40. JSON RPC – Lightweight web service protocol<br />Specification:<br />Request:<br />{&quot;version&quot;:&quot;1.1&quot;,&quot;method&quot;:&quot;getLocation&quot;,&quot;params&quot;:[]}<br />Response:<br />{&quot;version&quot;:&quot;1.1&quot;,&quot;result&quot;:{&quot;altitude&quot;:0,&quot;timestamp&quot;:1242744765930,&quot;latitude&quot;:47.434006,&quot;longitude&quot;:19.148868}}<br />
  41. 41. Demo<br />
  42. 42. Summary<br />“Mobile Web Applications will beat native applications”Daniel K. Appelquist (<br />Using OSGi – you can take the best of both worlds:<br />Web developers & designers build the front-end<br />Java developers build the app logic<br />… and OSGi ensures the transparent interworking.<br />Having a server on the edge of the network changes the way things work.<br />
  43. 43. Where To Start?<br />Devices: First MASS Deployment in US in 2009. – Project Name: Sprint Titan<br />Shipping 5 device models during 2009<br />On 3 different platforms: Windows Mobile, BREW, 3rd platform<br />OSGi for Android Download:<br />2009 Sprint Open Developer Conference<br />My blog:<br />
  44. 44. Question?<br />
  45. 45. Contact <br />Gábor Pécsy<br /><br />Mobile: +36 70 385 5821<br /><br />ProSyst Software GmbH<br />Dürener Straße 405<br />D-50858 Cologne, Germany<br />Tel. +49 221 6604-0<br />Fax +49 221 6604-660<br /><br /><br />Member of:<br />