Eclipse Persistence Services The Full Monty Mike Keith

  • Slides: 39
Download presentation
Eclipse Persistence Services The Full Monty Mike Keith michael. keith@oracle. com http: //www. eclipse.

Eclipse Persistence Services The Full Monty Mike Keith michael. keith@oracle. com http: //www. eclipse. org/eclipselink

About Me • 15+ years experience in server-side and persistence implementations • Persistence/Container Architect

About Me • 15+ years experience in server-side and persistence implementations • Persistence/Container Architect for Oracle • Active member of multiple JCP expert groups, including Java EE 6, EJB 3. 1 and JPA 2. 0 • Co-wrote Pro EJB 3: Java Persistence API • Contributer to SCA, SDO and DAS groups within OSOA and OASIS • Frequent presenter at numerous conferences and events

What will you learn? • What the Eclipse Persistence Services Project is • Why

What will you learn? • What the Eclipse Persistence Services Project is • Why this project exists, and why you should care • Where the project is situated in the context of the entire Eclipse ecosystem • How this project can be used, and how you can benefit from it • Who is involved (and how you can be too!)

What is Eclipse? • Eclipse is an open source community • Eclipse is more

What is Eclipse? • Eclipse is an open source community • Eclipse is more then just an IDE Ø Equinox (OSGi), Rich Client Platform (RCP), Higgins (Trust Framework), … Ø Incubating • Maya (Deployment Framework) • Persistence Services Project (Eclipse. Link) Ø Proposals • SOA, Rich Server Platform, …

Why Eclipse? • Eclipse has a strong and vibrant community with an effective governance

Why Eclipse? • Eclipse has a strong and vibrant community with an effective governance model • Good reputation for quality • Interest from within the Eclipse ecosystem • Oracle has had a positive experience with its existing participation in Eclipse projects Ø Projects lead by Oracle: Dali, BPEL, JSF Ø Other Oracle contributions: WTP and DTP

Eclipse Persistence Services • Eclipse runtime project Ø Nicknamed “Eclipse. Link” Ø Currently Incubating

Eclipse Persistence Services • Eclipse runtime project Ø Nicknamed “Eclipse. Link” Ø Currently Incubating in Technology Project • Comprehensive Ø Eclipse JPA: Object-Relational Ø Eclipse MOXy: Object-XML Ø Eclipse SDO: Service Data Objects Ø Eclipse DBWS: Database Web Services Ø Eclipse EIS: Non-Relational using JCA • Defining blueprints for OSGi persistence services

Java SE, Java EE, SCA, Spring, OSGi JPA MOXy SDO EIS DBWS Eclipse Persistence

Java SE, Java EE, SCA, Spring, OSGi JPA MOXy SDO EIS DBWS Eclipse Persistence Services (Eclipse. Link) JCA JDBC Relational Databases XML Packaged Apps Legacy Systems

Oracle Top. Link

Oracle Top. Link

Importance • First comprehensive open source persistence solution Ø Object-Relational and much more •

Importance • First comprehensive open source persistence solution Ø Object-Relational and much more • Based upon product with 12 years of commercial usage • Shared infrastructure Ø Easily share the same domain model with multiple persistence technologies Ø Leverage metadata for multiple services • Important part of the Eclipse Ecosystem

Eclipse JPA • • • JPA 1. 0 compliant implementation Java EE, Java SE,

Eclipse JPA • • • JPA 1. 0 compliant implementation Java EE, Java SE, Web, Spring, and OSGi Any JDBC/SQL compliant database Extensible and pluggable Schema generation Key infrastructure: Ø Caching, Locking, Query Framework, Mapping, … • … plus many valuable advanced features

Eclipse. Link Caching • Entity caching Ø L 2 shared across transactions/users Ø Coordination

Eclipse. Link Caching • Entity caching Ø L 2 shared across transactions/users Ø Coordination in a clustered deployment • Application specific configuration Ø Cache isolation: per client (EM) or shared Ø Cache Type and Size: Weak, Soft-Weak, Full, None Ø Expiration/Invalidation • Time to live, Time of day, API Ø Coordination (cluster-messaging) • Messaging: JMS, RMI, CORBA, RMI-IIOP, … • Mode: SYNC, SYNC+NEW, INVALIDATE, NONE

