OSGi Persistence Shaun Smith
OSGi Persistence <ul><li>A core need for any enterprise Java application is persistence, e.g.: </li></ul><ul><ul><li>Data ...
Java Persistence: The Problem Space Customer id: int name: String creditRating: int CUST ID NAME C_RATING <customer id=“…”...
Java Persistence Standards <ul><li>Object-Relational: Java Persistence API (JPA) </li></ul><ul><ul><li>JPA 1.0 part of EJB...
EclipseLink Architecture   DBWS   SDO   EIS   MOXy JPA XML Data Legacy Systems Databases Java SE Java EE OSGi Spring
EclipseLink Background <ul><li>EclipseLink  </li></ul><ul><ul><li>Official name &quot;Eclipse Persistence Services Project...
EclipseLink Distributions <ul><li>Eclipse </li></ul><ul><li>Oracle </li></ul><ul><ul><li>TopLink 11g </li></ul></ul><ul><u...
EclipseLink JPA <ul><li>JPA 1.0 compliant implementation  </li></ul><ul><li>Delivering the JPA 2.0 Reference Implementatio...
EclipseLink MOXy <ul><li>Provides complete Object-XML mapping </li></ul><ul><ul><li>Allows developers to work with XML as ...
EclipseLink SDO <ul><li>SDO 2.1 provides the ability to: </li></ul><ul><ul><li>Generate Java SDO classes (static SDOs) fro...
EclipseLink OSGi Packaging <ul><li>EclipseLink is available as a set of OSGi bundles: </li></ul><ul><ul><li>JPA </li></ul>...
OSGi Persistence Goal <ul><li>Support usage of standard APIs </li></ul><ul><ul><li>javax.persistence.Persistence.createEnt...
OSGi Persistence Challenges <ul><li>JPA </li></ul><ul><ul><li>javax.persistence.Persistence SPI scans classpath for provid...
JPA—Bootstrap Problem <ul><li>Persistence  finds providers by loading all  javax.persistence.spi .PersistenceProvider .xml...
JPA—Service Based Solution <ul><li>OSGi aware  javax.persistence  bundle that allows providers to register a persistence p...
JPA—Resource Access Problem <ul><li>EclipseLink’s Persistence Provider can’t see  persistence.xml, orm.xml , or Entities i...
JPA—Extender Pattern Solution <ul><li>EclipseLink JPA uses extender pattern to identify persistence unit bundles. </li></u...
Demo
EclipseLink Weaving Support <ul><li>Uses (ASM) to introduce additional functionality into the ‘POJO’ domain classes </li><...
More Problems and Solutions  <ul><li>JAXB OSGi  </li></ul><ul><ul><li>Support usage of standard APIs </li></ul></ul><ul><u...
Future Plans and Goals <ul><li>Investigate further bundle splitting </li></ul><ul><ul><li>As required by usage scenarios <...
Summary <ul><li>OSGi presents challenges when trying to use many frameworks built for Java SE/EE environments. </li></ul><...
Upcoming SlideShare
Loading in...5
×

OSGi Persistence With EclipseLink

10,236

Published on

A presentation on the use of EclipseLink as a JPA, JAXB, or SDO persistence provider in OSGi. Equinox specific extensions for JPA byte code weaving are also described.

