WebSockets and Equinox OSGi in a Servlet Container - Nedelcho Delchev

264 views

Published on

OSGi Community Event 2016 Presentation by Nedelcho Delchev (SAP)

How to use WebSockets, coming as a standard feature with the modern Servlet Containers (e.g. Tomcat 7.x) from within the embedded Equinox OSGi environment deployed as a WAR application archive?

This talk will explain in details how to configure the classloaders and dependencies as well as how to create a websocket bridge for the internal OSGi plugins.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
264
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

WebSockets and Equinox OSGi in a Servlet Container - Nedelcho Delchev

  1. 1. WebSockets and Equinox OSGi in a Servlet Container Nedelcho Delchev [SAP] 2016-10-27
  2. 2. Who am I? I am Development Architect in HANA Cloud Platform Core team in the area of extensions for large enterprises in the cloud. Project lead of Eclipse Dirigible – a Cloud Development Platform project that provides full- fledged capabilities for developing, running and operating cloud applications – http://www.dirigible.io
  3. 3. ServletBridge Architecture • Server-Side Equinox: http://www.eclipse.org/equinox/server/ • Equinox in a Servlet Container: http://www.eclipse.org/equinox/server/http_in_ container.php • What is OSGi in Servlet Container series by Angelo Zerr: https://angelozerr.wordpress.com/2010/08/31/o sgi-equinox-in-a-servlet-container-step0/
  4. 4. ServletBridge Component Web Container Servlet Bridge OSGi Servlet OSGi Servlet Servlet
  5. 5. Websockets https://www.pubnub.com/blog/2014-10-01-websockets-and-long-polling-in- javascript-ruby-and-python/ https://www.tutorialspoint.com/websockets/websockets_quick_guide.htm
  6. 6. WebSocket Bridge in WebApp
  7. 7. WebSocket Servlet in OSGi
  8. 8. Registering OSGi WS Servlet in the BundleActivator
  9. 9. Websocket in Web Container Web Container ServletBridge [Registered OSGi WS Servlets] OSGi WS Servlet Websocket Servlet 1 2 3 1. Registering 2. Lookup 3. Communication
  10. 10. Classloaders visibility (launch.ini) osgi.*=@null org.osgi.*=@null eclipse.*=@null osgi.parentClassloader=fwk osgi.contextClassLoaderParent=fwk org.osgi.framework.system.packages.extra=javax.w ebsocket,javax.websocket.server,javax.mail,javax.m ail.internet,osgi.websockets.bridge
  11. 11. Authentication and Authorization • Logged-in User • Is User in Role?
  12. 12. “Hello World” via Websocket channel • Clone – https://github.com/delchev/WebSockets_EquinoxOSGi_ServletCont ainer.git • Build & Deploy • Access & Login - http://localhost:8080/services/standard • Create WS Client e.g. in Chrome – > var logSocket = new WebSocket("ws://localhost:8080/log"); • Inspect Frames in Network/WS • Access from a second browser - http://localhost:8080/services/standard • Send a message from WS client and receive the echo - logSocket.send("Hello from Client!");
  13. 13. Real-world examples • By Eclipse Dirigible
  14. 14. Log Console
  15. 15. Terminal
  16. 16. Debug
  17. 17. Scripting Services http://www.dirigible.io/api/websocket.html
  18. 18. Recap • You learnt that you can utilize WebSockets in a OSGi environment • You learnt how to do it via the ‘bridge’ concept • You learnt that it is not just pure theoretical thing, but it is already used in the real world projects • You got it re-confirmed OSGi is cool • You learnt about existence of an OSGi based Cloud Development Platform project called Eclipse Dirigible: http://www.dirigible.io
  19. 19. Thank You!
  20. 20. References • http://www.dirigible.io/blogs/2016/05/19/blo gs_web_sockets_and_osgi_in_servlet_contain er.html

×