220 likes | 381 Views
EclipseLink OSGi. OSGi Concepts. Multiple Versions Allows multiple versions of the same code to be deployed and provides a mechanism to find the required version Bundle Roughly equivalent to a JAR file
E N D
OSGi Concepts • Multiple Versions • Allows multiple versions of the same code to be deployed and provides a mechanism to find the required version • Bundle • Roughly equivalent to a JAR file • Bundle manifest describes the bundle to the Framework, Identity, version, dependencies, exports etc • Fragment • Allows new functionality to be “attached” to a bundle • Activator • When a bundle starts, if it has an activator it is run • Services • OSGi Provides a service registry
EclipseLink OSGi Functionality • JAXB • SDO • JPA • EclipseLink 2.1 contains 2 OSGi implementations • Home-grown support from our 2.0 release • Dynamic weaving support on Equinox • Persistence Units may span bundles • Gemini • Eclipse Project implementing OSGi Enterprise Specification • OSGi Spec-based JPA • Dynamic weaving work in progress
Core EclipseLink OSGi Packaging EclipseLink is available as a set of OSGi bundles: JPA org.eclipse.persistence.jpa—JPA implementation org.eclipse.persistence.antlr—JPQL parsing org.eclipse.persistence.asm—Byte code manipulation MOXy JAXB org.eclipse.persistence.moxy—OXM/JAXB implementation SDO org.eclipse.persistence.sdo—SDO implementation Core (used by all persistence services) org.eclipse.persistence.core—shared infrastructure
Gemini and EclipseLink • Additional Bundles • javax.persistence 2.0 • Gemini version • JDBC driver bundle following OSGi Enterprise specification • Gemini Bundle
Gemini OSGi Example ClientBundle PersistenceBundle 'Accounting' Entity Manager Factory Service?
Gemini OSGi Example ClientBundle PersistenceBundle 'Accounting' Entity Manager Factory Service?
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle JPA Provider Bundle Started 'Accounting' Entity Manager Factory Service?
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle Detect & Process Persistence Descriptor 'Accounting' Entity Manager Factory Service?
Gemini OSGi Example 'Accounting' PU with required data source declared ClientBundle PersistenceBundle JPA ProviderBundle 'Accounting' Entity Manager Factory Service?
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle 'Accounting' Entity Manager Factory Service? JDBC Data Source for 'Accounting' PU?
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle 'Accounting' Entity Manager Factory Service? JDBC Data Source for 'Accounting' PU?
Gemini OSGi Example JDBC Driver Bundle Started JDBC ProviderBundle ClientBundle PersistenceBundle JPA ProviderBundle 'Accounting' Entity Manager Factory Service? JDBC Data Source for 'Accounting' PU?
Gemini OSGi Example Data Source Service Published JDBC ProviderBundle ClientBundle PersistenceBundle JPA ProviderBundle JDBC Data Source Service 'Accounting' Entity Manager Factory Service? JDBC Data Source for 'Accounting' PU?
Gemini OSGi Example JDBC ProviderBundle ClientBundle PersistenceBundle JPA ProviderBundle JDBC Data Source Service 'Accounting' Entity Manager Factory Service? JDBC Data Source for 'Accounting' PU?
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle JDBC ProviderBundle JDBC Data Source Service 'Accounting' Entity Manager Factory Service? 'Accounting' Entity Manager Factory Service Entity Manager Factory Service Published
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle JDBC ProviderBundle JDBC Data Source Service 'Accounting' Entity Manager Factory Service? 'Accounting' Entity Manager Factory Service
Gemini OSGi Example ClientBundle PersistenceBundle JPA ProviderBundle JDBC ProviderBundle JDBC Data Source Service Obtain Entity Manager Factory from service 'Accounting' Entity Manager Factory Service
What do I need to know • Manifests • All EclipseLink bundles have OSGi manifests that describe their dependencies • Activators • org.eclipse.persistence.jpa • Provides functionality for pre-Gemini • Advertises persistence provider serivce • Sets up initialization • javax.persistence • Sets provider resolver • Advertises service in pre-gemini implementation • Fragments • Several fragments used to alter the behavior in certain situations • Equinox weaving (includes hook into Equinox) • Switching between Gemini and pre-Gemini functionality • Oracle-specific Platform classes
Gotchas/Challenges • Packages must be completely contained in the same bundle • Exception: Fragments may extend a package • Must use the correct class loader • ClassLoader is passed in to EclipseLink • In absence of available loader, “loader that loaded this class” can sometimes work • In Gemini, persistence unit must be contained in same bundle • PDE quirkiness • Manifest coordination • BND • PDE/PDE Build • JEE/OSGi versioning practices
Pre-Gemini OSGi Config • Additional Bundles • javax.persistence 2.0 • Must use javax.persistence bundle from EclipseLink repository • org.eclipse.persistence.jpa.osgi • New fragment in 2.1 Required to run in pre-gemini mode • DB Driver bundle • Bundle that makes DB driver code available • org.eclipse.persistence.equinox • Byte code weaving Fragment for Equinox • org.eclipse.persistence.equinox.weaving • Byte code weaving Fragment for Equinox • http://fisheye2.atlassian.com/browse/eclipselink/trunk/examples/org.eclipse.persistence.example.jpa.rcp.comics/ReadMe.txt
Future Directions • Weaving • Enable weaving in Gemini • Weaving for OSGi implementations other than Equinox • Testing • Stronger JPA OSGi testing story • Automated testing of JAXB and SDO • Mindshare • Committers understand OSGi basics and code with OSGi in mind