Caching Architecture Entity. Manager Unit. Of. Work Session TX Cache Isolated Cache Entity. Manager

Caching Architecture Entity. Manager Unit. Of. Work Session TX Cache Isolated Cache Entity. Manager Factory Server Shared Cache Coordination JMS (MDB) RMI CORBA IIOP

Configuring the Cache • Default: objects read are cached and trusted • Configuration by

Configuring the Cache • Default: objects read are cached and trusted • Configuration by entity type important Ø Volatility of data Ø Shared usage of data • Configuration Parameters Ø Cache isolation, type, size, expiry, coordination Ø Refreshing • By query (use-case) or descriptor (always) • Locking is the only way to avoid potential data corruption in concurrent write scenarios

Locking • Prevent data corruption !!! • Java Developers think of locking at the

Locking • Prevent data corruption !!! • Java Developers think of locking at the object level • Databases may need to manage locking across many applications • Eclipse. Link is able to respect and participate in locks at database level Ø Optimistic: Numeric, Timestamp, All fields, Selected fields, Changed field Ø Pessimistic

Query Framework • Queries can be defined using Ø Entity Model: JPQL, Expressions, Query-by-example

Query Framework • Queries can be defined using Ø Entity Model: JPQL, Expressions, Query-by-example Ø Database: SQL, Stored Procedures • Customizable Ø Locking, Cache Usage, Refreshing Ø Optimizations: Joining, Batching, parameter binding Ø Result shaping/conversions • Static or Dynamic Ø Stored Procedure support

Eclipse. Link JPA Extensions • Extensions applied using annotations or XML • Mappings Ø

Eclipse. Link JPA Extensions • Extensions applied using annotations or XML • Mappings Ø @Basic. Map, @Basic. Collection, @Private. Owned, @Join. Fetch Ø @Converter, @Type. Converter, @Object. Type. Converter • @Cache Ø type, size, isolated, expiry, refresh, cache usage, coordination Ø Cache usage and refresh query hints • @Named. Stored. Procedure. Query Ø IN/OUT/INOUT parameters, multiple cursor results

Eclipse. Link JPA Extensions • Locking Ø Non-intrusive policies @Optimistic. Locking Ø Pessimistic query

Eclipse. Link JPA Extensions • Locking Ø Non-intrusive policies @Optimistic. Locking Ø Pessimistic query hints • JDBC Connection Pooling • Logging: Diagnostics, SQL, Debugging • Weaving for lazy fetch and change tracking Ø Dynamic and Static • Customization Ø Entity Descriptor: @Customizer, @Read. Only Ø Session Customizer

Mapping Extensions @Entity @Cache(type=SOFT_WEAK, coordination. Type=SEND_OBJECT_CHANGES) @Optimistic. Locking(type=CHANGED_COLUMNS) @Converter(name=“money”, converter. Class=Money. Converter. class) public

Mapping Extensions @Entity @Cache(type=SOFT_WEAK, coordination. Type=SEND_OBJECT_CHANGES) @Optimistic. Locking(type=CHANGED_COLUMNS) @Converter(name=“money”, converter. Class=Money. Converter. class) public class Employee { @Id private int id; private String name; @One. To. Many(mapped. By=“owner”) @Private. Owned private List<Phone. Numbers> phones; @Convert(“money”) private Money salary … }

Database Platform • Native SQL (dialect) support with custom operators • Stored Procedure &

Database Platform • Native SQL (dialect) support with custom operators • Stored Procedure & Function • Extensible Advanced Data Types support (Struct) • Database Security Ø Oracle DB’s VPD/OLS and Proxy Authentication • Configurable value return from write • Supported platforms (default = Auto) Ø My. SQL, Derby, Oracle, DB 2, Sybase, SQLServer, Times. Ten, Postgre. SQL, SQLAny. Where, HSQL, Informix, …

Server Platform • Simplified configuration and mediator for host container environment • Enables Ø

