WebSockets and Equinox OSGi in a Servlet Container

20
WebSockets and Equinox OSGi in a Servlet Container Nedelcho Delchev [SAP] 2016-10-27

Transcript of WebSockets and Equinox OSGi in a Servlet Container

Page 1: WebSockets and Equinox OSGi in a Servlet Container

WebSockets and Equinox OSGi in a Servlet Container

Nedelcho Delchev [SAP]2016-10-27

Page 2: WebSockets and Equinox OSGi in a Servlet Container

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

Page 3: WebSockets and Equinox OSGi in a Servlet Container

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/osgi-equinox-in-a-servlet-container-step0/

Page 4: WebSockets and Equinox OSGi in a Servlet Container

ServletBridge Component

Web Container

Servlet Bridge

OSGi Servlet

OSGiServlet

Servlet

Page 6: WebSockets and Equinox OSGi in a Servlet Container

WebSocket Bridge in WebApp

Page 7: WebSockets and Equinox OSGi in a Servlet Container

WebSocket Servlet in OSGi

Page 8: WebSockets and Equinox OSGi in a Servlet Container

Registering OSGi WS Servlet in the BundleActivator

Page 9: WebSockets and Equinox OSGi in a Servlet Container

Websocket in Web Container

Web ContainerServletBridge [Registered

OSGi WS Servlets]

OSGi WS Servlet

Websocket Servlet

1

2

3

1. Registering 2. Lookup 3. Communication

Page 10: WebSockets and Equinox OSGi in a Servlet Container

Classloaders visibility (launch.ini)

osgi.*[email protected].*=@nulleclipse.*=@null

osgi.parentClassloader=fwkosgi.contextClassLoaderParent=fwkorg.osgi.framework.system.packages.extra=javax.websocket,javax.websocket.server,javax.mail,javax.mail.internet,osgi.websockets.bridge

Page 11: WebSockets and Equinox OSGi in a Servlet Container

Authentication and Authorization

• Logged-in User• Is User in Role?

Page 12: WebSockets and Equinox OSGi in a Servlet Container

“Hello World” via Websocket channel

• Clone – https://github.com/delchev/WebSockets_EquinoxOSGi_ServletContainer.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!");

Page 13: WebSockets and Equinox OSGi in a Servlet Container

Real-world examples

• By Eclipse Dirigible

Page 14: WebSockets and Equinox OSGi in a Servlet Container

Log Console

Page 15: WebSockets and Equinox OSGi in a Servlet Container

Terminal

Page 16: WebSockets and Equinox OSGi in a Servlet Container

Debug

Page 17: WebSockets and Equinox OSGi in a Servlet Container

Scripting Services

http://www.dirigible.io/api/websocket.html

Page 18: WebSockets and Equinox OSGi in a Servlet Container

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

Page 19: WebSockets and Equinox OSGi in a Servlet Container

Thank You!