3. OSGi Core: Modularity
• OSGi modules are called 'Bundles'
• Computed classloader delegation graph
• Bundles can be added,
removed & updated dynamically JRE JRE
• Side-by-side versioning
• Private truly private Lib A
Lib A Lib B
Lib B Lib A'
Lib A'
• No more Jar Hell
• OSGi Bundle can be a Module A Module B
Module A Module B
plain Jar at the same time
4. OSGi Core: Services
• “SOA inside the JVM”
• Services looked up by type and/or custom
filter
– “I want a service that implements
org.acme.Payment where location=US”
– One or many
• Dynamic! Services can be updated without
taking down the consumers
– OSGi Service Consumers react to dynamism
6. Cost vs Complexity
Cost
Big ball of mud
Traditional
Many small &
focused modules
Modular
Complexity
Modularity highly improves
*
maintainability
7. OSGi Bundles vs. JBoss Modules
• OSGi is a standard • Modules not portable
• Uses a complex resolver • Uses explicit wiring
• Wiring based on rich • Wiring based on module
metadata. Package version name. Multiple “slots” are
just one criteria supported
• Many compendium • Exist in the context of AS7
specifications and other 3rd • Very fast resolution
party bundles
• Attachable Fragments
• Sensitive to execution env
8. OSGi Service vs. MSC Services
• Keyed by Interface they • Keyed by unique service
implement name
• LDAP filter supported • No filtering, name only
• Lifecycle tied to owner • Lifecycle tied to owner
bundle or explicit API owner or explicit API
• Service dependency and • Service dependency and
injection via DS, Blueprint injection by MSC API
• ServiceListener supported • ServiceListener supported
• ServiceFactory supported • Instance per service name
• ConfigurationAdmin • ConfigAdmin in AS7
9. R5 Enterprise OSGi
• Mapping of a number of EE specs
– Webapp – JPA
– JTA – JNDI
– JDBC – JMX
• Remote Services
• Resolver
• Repository
• Subsystems
• Blueprint
11. OSGi Core in AS7
• AS7 is a fully compliant OSGi 4.2 Core
Framework
– TCK tests pass 100%
• Just deploy your OSGi Bundles
– Through the standard AS7 deployment
channels
12. OSGi Core Implementation
• Implemented from scratch on top of jboss-
modules and jboss-msc
• For the OSGi resolver we use the one from
Apache Felix
– Resolver computes the bundle classloader
wirings
– Based on OSGi Metadata
• e.g. Import-Package / Export-Package
13. AS7 OSGi Integration
• Use OSGi services in EE components
• Use EE components in OSGi services
• JBoss modules/msc as integration layer
• Every bundle is a module. Not every module
is bundle
• Support for WebApp, EJB, CDI, JAX-RS,
JAX-WS, JPA as OSGi deployments
• Support for Bundles in EAR files
14. Enterprise OSGi in AS7
• AS7 out of the Box:
– OSGi Core, Compendium APIs
– Enterprise OSGi JMX, JNDI, JTA, WebApp,
Blueprint
– OSGi ConfigAdmin, EventAdmin, HttpServer
– Management through WebConsole
15. OSGi in AS7 – Next Steps
• OSGi R5 specification
• OSGi Enterprise Applications
• Provisioning service
16. Demo
• Show how an EJB3 can access an OSGi
payment service
• Show how a Servlet can access an OSGi
payment service