Top Banner
<Insert Picture Here> SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB
30

SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Dec 17, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

<Insert Picture Here>

SDO 3.0 – Enhancing the APIBlaise DoughanTeam Lead, Oracle TopLink OXM/SDO/JAXBTeam Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB

Page 2: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Agenda

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Page 3: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Java EE – The Competing Technology

XML

DocumentRelational

DBObjectsOXM ORM

JAXB/JAX-WS JPA/EJB

Some vendors are providing extensions to the above specifications to better meet customer needs.

Page 4: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Data

DB

Java EE – The Companion Technology

Java EE

Objects JAXB

Java EE

ObjectsJAXBXML

JPA

SCA

Data

ObjectsSDO

SCA

Data

ObjectsSDO

Data

Graph

Page 5: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Agenda

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Page 6: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Object vs. DataObject

JAXB SDO

Primitive Types Supports all Java primitive types.

Supports some Java primitive types.

Portability Portable across all vendor implementations.

Interfaces are portable, and impl classes are not.

Serialization Easily serializable. Easily serializable only when using static INSTANCE helpers

Property Restrictions

Cannot have a property called “class” due to the Java language.

Cannot have an additional 8 properties due to the DataObject interface.

Bytecode Technologies

Easy to use with byte code manipulation technologies.

Difficult to use at least in a vendor neutral way.

Page 7: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Java SE 5 – DataObject get*/set* APIs

Proposed by Ron Barrack, SAP

We could take advantage of Java SE 5 to reduce the number of methods on the

DataObject interface.

get* (Could reduce 39 methods to 3 methods)• <T> T get(Class<T> targetClass, String path);• <T> T get(Class<T> targetClass, int propertyIndex);• <T> T get(Class<T> targetClass, Property property);

set* (Could reduce 39 methods to 3 methods)• <T> void set(Class<T> targetClass, String path, T value);• <T> void set(Class<T> targetClass, int propertyIndex, T value);• <T> void set(Class<T> targetClass, Property property, T value);

Page 8: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Java SE 5 – DataObject List APIs

Proposed by Ron Barrack, SAP

We could take advantage of Java SE 5 to enhance the List methods on the

DataObject interface.

getList• <T> List<T> getList(Class<T> elementClass, String path);• <T> List<T> getList(Class<T> elementClass, int propertyIndex);• <T> List<T> getList(Class<T> elementClass, Property property);

setList• <T> void setList(Class<T> targetClass, String path, List<T> value);• <T> void setList(Class<T> targetClass, int propertyIndex, List<T> value);• <T> void setList(Class<T> targetClass, Property property, List<T> value);

Page 9: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Performance – DataObject.get*(String)

get*(String path)

This API requires that the String be introspected in order to determine how to execute it.getFirstName() not comparable to get(“firstName”)

Page 10: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Performance – Containment (SDO-186)

Section 3.1.6

“Containment is managed. When a DataObject is set or added to a containment Property, it is removed from any previous containment Property. Containment cannot have cycles. If a set or add would produce a containment cycle, an exception is thrown.”

The above spec defined behaviour can be a big performance hit for deeply nested trees.

Page 11: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

isSet – isMany == true

SDO Properties Have an “isSet” ConceptcustomerDO.get(“phone-numbers”); // aList.size() > 0

customerDO.isSet(“phone-numbers”); // return true

SDO Does Not Track an Explicit ClearcustomerDO.get(“phone-numbers”).clear();

customerDO.get(“phone-numbers”); // return empty list

customerDO.isSet(“phone-numbers”); // return false

Page 12: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Read Only Properties

Proposal

Change this to be a hint instead of it actually preventing an update of a property.

Page 13: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Sequence (SDO-274)

The add APIs are not consistent:• public void add(int index, Property property, Object value)• public boolean add(Property property, Object value)

Change to remove API:• public void remove(int index)

Change this method to be consistent with java.util.List and return the Object that was removed.

Page 14: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Agenda

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Page 15: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Eating our own Dog Food

Why aren’t we using SDO to implement SDO?