Server Platform • Simplified configuration and mediator for host container environment • Enables Ø Ø Direct JTA integration Data Source/JDBC connection un-wrapping JMX MBean deployment Logging integration • Current Server Platforms Ø Sun. AS/Glass. Fish, Oracle. AS/OC 4 J, WLS, WAS, JBoss

Performance and Tuning • Highly configurable and tunable Ø Principle: minimize and optimize database

Performance and Tuning • Highly configurable and tunable Ø Principle: minimize and optimize database calls Ø Enable application specific tuning • Flexibility allows efficient business models and relational schemas to be used • Leverages underlying performance tuning features Ø Java, JDBC and the underlying database technology

Eclipse. Link JPA Configuration • JPA (portable) Ø persistence. xml with Eclipse. Link properties

Eclipse. Link JPA Configuration • JPA (portable) Ø persistence. xml with Eclipse. Link properties Ø Mapping: Annotations and/or orm. xml Ø Query hints • Eclipse. Link Ø Sessions Configuration (sessions. xml) Ø Mapping using XML or Code • Eclipse JPA Ø JPA + Eclipse. Link configurations options Ø Eclipse. Link annotations

Eclipse MOXy • Provides complete Object-XML mapping Ø Allows developers to work with XML

Eclipse MOXy • Provides complete Object-XML mapping Ø Allows developers to work with XML as objects Ø Efficiently produce and consume XML Ø Document Preservation • Supports Object-XML standard - JAXB Ø Provides additional flexibility to allow complete control on how objects are mapped domain model XML Data

Eclipse MOXy Benefits • Rich set of mappings providing complete control and flexibility to

Eclipse MOXy Benefits • Rich set of mappings providing complete control and flexibility to map objects to any XSD Ø Direct, composite object, composite collection, inheritance, positional, path, transformation …. • Development Approaches Ø Model + Annotations XSD Ø XSD Model + Annotations Ø Model + Mappings(Annotations or XML) • Supports any JAXP compliant parser Ø SAX, DOM, St. AX • Visual Mapping support using Workbench

Eclipse MOXy: JAXBContext ctx = JAXBContext. new. Instance(classes); Marshaller marshaller = ctx. create. Marshaller();

Eclipse MOXy: JAXBContext ctx = JAXBContext. new. Instance(classes); Marshaller marshaller = ctx. create. Marshaller(); Customer customer = new Customer(); customer. set. First. Name("William"); customer. set. Last. Name("Gibson"); marshaller. marshal(customer, System. out); jaxb. properties: javax. xml. bind. context. factory = org. eclipse. persistence. jaxb. JAXBContext. Factory

Eclipse DBWS • Simplified and efficient access to relational data through Web Services •

Eclipse DBWS • Simplified and efficient access to relational data through Web Services • Minimal configuration with development utilities to retrieve metadata and generate/package Web Service • Developers can fully customize the database access and XML mapping of the data • Ideal for usage within SOA/SCA

Eclipse DBWS OR-Map OX-Map (XML) Web Service DBWS Specification ANT Java XR Service (XML)

Eclipse DBWS OR-Map OX-Map (XML) Web Service DBWS Specification ANT Java XR Service (XML) Eclipse. Link DBWS Data Source import definitions RDBMS development runtime

Eclipse SDO • What can you do? Ø Marshall/Unmarshall objects to/from XML Ø Define

Eclipse SDO • What can you do? Ø Marshall/Unmarshall objects to/from XML Ø Define Types/Properties programmatically or derive from XSD Ø Generate Java. Bean classes from XSD Ø Advanced mapping support for greater flexibility • Why would you use it? Ø Ø Schema/Structure unknown at compile time Declarative metadata based tools/frameworks XML-centric applications, need open content support Dynamic content user interfaces

Eclipse EIS • Provide persistence support for non-relational data stores using Java EE Connector

Eclipse EIS • Provide persistence support for non-relational data stores using Java EE Connector Architecture (JCA) • Mapping interaction inputs and outputs to persistent domain model Ø XML mapping leveraging Eclipse MOXy Ø Common Client Interface (CCI) mapping • Visual mapping Workbench support • Out of the box support for: Ø MQSeries, Oracle. AQ, Sun JCA, XML Files