Published in: Economy & Finance, Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,236
On Slideshare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
213
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • One of the core needs of any enterprise application is persistence. To compete in this space, OSGi applications need access to relational, XML, and web service data sources using Java standard APIs like the Java Persistence API (JPA), Java Architecture for XML (JAXB), and Service Data Objects (SDO). But most commercial and open source persistence frameworks do not work out of the box in OSGi. Fortunately EclipseLink, the Eclipse Persistence Services Project, provides high performance native OSGi implementations of JPA, JAXB, and SDO.
  • Java Applications need to either access existing data sources like relational database or interact with other systems via XML—or BOTH. The example is a trivial one but it can get very complicated to map between an Java object model and a relational or XML schema.
  • Transcript of "OSGi Persistence With EclipseLink"

    1. 1. OSGi Persistence Shaun Smith
    2. 2. OSGi Persistence <ul><li>A core need for any enterprise Java application is persistence, e.g.: </li></ul><ul><ul><li>Data maintained in a relational database </li></ul></ul><ul><ul><li>XML data maintained in files or exchanged with other systems </li></ul></ul><ul><li>Persistence frameworks and standards designed for Java SE and EE are not typically OSGi compatible </li></ul><ul><li>EclipseLink provides a set of high performance and scalable Java persistence services for OSGi </li></ul>
    3. 3. Java Persistence: The Problem Space Customer id: int name: String creditRating: int CUST ID NAME C_RATING <customer id=“…”> <name>…</name> … </contact-info> </customer> Relational XML Java
    4. 4. Java Persistence Standards <ul><li>Object-Relational: Java Persistence API (JPA) </li></ul><ul><ul><li>JPA 1.0 part of EJB 3.0 standard (JSR 220) </li></ul></ul><ul><ul><li>JPA 2.0 independent standard (JSR 317) </li></ul></ul><ul><li>Object-XML: Java Architecture for XML Binding (JAXB) </li></ul><ul><ul><li>JAXB 2.x standardized in JSR 222 </li></ul></ul><ul><li>Object-XML: Service Data Objects </li></ul><ul><ul><li>SDO 2.1.1 standardized in JSR 235 </li></ul></ul>
    5. 5. EclipseLink Architecture DBWS SDO EIS MOXy JPA XML Data Legacy Systems Databases Java SE Java EE OSGi Spring
    6. 6. EclipseLink Background <ul><li>EclipseLink </li></ul><ul><ul><li>Official name &quot;Eclipse Persistence Services Project&quot; </li></ul></ul><ul><ul><li>Founding Eclipse Runtime Project member </li></ul></ul><ul><li>Lead by Oracle </li></ul><ul><li>Founded upon contribution of full TopLink source </li></ul><ul><li>Code base with 12 years of commercial usage </li></ul><ul><li>First comprehensive open source persistence solution </li></ul>
    7. 7. EclipseLink Distributions <ul><li>Eclipse </li></ul><ul><li>Oracle </li></ul><ul><ul><li>TopLink 11g </li></ul></ul><ul><ul><li>WebLogic Server </li></ul></ul><ul><li>Sun GlassFish v3 (SunAS) </li></ul><ul><ul><li>Replaces TopLink Essentials (JPA 2.0 Reference Implementation) </li></ul></ul><ul><li>Spring Source </li></ul><ul><ul><li>Spring Framework </li></ul></ul><ul><ul><li>Spring OSGi Bundle Repository </li></ul></ul><ul><li>JOnAS Application Server 5.1 </li></ul>
    8. 8. EclipseLink JPA <ul><li>JPA 1.0 compliant implementation </li></ul><ul><li>Delivering the JPA 2.0 Reference Implementation </li></ul><ul><li>Java EE, Java SE, Web, Spring, and OSGi </li></ul><ul><li>Any JDBC/SQL compliant database </li></ul><ul><li>Extensible and pluggable </li></ul><ul><li>Schema generation </li></ul><ul><li>Key infrastructure: </li></ul><ul><ul><li>Caching, Locking, Query Framework, Mapping, … </li></ul></ul><ul><li>… plus many valuable advanced features </li></ul>
    9. 9. EclipseLink MOXy <ul><li>Provides complete Object-XML mapping </li></ul><ul><ul><li>Allows developers to work with XML as objects </li></ul></ul><ul><ul><li>Efficiently produce and consume XML </li></ul></ul><ul><li>Supports Object-XML binding standard - JAXB </li></ul><ul><li>Provides external mapping file for complete control on how objects are mapped </li></ul>domain model XML Data
    10. 10. EclipseLink SDO <ul><li>SDO 2.1 provides the ability to: </li></ul><ul><ul><li>Generate Java SDO classes (static SDOs) from an XML Schema. </li></ul></ul><ul><ul><li>Generate SDO Types and Properties at runtime from an XML Schema to create dynamic SDOs. </li></ul></ul><ul><ul><li>Generate an XML schema that corresponds to the types and properties of an SDO model. </li></ul></ul><ul><ul><ul><li>This allows XML payloads in, for example, web services to include the schema that they conform to making the payload contents fully self describing. </li></ul></ul></ul><ul><ul><li>Capture and marshal to XML the set of changes made to an SDO object graph in an SDO Change Summary. </li></ul></ul>
    11. 11. EclipseLink OSGi Packaging <ul><li>EclipseLink is available as a set of OSGi bundles: </li></ul><ul><ul><li>JPA </li></ul></ul><ul><ul><ul><li>org.eclipse.persistence.jpa—JPA implementation </li></ul></ul></ul><ul><ul><ul><li>org.eclipse.persistence.antlr—JPQL parsing </li></ul></ul></ul><ul><ul><ul><li>org.eclipse.persistence.asm—Byte code weaving </li></ul></ul></ul><ul><ul><li>MOXy JAXB </li></ul></ul><ul><ul><ul><li>org.eclipse.persistence.moxy—OXM/JAXB implementation </li></ul></ul></ul><ul><ul><li>SDO </li></ul></ul><ul><ul><ul><li>org.eclipse.persistence.sdo—SDO implementation </li></ul></ul></ul><ul><ul><li>Core (used by all persistence services) </li></ul></ul><ul><ul><ul><li>org.eclipse.persistence.core—shared infrastructure </li></ul></ul></ul>
    12. 12. OSGi Persistence Goal <ul><li>Support usage of standard APIs </li></ul><ul><ul><li>javax.persistence.Persistence.createEntityManagerFactory(..) </li></ul></ul><ul><ul><li>javax.xml.bind.JAXBContext.newInstance(..) </li></ul></ul><ul><ul><li>commonj.sdo.HelperProvider </li></ul></ul><ul><li>Support modular packaging </li></ul><ul><ul><li>E.g., domain model bundle(s), meta-data bundle, provider bundles </li></ul></ul><ul><li>Decouple application from provider </li></ul><ul><ul><li>Use JPA resolution to find suitable provider </li></ul></ul><ul><ul><li>Use JPA standard <provider> tag in persistence.xml to identify specific provider—no provider specific require-bundle or import-package </li></ul></ul>
    13. 13. OSGi Persistence Challenges <ul><li>JPA </li></ul><ul><ul><li>javax.persistence.Persistence SPI scans classpath for providers </li></ul></ul><ul><ul><li>Provider needs access to domain model classes and application resources </li></ul></ul><ul><ul><li>Needs access to JDBC driver (addressed by RFC 122) </li></ul></ul><ul><li>JAXB </li></ul><ul><ul><li>Spec SPI does not support registration of providers </li></ul></ul><ul><ul><li>Provider needs access to domain model classes and application resources </li></ul></ul><ul><ul><li>Spec supports passing domain model classloader </li></ul></ul><ul><li>SDO </li></ul><ul><ul><li>Spec hardwires provider class and package—doesn't support multiple providers. </li></ul></ul>
    14. 14. JPA—Bootstrap Problem <ul><li>Persistence finds providers by loading all javax.persistence.spi .PersistenceProvider .xml files on classpath—but in OSGi it can’t see any. </li></ul>javax.persistence Eclipselink JPA PersistenceProvider.xml Persistence requires
    15. 15. JPA—Service Based Solution <ul><li>OSGi aware javax.persistence bundle that allows providers to register a persistence provider service. </li></ul><ul><li>When a provider bundle is started it registers with javax.peristence </li></ul><ul><li>When javax.persistence .Persistence is asked for a persistence unit it can ask registered providers to supply it. </li></ul>javax .persistence PersistenceProvider register Providers Eclipselink JPA
    16. 16. JPA—Resource Access Problem <ul><li>EclipseLink’s Persistence Provider can’t see persistence.xml, orm.xml , or Entities in PU bundle. </li></ul>Eclipselink JPA persistence unit bundle persistence.xml orm.xml,…
    17. 17. JPA—Extender Pattern Solution <ul><li>EclipseLink JPA uses extender pattern to identify persistence unit bundles. </li></ul><ul><li>EclipseLink keeps track of what persistence units are associated with what bundles (and what classloaders) </li></ul>persistence unit bundle persistence.xml orm.xml,… bundle event OSGi Eclipselink JPA
    18. 18. Demo
    19. 19. EclipseLink Weaving Support <ul><li>Uses (ASM) to introduce additional functionality into the ‘POJO’ domain classes </li></ul><ul><li>Used for </li></ul><ul><ul><li>M:1 and 1:1 lazy fetching </li></ul></ul><ul><ul><li>Fetch Groups </li></ul></ul><ul><ul><li>Change Tracking </li></ul></ul><ul><ul><li>State Caching </li></ul></ul><ul><li>Use is Optional (used by default when possible) </li></ul><ul><li>Static weaving also supported </li></ul><ul><ul><li>Weaving of .class files before deployment </li></ul></ul><ul><li>Dynamic weaving supported in Equinox through Adaptor Hook framework </li></ul>
    20. 20. More Problems and Solutions <ul><li>JAXB OSGi </li></ul><ul><ul><li>Support usage of standard APIs </li></ul></ul><ul><ul><ul><li>javax.xml.bind.JAXBContext.newInstance(..) </li></ul></ul></ul><ul><ul><li>Support modular packaging </li></ul></ul><ul><ul><ul><li>E.g., domain model bundle(s), meta-data bundle, provider </li></ul></ul></ul><ul><ul><li>No dependency on specific provider </li></ul></ul><ul><ul><ul><li>JAXB SPI, unlike JPA, does not have a provider resolution mechanism that is OSGi friendly </li></ul></ul></ul><ul><ul><ul><li>Application must explicitly depend on specific provider </li></ul></ul></ul><ul><li>SDO OSGi </li></ul><ul><ul><li>Support usage of standard commonj.sdo.HelperProvider </li></ul></ul><ul><ul><ul><li>Application must use provider specific HelperProvider </li></ul></ul></ul>
    21. 21. Future Plans and Goals <ul><li>Investigate further bundle splitting </li></ul><ul><ul><li>As required by usage scenarios </li></ul></ul><ul><li>Participate on development of OSGi RFC 143 JPA Integration </li></ul><ul><ul><li>Weaving </li></ul></ul><ul><ul><li>Container vs. non-container API </li></ul></ul><ul><ul><li>JPA packaging configurations </li></ul></ul><ul><li>Participate on JAXB and SDO expert groups to better support OSGi </li></ul><ul><li>Usability </li></ul><ul><ul><li>Documentation and Examples </li></ul></ul>
    22. 22. Summary <ul><li>OSGi presents challenges when trying to use many frameworks built for Java SE/EE environments. </li></ul><ul><li>Before you commit to a framework you must evaluate whether it is OSGi friendly. </li></ul><ul><li>EclipseLink is the only comprehensive persistence framework shipping with support for OSGi! </li></ul>
    1. A particular slide catching your eye?

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

    ×