• DataGraph (commonj.sdo)• Type (commonj.sdo)• Property (commonj.sdo) • XMLDocument (commonj.sdo.helper) • XMLHelper (commonj.sdo.helper) load & save

• The load and save operations take an java.lang.Object parameter to represent options. Why isn’t this parameter a DataObject?

Page 16: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Type & Property as DataObject

SDO-252 – Clarify behavior when storing Type /

Property as a value in a DataObject• If you mark a Property as Type commonj.sdo.Type

can I store an implementation of commonj.sdo.Type on it and/or a DataObject of Type commonj.sdo.Type?

• If you can create a Data Objects for Type and Property should I be able to use the XML representation to populate TypeHelper?

Page 17: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Type & Property as DataObjectsThe Pain Points

• Conflicts between existing API• Property.getType()

• If the property represented a Customer’s first name, this method would probably return the Type commonj.sdo.Type.

• DataObject.getType()• As a DataObject Property would need to return the Type

commonj.sdo.Property.

• Type & Property are currently read-only. They would need to be read/write to work with TypeHelper.

Page 18: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Property – Namespace URIs (SDO-66)

Oracle Requirements:

1. Loading an XML Schema with no target namespace should result in registered global properties.

2. If no Types or Property objetcs are defined the user should be able to create a namespace qualified XML document.

Page 19: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Common Root Class (SDO-257)

• Impact on Simple Types (SDO-264)

Page 20: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Section 9.10 – XML without Schema

• The algorithm here necessitates a sequenced and open Type with no defined Properties to be used.

• Currently this Type is vendor specific, I propose we add a defined Type to the spec.

Page 21: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Unfinished Items

• Multiple Inheritance• No XML Representation• Cannot be serialized (due to above)

• Helper Context• Added late in SDO 2.1• No standard way to create them• Problems related to serialization

Page 22: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Agenda

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Page 23: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

JAXB Runtime vs. SDO Runtime

JAXBContext• Fixed• No programmatic way to

generate XML Schema

Marshaller• Multiple marshal targets• Standard options

Unmarshaller• Multiple unmarshal sources• Standard options

XSDHelper & TypeHelper• Dynamic• Programmatic way to

generate XML Schema

XMLHelper• Limited marshal targets• No standard options

XMLHelper• Limited unmarshal sources• No standard options

Page 24: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Specifying Vendor Implementations

Currently in Java there can only be one SDO implementation

available in a VM.

From commonj.sdo.helper.impl:

public abstract class HelperProvider {

static HelperProvider INSTANCE = getHelperProviderImpl(); 

static HelperProvider getHelperProviderImpl() {

return (HelperProvider)

Class.forName("commonj.sdo.impl.HelperProviderImpl")

.newInstance();

}

}

Page 25: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Date/Time Handling (SDO-46)

• SDO-214

Page 26: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Agenda

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Page 27: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Expected Behaviour (Example SDO-255)

In my opinion we are not consistent with our handling of error

conditions. In some circumstances we throw an exception, and

in other cases we try to continue. In many cases it is undefined.

Option #1 – Throw Exceptions

For example in the case where an undefined property is asked for throw an Exception.

Option #2 – Avoid Exceptions

If an undefined property is asked for assume the user meant to have a property by this name and create one automatically.

Page 28: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Standard Exceptions (SDO-105)

It is common for Java EE technologies to throw a common exception. Clearly identifying the layer that encountered the problem:• javax.xml.bind.JAXBException (JAXB)• javax.persistence.PersistenceException (JPA)

Many SDO runtime methods necessitate vendor specific

runtime exceptions, others mandate confusing Java SE

exceptions.• java.lang.ClassCastException• java.lang.UnsupportedOperationException

Page 29: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.

Summary

Java EE

Model Classes

Metadata Classes

Runtime Classes

Error Handling

Unfinished Items

Page 30: SDO 3.0 – Enhancing the API Blaise Doughan Team Lead, Oracle TopLink OXM/SDO/JAXB Team Lead, Eclipse Persistence Services (EclipseLink) OXM/SDO/JAXB.