OSGi
-
Upload
zeeshan-bilal -
Category
Technology
-
view
242 -
download
5
Transcript of OSGi
![Page 1: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/1.jpg)
OSGiThe Dynamic Module System for JavaTM
![Page 2: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/2.jpg)
OS
GiMotivation Growing complexity requires not only highly modular
code, but also systems that are dynamically extensible
Because there should be simpler way to construct software systems than writing , writing, and writing …
No matter which problem domain is your area of concern◦ Embedded systems need to adapt to changing requirements
even though they are deployed out in the field◦ Server applications must be configurable and manageable
without down time◦ Client applications must respond to user desires for new
functionality instantaneously
![Page 3: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/3.jpg)
OS
GiProblems to AddersLack of PortabilityStale DevicesSoftware SizeSoftware ComplexityLimits OO TechnologyQuality of Service
![Page 4: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/4.jpg)
OS
GiBackgroundStarted as an embedded platform for the
“home gateway”
Originally under the JCP as JSR-8 (1999)
Maintained by OSGi alliance, consists of a large number of big companies.
Current version: OSGi Release 4.2 (JSR-294)
![Page 5: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/5.jpg)
OS
GiIntroductionAn interesting platform for creating dynamically
extensible applications
Provides a service-oriented, component based environment
Offers standardized ways to manage the software lifecycle.
OSGi technology is Universal Middleware.
![Page 6: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/6.jpg)
OS
GiWhat we can achieve Resolves many deficiencies associated with
conventional approaches for modularity and dynamism◦ Provide a module concept
Explicit sharing of code (i.e., importing and exporting)
◦ Automatic management of code dependencies Enforces sophisticated consistency rules for class
loading
◦ Life-cycle management Manages dynamic deployment and configuration
![Page 7: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/7.jpg)
OS
GiArchitectural Overview
![Page 8: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/8.jpg)
OS
GiFramework Layers
L3 - publish/find/bind service model to decouple bundles
L2 - independent life-cycle of bundles without JVM restarts
L1 - a module (or bundle) uses classes from other bundles in a controlled way
L0 - well defined profiles that define the environment in which bundles can work
![Page 9: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/9.jpg)
OS
GiModule Layer Unit of deployment is bundle, a JAR Separate class loader per bundle Multi-version support (side-by-side) Explicit code boundaries and
dependencies Metadata in the manifest Automatic wiring based on version
ranges
![Page 10: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/10.jpg)
OS
GiLife-cycle Layer
Managed life cycle◦ States for each bundle;
Allows updates of existing bundles.◦ Dynamically install, start,
update, and uninstall
![Page 11: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/11.jpg)
OS
GiService Layer Service interfaces allow bundles to
interact by binding interfaces, not implementations
Publish/find/bind intra-VM service model
![Page 12: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/12.jpg)
OS
GiDynamic Service Lookup
OSGi Framework
Provided Service
Provided Package
installbundle.jar
Automatic package dependency resolution
Manual service dependency resolution Existin
g Bundle
Installed
Bundle
Resolv-ed Bundle
resolve bundle
![Page 13: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/13.jpg)
OS
GiOSGi Service AdvantagesLightweight services
◦ Direct method invocation
Good design practice◦ Separates interface from implementation◦ Enables reuse, substitutability, loose coupling, and late binding
Dynamic◦ Loose coupling and late binding make it possible to support
run-time dynamism
Application's configuration is simply the set of deployed bundles◦ Deploy only the bundles that you need
![Page 14: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/14.jpg)
OS
GiPaint ProgramCreate a simple Swing-based paint programDefine a SimpleShape interface to draw shapes
◦ Different implementations of SimpleShape can be created to draw different shapes
◦ Each shape has name and icon properties◦ Available shapes are displayed in tool bar
To draw a shape, click on its button and then click in the drawing canvas◦ Shapes can be dragged, but not resized
Support dynamic deployment of shapes
![Page 15: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/15.jpg)
OS
GiHigh Level Architecture
Best practice – Try to
centralize interactionwith OSGi API so that
other componentsremain POJOs...onlyShape Tracker willinteract with OSGi
API.Best practice – Do
notmake assumptions
about threads...since we
are creating a Swingapplication, Shape
Tracker sends events on
Swing thread.
Main applicationwindow – gets dynamically
injectedwith available
shapesfrom the Shape
Tracker..
Actual shapeimplementation.
Injected “proxied” shapeimplementation to hideaspects of dynamismand provide a defaultimplementation.
Component that draws the
shape in parent frame; looks
up shape via Drawing Frame
rather than having a direct
reference..
![Page 16: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/16.jpg)
OS
Gi
DEMO
![Page 17: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/17.jpg)
OS
GiAdoptionApplications can leverage OSGi
functionality in two ways◦Bundled application
Build entire application as a set of bundles that will run on top of a framework instance
◦Hosted framework Host a framework instance inside the
application and externally interact with bundles/services
![Page 18: OSGi](https://reader036.fdocuments.net/reader036/viewer/2022081519/554f7879b4c9052a518b48b8/html5/thumbnails/18.jpg)
OS
GiAdoption (Bundled vs Hosted)Building your application as a set of bundles is
the preferred approach◦ Allows all parts of application to benefit from OSGi
modularity and dynamism◦ Allows application to run on any framework◦ However, it is not always possible to bundle
application, e.g., legacy situationsHosted framework approach allows piecemeal
OSGi adoption◦ Will likely tie application to a framework
implementation