Eclipse. Link and OSGi • Work with OSGi expert group to define OSGi persistence

Eclipse. Link and OSGi • Work with OSGi expert group to define OSGi persistence services blueprint • Deliver Eclipse. Link as OSGi bundle(s) • Show through examples how to leverage within an OSGi solution • Address technical challenges as a community

Combining Services • Metadata based approach allows the same domain model to be mapped

Combining Services • Metadata based approach allows the same domain model to be mapped with multiple persistence services Ø Supports usage within Web Services / SOA / SCA Ø Domain model can be shared between persistence services (JPA, MOXy, EIS) Ø Transformations are bidirectional: • Unmarshall XML to objects and then persist • Marshall persistent objects to XML

Common Domain Model Schema-1 Ec lip se L ink L se p cli k

Common Domain Model Schema-1 Ec lip se L ink L se p cli k MO Xy Xy O domain M k model in in L e A JP Schema-3 ps i l c E Ecli pse Lin k JP A E Schema-2 Schema-4

Eclipse. Link and Spring • Eclipse JPA Ø Container integration Ø POP (Plain Old

Eclipse. Link and Spring • Eclipse JPA Ø Container integration Ø POP (Plain Old Persistence) API Ø DAO Template approach • Eclipse. Link Native ORM Template • Eclipse MOXy Ø Direct, Spring WS, Spring Remoting, … • and many more possibilities… Ø Spring Batch, Spring OSGi, …

Eclipse JPA and Spring @Repository @Transactional public class Entity. Manager. Clinic implements Clinic {

Eclipse JPA and Spring @Repository @Transactional public class Entity. Manager. Clinic implements Clinic { @Persistence. Context private Entity. Manager em; public Collection<Owner> find. Owners(String last. Name) throws Data. Access. Exception { Query query = em. create. Named. Query(“Employee. find. Owners"); query. set. Parameter("last. Name", last. Name + "%"); return query. get. Result. List(); }

Part of the Eclipse Ecosystem • Provide an Eclipse persistence solution easily consumable by

Part of the Eclipse Ecosystem • Provide an Eclipse persistence solution easily consumable by any project Ø Storage of metadata in RDBMS, XML, EIS Ø XML Messaging infrastructure • Eclipse Projects Ø Ø Dali JPA Tooling Project Teneo to use Eclipse. Link for EMF model persistence Maya for storage of deployment configuration SOA Project for Eclipse. Link SDO

Where are we going? • Delivery of initial 0. 1 -incubation milestone Ø Build

Where are we going? • Delivery of initial 0. 1 -incubation milestone Ø Build and testing processes Ø Initial contribution functional Ø Spring Framework support • • • Specifications: JAXB 2. 0, SDO 2. 1, JPA 2. 0 OSGi packaging and usage examples Database Web Services (DBWS) Data Access Service (DAS) - SDO with JPA Simplified Data. Map Access and Dynamic Persistence

How can you get involved? • Users Ø The 0. 1 -incubation milestone will

How can you get involved? • Users Ø The 0. 1 -incubation milestone will be available soon Ø Try it out and provide feedback Ø File bug reports and feature requests • Contributors Ø Contribute to roadmap discussions Ø Bug fixes • Committers Ø Very interested in growing committer base

Eclipse. Link Summary • First comprehensive Open Source Persistence solution Ø Eclipse JPA: Object-Relational

Eclipse. Link Summary • First comprehensive Open Source Persistence solution Ø Eclipse JPA: Object-Relational Ø Eclipse MOXy: Object-XML Ø Eclipse SDO: Service Data Objects Ø Eclipse DBWS: Database Web Services Ø Eclipse EIS: Non-Relational using JCA • Mature and full featured • Get involved

More Information Project: www. eclipse. org/eclipselink Newsgroup: eclipse. technology. eclipselink Wiki: wiki. eclipse. org/index.

More Information Project: www. eclipse. org/eclipselink Newsgroup: eclipse. technology. eclipselink Wiki: wiki. eclipse. org/index. php/Eclipse. Link Committer Team Blog: eclipselink. blogspot. com