Your SlideShare is downloading. ×
0
1
<Insert Picture Here>
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application
Development
Sanjeeb Sahoo
Staff...
2
The following is intended to outline our general
product direction. It is intended for information
purposes only, and ma...
3
The preceding is intended to outline our general
product direction. It is intended for information
purposes only, and ma...
4
<Insert Picture Here>
Agenda
• OSGi 101
• OSGi meets Java EE – Hybrid Applications
• Advanced usecases
• Hybrid Applicat...
5
<Insert Picture Here>
Agenda
• OSGi 101
• OSGi meets Java EE – Hybrid Applications
• Advanced usecases
• Hybrid Applicat...
6
OSGi
Service oriented
dynamic
module system
for Java
7
OSGi Layers
8
Module Layer
• Bundle – a unit of modularity in OSGi
• Encapsulation
• Lifecycle independent of the JVM
• Versionable
• ...
9
Bundle-SymbolicName: com.acme.hello.startup
Bundle-Name: Hello World OSGi Sample
Bundle-Version: 1.0.1
Bundle-ManifestVe...
10
Classloading in OSGi
Image from the OSGi R4 Core Specification
11
Lifecycle Layer
• Provides an API to manage bundles
– BundleContext.install
– BundleContext.uninstall
– Bundle.update
•...
12
Bundle Lifecycle
Image from the OSGi R4 Core Specification
13
Service Layer
• In-VM SOA
• Service Registry
– Register
– Unregister
• Service is a POJO
• Service Dynamism
– Service t...
14
Interactions between OSGi Layers
Image from the OSGi R4 Core Specification
15
OSGi benefits – a recap
• Layered approach
• Modularity
– Enforces modularity
– Ensures class-space consistency
– Enabl...
16
OSGi meets Java EE
17
<Insert Picture Here>
Agenda
• OSGi 101
• OSGi meets Java EE – Hybrid Applications
• Advanced usecases
• Hybrid Applica...
18
Java EE
Platform of choice for enterprise applications
• Widely used APIs (JPA, JTA, JAXB, JNDI)
• Component Models (Se...
19
Hybrid Applications
Meeting of the two worlds
• OSGi + Java EE = Hybrid application
• Hybrid application
– An OSGi bund...
20
Current State
• OSGi Enterprise Expert Group (EEG)
– Relased OSGi Service Platform Enterprise Specification 4.2
in 2010...
21
OSGi/Web Application (WAB)
• Web Application Bundle (WAB)
– WAR + OSGi metadata + Web-ContextPath header
• Can use all ...
22
Bundle-SymbolicName: com.acme.hellowab
Bundle-Name: Hello World OSGi Web Application
Bundle-Version: 1.0.0
Bundle-Manif...
23
Hybrid application bundle lifecycle
24
Enterprise OSGi Specifications
• OSGi/Web Application
• OSGi/JPA
• OSGi/JDBC
• OSGi/JTA
• OSGi/JNDI
• OSGi/HTTP Service...
25
EE APIs in OSGi
• OSGi/JDBC
– JDBC driver as DataSourceFactory
– Dynamic discovery of driver details
– Multiple version...
26
Tools
• BND (http://www.aqute.biz/Code/Bnd)
– de-facto tool for OSGi metadata generation
– maven-bundle-plugin
– Ant ta...
27
Advanced Usecases
28
<Insert Picture Here>
Agenda
• OSGi 101
• OSGi meets Java EE – Hybrid Applications
• Advanced usecases
• Hybrid Applica...
29
OSGi/EJB Application
• Allows you to develop managed, transactional, secure
OSGi services with very little knowledge of...
30
Bundle-SymbolicName: com.acme.helloEjbOsgi
Bundle-Name: Hello World OSGi EJB Bundle
Bundle-Version: 1.0.0
Bundle-Manife...
31
CDI
• Brings type-safe dependency injection to EE platform
– Strong typing and loose coupling
• Well defined life cycle...
32
GlassFish CDI/OSGi Portable Extension
• Use of CDI for type safe injection of OSGi services
@WebServlet(urlPatterns = “...
33
Demo: Putting them
together
34
Demo schematic
• WAB
• JPA- LAZY loading
• EJB as Service
• OSGi Service Injection
• OBR
• Security/Transaction
Context...
35
Call To Action
• Want to build hybrid applications?
– Try our tutorial at http://tinyurl.com/osgieehol
• Want to try ou...
36
References
• OSGi Service Platform Core and Enterprise
Specification 4.2
– http://www.osgi.org
• Project GlassFish
– ht...
37
<Insert Picture Here>
Agenda
• OSGi 101
• OSGi meets Java EE – Hybrid Applications
• Advanced usecases
• Hybrid Applica...
38
<Insert Picture Here>
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application
Development
Sanjeeb Sahoo
Staf...
Upcoming SlideShare
Loading in...5
×

OSGi & Java EE: A hybrid approach to Enterprise Java Application Development, Sahoo

4,448

Published on

There's a considerable activity in the enterprise Java community about the use of OSGi in Java EE applications. We call such applications "hybrid applications." With hybrid applications, developers can continue to build standard and familiar enterprise application components, such as Java Servlets and EJBs, and take full advantage of:

* Features such as modularity/dependency management, service dynamism, and more provided by OSGi
* Infrastructure services such as transaction management, security, persistence, and more offered by Java EE

This session will present the current state of affairs, discuss the benefits of hybrid applications, and demonstrate development and deployment of such applications.
GlassFish will be used for demonstration.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,448
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
145
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "OSGi & Java EE: A hybrid approach to Enterprise Java Application Development, Sahoo"

  1. 1. 1 <Insert Picture Here> OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development Sanjeeb Sahoo Staff Engineer, Sun Microsystems India Pvt. Ltd.
  2. 2. 2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Safe Harbor Statements
  3. 3. 3 The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  4. 4. 4 <Insert Picture Here> Agenda • OSGi 101 • OSGi meets Java EE – Hybrid Applications • Advanced usecases • Hybrid Application Demo • Q & A
  5. 5. 5 <Insert Picture Here> Agenda • OSGi 101 • OSGi meets Java EE – Hybrid Applications • Advanced usecases • Hybrid Application Demo • Q & A
  6. 6. 6 OSGi Service oriented dynamic module system for Java
  7. 7. 7 OSGi Layers
  8. 8. 8 Module Layer • Bundle – a unit of modularity in OSGi • Encapsulation • Lifecycle independent of the JVM • Versionable • Packaged as a JAR (classes + Manifest with OSGi metadata) • Very explicit dependency specification • Well defined dependency resolution rules
  9. 9. 9 Bundle-SymbolicName: com.acme.hello.startup Bundle-Name: Hello World OSGi Sample Bundle-Version: 1.0.1 Bundle-ManifestVersion: 2 Bundle-Activator: com.acme.hello.startup.MyActivator Export-Package: com.acme.hello.startup;version=1.0.0 Import-Package: org.osgi.framework;version=1.3 OSGi Metadata
  10. 10. 10 Classloading in OSGi Image from the OSGi R4 Core Specification
  11. 11. 11 Lifecycle Layer • Provides an API to manage bundles – BundleContext.install – BundleContext.uninstall – Bundle.update • BundleActivator • BundleListener – listen to BundleEvents – Synchronous – Asynchronous
  12. 12. 12 Bundle Lifecycle Image from the OSGi R4 Core Specification
  13. 13. 13 Service Layer • In-VM SOA • Service Registry – Register – Unregister • Service is a POJO • Service Dynamism – Service tracking • Service Discovery – LDAP filter based queries
  14. 14. 14 Interactions between OSGi Layers Image from the OSGi R4 Core Specification
  15. 15. 15 OSGi benefits – a recap • Layered approach • Modularity – Enforces modularity – Ensures class-space consistency – Enables component reuse – Supports versioning and evolution • Dynamism – Bundles – Services • Ease of deployment and management – OBR • Bundle deployment order is not relevant – Faster deployment cycle
  16. 16. 16 OSGi meets Java EE
  17. 17. 17 <Insert Picture Here> Agenda • OSGi 101 • OSGi meets Java EE – Hybrid Applications • Advanced usecases • Hybrid Application Demo • Q & A
  18. 18. 18 Java EE Platform of choice for enterprise applications • Widely used APIs (JPA, JTA, JAXB, JNDI) • Component Models (Servlet, EJB, JAX-RS) • Frameworks (JSF, CDI) • Ease of Use (Annotations, Convention over Configuration) • Platform provided infrastructure services (Transaction, Security, Persistence, Remoting) • Tools (IDE, Management, Monitoring) • Ubiquitous deployment platform for enterprise applications
  19. 19. 19 Hybrid Applications Meeting of the two worlds • OSGi + Java EE = Hybrid application • Hybrid application – An OSGi bundle – And a Java EE Archive • Leverage the capabilities of both the platforms – Enterprise applications can now • be built as modular OSGi bundles • use OBR, Config Admin, service tracking, etc. – OSGi bundles can now use Java EE services like JTA, JPA, etc.
  20. 20. 20 Current State • OSGi Enterprise Expert Group (EEG) – Relased OSGi Service Platform Enterprise Specification 4.2 in 2010 • Open source efforts – Project GlassFish – Project Aries – Eclipse Gemini
  21. 21. 21 OSGi/Web Application (WAB) • Web Application Bundle (WAB) – WAR + OSGi metadata + Web-ContextPath header • Can use all enterprise APIs (like JPA, JTA) • Wrapped WAR support – webbundle: URL scheme
  22. 22. 22 Bundle-SymbolicName: com.acme.hellowab Bundle-Name: Hello World OSGi Web Application Bundle-Version: 1.0.0 Bundle-ManifestVersion: 2 Bundle-Activator: com.acme.hellowab.MyActivator Import-Package: javax.servlet; javax.servlet.http; version=3.0, org.osgi.framework; version=1.5 Bundle-ClassPath: WEB-INF/classes, WEB-INF/lib/foo.jar Web-ContextPath: /hello OSGi Metadata of a WAB
  23. 23. 23 Hybrid application bundle lifecycle
  24. 24. 24 Enterprise OSGi Specifications • OSGi/Web Application • OSGi/JPA • OSGi/JDBC • OSGi/JTA • OSGi/JNDI • OSGi/HTTP Service • OSGi Blueprint Service
  25. 25. 25 EE APIs in OSGi • OSGi/JDBC – JDBC driver as DataSourceFactory – Dynamic discovery of driver details – Multiple versions of same driver • OSGi/JTA – JTA artifacts available as OSGi Services • OSGi/JPA – Enhancement of JPA entities at runtime – Same packaging rules as JPA and also deploy entities as a bundle – Shared Persistence Unit and thereby shared second level cache
  26. 26. 26 Tools • BND (http://www.aqute.biz/Code/Bnd) – de-facto tool for OSGi metadata generation – maven-bundle-plugin – Ant task • IDE – Eclipse – NetBeans – IntelliJ IDEA
  27. 27. 27 Advanced Usecases
  28. 28. 28 <Insert Picture Here> Agenda • OSGi 101 • OSGi meets Java EE – Hybrid Applications • Advanced usecases • Hybrid Application Demo • Q & A
  29. 29. 29 OSGi/EJB Application • Allows you to develop managed, transactional, secure OSGi services with very little knowledge of OSGi • Make your existing EJB service available to OSGi clients with little effort • Achieved through simple manifest metadata – Export-EJB: ALL/None/<names of stateless local EJB>
  30. 30. 30 Bundle-SymbolicName: com.acme.helloEjbOsgi Bundle-Name: Hello World OSGi EJB Bundle Bundle-Version: 1.0.0 Bundle-ManifestVersion: 2 Import-Package: javax.ejb; version=3.0, Export-EJB: ALL OSGi Metadata of an OSGi/EJB bundle
  31. 31. 31 CDI • Brings type-safe dependency injection to EE platform – Strong typing and loose coupling • Well defined life cycle of stateful objects bound to life cycle contexts • Ability to decorate and intercept injected Beans • An event notification model • An ability to develop portable extensions that integrates with the container to extend the runtime
  32. 32. 32 GlassFish CDI/OSGi Portable Extension • Use of CDI for type safe injection of OSGi services @WebServlet(urlPatterns = “/login”) public class FooServlet implements HttpServlet {     @Inject      @org.glassfish.osgicdi.OSGiService(           dynamic=”true”,            timeout = 200,            serviceCriteria=<an ldap query >)     FooService foo; }
  33. 33. 33 Demo: Putting them together
  34. 34. 34 Demo schematic • WAB • JPA- LAZY loading • EJB as Service • OSGi Service Injection • OBR • Security/Transaction Context propagation Simple OSGi Bundle OSGi Service Simple OSGi Service EJB OSGi Service Advanced WAB Simple WAB
  35. 35. 35 Call To Action • Want to build hybrid applications? – Try our tutorial at http://tinyurl.com/osgieehol • Want to try out? – Use GlassFish 3.1 trunk builds from http://glassfish.org • Questions? – users@glassfish.dev.java.net
  36. 36. 36 References • OSGi Service Platform Core and Enterprise Specification 4.2 – http://www.osgi.org • Project GlassFish – http://glassfish.org • Hybrid application samples – http://wikis.sun.com/display/GlassFish/BlogsGfOsgi
  37. 37. 37 <Insert Picture Here> Agenda • OSGi 101 • OSGi meets Java EE – Hybrid Applications • Advanced usecases • Hybrid Application Demo • Q & A
  38. 38. 38 <Insert Picture Here> OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development Sanjeeb Sahoo Staff Engineer, Sun Microsystems India Pvt. Ltd.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×