140 likes | 153 Views
Explore the concept of Micro Services in JavaScript with OSGi-style modularity. Learn about software development in a browser environment like Orion, utilizing modularity, plugins, and service APIs.
E N D
JavaScript Micro Services Simon Kaegi 27 March 2012
What are Micro Services? • OSGi minus the modularity
Orion and OSGi Modularity • e4 – OSGi style modularity in JavaScript { "Bundle-SymbolicName":"sample.jsbundle", "Bundle-Version":"1.0", "Bundle-ScriptPath":"script.js", "Import-Package":"a.resource;version=[1.0.0,2.0.0)", "Export-Package":"sample.resource;version=1.0.0", "Require-Bundle:"some.other.bundle“ } • AMD – RequireJS define(["dojo", "orion/serviceregistry", "dojo/DeferredList"], function(dojo, mServiceregistry){… return exports});
Orion Plugins • Orion applications are NOT made up of plugins • Orion pages are designed to be 'extended' with plugins • Orion plugins are 'separate' HTML pages hosted in non-visible IFrames • Can be cross origin and communicate using HTML5 postMessage which is ASYNC • Plugins are isolated and secure against direct modification of the hosting page
Web Application Front-end Web Client Web Application Front-end Web Server Web Application Front-end Plugin Web Application Front-end Plugin Web Application Front-end Plugin Web Application Front-end Web Client Web Application Front-end Web Server Web Application Front-end Proxied Service Web Application Front-end Proxied Service Java Web Application / OSGi Proxy Server / Portal
Web Application Front-end Web Client Web Application Front-end Web Server Web Application Front-end Plugin Web Application Front-end Web Server Web Application Front-end Plugin Web Application Front-end Web Server Orion way / Client-side Extension
Orion Extensibility registerService(INTERFACE_NAME, IMPLEMENTATION, PROPERTIES) In-page Plugin
Comparing OSGi and Orion Service APIs • Orion provides a nearly complete implementation of the Service API from OSGi BundleContext • ServiceReference, ServiceRegistration, … • service listeners, event types • Use Strings instead of java.lang.class when referencing Service interfaces • All Service calls return a “promise” – needed to abstract asynchronous service implementations • No ServiceTracker currently • originally built into getService but this was a mistake
What’s next • Declarative Services • wire.js – extends Asynchronous Module Definition define([“wire!aService", “wire!anotherService], function(aService, anotherService){…}); • Configuration Admin and Metatype Services • Permission Policy and Admin