In this presentation, we will discuss the benefits of hybrid applications and demonstrate how such applications can be built and deployed. A hybrid application is both an OSGi bundle as well as a Java EE application. GlassFish is a natural container of choice for such applications.
4.
GlassFish
● A Community
● Users, Partners, Testers, Developers
● Started in 2005 on java.net
● Application Server
● Enterprise Quality and Open Source
● Java EE 5 / 6 Reference Implementation
● Full Commercial Support from Sun/Oracle
● Tools Bundle for NetBeans & Eclipse
– http://www.eclipsecon.org/2010/sessions/?page=sessions&id=1226
10.
Why OSGi in Enterprise Apps?
● Improved Modularity
● Reusable bundles
● Dependencies are more visible
● Better Isolation / Cleaner Class Loading Model
● Better version control
● Faster deployment cycle
● Better tools for deployment (e.g., OBR)
● Observable bundle life cycle
● Service Tracking
● Criteria Based Service Selection
11.
Why Java EE in Enterprise Apps?
● Better API (JPA, JTA, JAXB, JNDI)
● Better component model (Servlet, EJB, JAXRS)
● Better frameworks (JSF, CDI)
● Ease of Use (Annotations, Convention over
configuration)
● Platform provided integrated infrastructure
services (Transaction, Security, Persistence,
Remoting)
● Many more reasons....
14.
Differentiators
● Runtime + OSGi glue layer
● Migration path for Java EE to hybrid apps
● Java EE 6 support
● Supports Java EE component model (e.g. EJB
as OSGi service)
● And extensible (blueprint component model,
declarative services, iPOJO)
17.
OSGi/HTTP Service
● Thin API – contains only two interfaces
● HttpService – registerResource, registerServlet,
unregister
● HttpContext – Provides a context to a collection of
servlets.
● GlassFish OSGi Administration Console
● Based on Apache Felix Web Console
http://www.osgi.org/javadoc/r4v42/org/osgi/service/http/packagesummary.html
18.
OSGi/JPA
● JPA supported in hybrid applications
● Enhancement at runtime
● Works in all OSGi runtime
● Same packaging rules as JPA
● You can also deploy entities.jar as a bundle
● Shared persistence unit – so shared 2nd
level cache
19.
OSGi/JDBC
● JDBC Driver as DataSourceFactory
● Dynamic discovery of driver details
● Multiple versions of same driver
● Wrap nonOSGi driver jars > Bundles
● JDBC resource exported as OSGi Service
20.
OSGi/Web Application (rfc #66)
● Web Application Bundle (WAB)
● WAR + OSGi Metadata + WebContextPath header
● Can use all enterprise APIs Including JPA with lazy loading
● Sample manifest:
ManifestVersion: 1.0
ImportPackage: javax.servlet.http; javax.persistence
BundleClassPath: WEBINF/classes/,WEBINF/lib/entities.jar
BundleVersion: 1.0
BundleManifestVersion: 2
WebContextPath: /hello
BundleSymbolicName: test.hellowab
● Wrapped WAR Support
● webbundle: URL scheme
21.
OSGi/EJB (GlassFish feature)
● EJB Jar as OSGi bundle
● EJB artifacts + OSGi Metadata + ExportEJB
header
● ExportEJB: List of EJBs to be exported as
OSGi services.
● Special values: NONE, ALL
● Support for Stateless & Singleton EJBs with Local
Views
● Same life cycle as WAB
● Local EJB can cross application boundary!!!