VIB - Very Important Bundles
-
Upload
roman-roelofsen -
Category
Technology
-
view
1.297 -
download
4
Transcript of VIB - Very Important Bundles
![Page 1: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/1.jpg)
Very Important Bundles
Roman RoelofsenLead Architect
@
![Page 2: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/2.jpg)
OSGi Bundles
● Even though this depends on the architecture and dependencies, OSGi has proven that bundles increase the assembly possibilites
– Rich meta-data, enforced resolving, ...● E.g. copy & paste files to enhance the runtime
features („VB-feeling“ on module level)
– Console (test, debug, ...)● Bundles can improve the development process
– Some bundles make it easy, some hard...
![Page 3: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/3.jpg)
Good Bundles
# 6
Logging
![Page 4: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/4.jpg)
Good Bundles: Logging
● Problem
– Your application + frameworks use different logging APIs, e.g. log4j, commons logging, ...
● Solution
– PAX Logging
– 2 bundles: pax-logging-api & pax-logging-service
– 8 logging APIs
– Redirects to LogService & log4j
– Configuration Admin support
![Page 5: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/5.jpg)
Good Bundles
# 5
Web Development
![Page 6: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/6.jpg)
Good Bundles: Web Development
● Problem
– HttpService is simply not enough● Solution
– PAX Web
– Whiteboard pattern (service registry)
– Extender pattern (web.xml)
– Support for filters and JSP
– Configuration Admin support
![Page 7: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/7.jpg)
Good Bundles
# 4
Remoting
![Page 8: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/8.jpg)
Good Bundles: Remoting● Problem
– You want to expose some of your services as endpoints
– You want to access endpoints via services● Solution
– Apache CXF Distributed OSGi
– Single bundle distribution!
– Export endpoint● service.exported.interfaces = *
– Import Endpoint● /OSGI-INF/remote-service/remote-services.xml
![Page 9: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/9.jpg)
Good Bundles
# 3
Dependency Injection /Service Interaction
![Page 10: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/10.jpg)
Good Bundles: DI● Problem
– You want dependency injection● Solution
– Declarative Services● No full DI support, mostly for dealing with services
– Peaberry● Google Guice add-on, Java based DSL
– Apache Felix iPOJO● Sophisticated, a bit challenging
– Spring Dynamic Modules● Spring add-on
![Page 11: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/11.jpg)
Good Bundles
# 2
Framework Tooling
![Page 12: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/12.jpg)
Good Bundles: Framework Tooling
● Problem
– The console is nice, but sometimes a bit annoying– Install file: /home/user/dev/workspace/app/.../bundle.jar
– Track EventAdmin events
● Solution
– Apache Felix Web Console
– Basic setup requires only one bundle
– Works with Felix/Equinox/...
![Page 13: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/13.jpg)
Good Bundles: Framework Tooling
![Page 14: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/14.jpg)
Good Bundles
# 1
Bundle Tooling
![Page 15: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/15.jpg)
Good Bundles: Bundle Tooling
● Problem
– Create bundles for quick tests
– Manifest reading
– Library wrapping
– ...● Solution
– Peter Kriens' BND
![Page 16: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/16.jpg)
Good Bundles: Bundle Tooling
![Page 17: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/17.jpg)
Good Bundles: Bundle Tooling
![Page 18: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/18.jpg)
Better Modularity with Bundles
≠
![Page 19: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/19.jpg)
Dependencies
● Writing bundles does not automatically imply that dependency problems are avoided
● Require-Bundle is just as bad as „new Service()“
– Only on a different level
– Rely on Import-Package, let the resolver do the rest
– Be open for future modifications● Provide whiteboard / extender pattern implementation
where reasonable
![Page 20: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/20.jpg)
Bundle Granularity
● Common practive, e.g. Maven
– Divide you build into several modules
– Each module will result in a JAR
● Maven-bundle-plugin
– Add OSGi metadata
● Ship bundles
– User happy?
![Page 21: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/21.jpg)
Bundle Granularity
Build
core1.jarcore2.jar
protocolA1.jarprotocolA2.jarprotocolA3.jar
protocolB1.jarprotocolB2.jar
Bundle
core1.jarcore2.jar
protocolA1.jarprotocolA2.jarprotocolA3.jar
protocolB1.jarprotocolB2.jar
User's POV
either this
or this
mandatory
![Page 22: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/22.jpg)
Bundle Granularity
Build
core1.jarcore2.jar
protocolA1.jarprotocolA2.jarprotocolA3.jar
protocolB1.jarprotocolB2.jar
Bundle User's POV
either this
or this
mandatorycore.jar
protocolA.jar
protocolB.jar
![Page 23: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/23.jpg)
Summary
● Bundles are so much better than plain JARs
● Bundles are deliveries for your users
● Granularity during development is different from granularity for deployments
● Embed your dependencies if they do not provide a value for your user
– Bundle-Classpath is your friend● Avoid Require-Bundle & DynamicImport-
Package
![Page 25: VIB - Very Important Bundles](https://reader034.fdocuments.net/reader034/viewer/2022052508/55a06a9b1a28ab75388b4778/html5/thumbnails/25.jpg)
●http://www.flickr.com/photos/jessicafm/2767435428
●http://www.manuelm.org/blog/wp-content/uploads/2009/02/overview.png