Title: SDO 3.0 Enhancing the API
1SDO 3.0 Enhancing the API
- Blaise Doughan
- Team Lead, Oracle TopLink OXM/SDO/JAXB
- Team Lead, Eclipse Persistence Services
(EclipseLink) OXM/SDO/JAXB
2Agenda
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
3Java EE The Competing Technology
4Java EE The Companion Technology
5Agenda
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
6Object vs. DataObject
7Java 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)
- ltTgt T get(ClassltTgt targetClass, String path)
- ltTgt T get(ClassltTgt targetClass, int
propertyIndex) - ltTgt T get(ClassltTgt targetClass, Property
property) - set (Could reduce 39 methods to 3 methods)
- ltTgt void set(ClassltTgt targetClass, String path, T
value) - ltTgt void set(ClassltTgt targetClass, int
propertyIndex, T value) - ltTgt void set(ClassltTgt targetClass, Property
property, T value)
8Java 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
- ltTgt ListltTgt getList(ClassltTgt elementClass, String
path) - ltTgt ListltTgt getList(ClassltTgt elementClass, int
propertyIndex) - ltTgt ListltTgt getList(ClassltTgt elementClass,
Property property) - setList
- ltTgt void setList(ClassltTgt targetClass, String
path, ListltTgt value) - ltTgt void setList(ClassltTgt targetClass, int
propertyIndex, ListltTgt value) - ltTgt void setList(ClassltTgt targetClass, Property
property, ListltTgt value)
9Performance 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)
10Performance 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.
11isSet isMany true
- SDO Properties Have an isSet Concept
- customerDO.get(phone-numbers) // aList.size()
gt 0 - customerDO.isSet(phone-numbers) // return true
- SDO Does Not Track an Explicit Clear
- customerDO.get(phone-numbers).clear()
- customerDO.get(phone-numbers) // return empty
list - customerDO.isSet(phone-numbers) // return
false
12Read Only Properties
- Proposal
- Change this to be a hint instead of it actually
preventing an update of a property.
13Sequence (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.
14Agenda
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
15Eating our own Dog Food
- Why arent 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 isnt this parameter a DataObject?
16Type 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?
17Type Property as DataObjectsThe Pain Points
- Conflicts between existing API
- Property.getType()
- If the property represented a Customers 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.
18Property Namespace URIs (SDO-66)
- Oracle Requirements
- Loading an XML Schema with no target namespace
should result in registered global properties. - If no Types or Property objetcs are defined the
user should be able to create a namespace
qualified XML document.
19Common Root Class (SDO-257)
- Impact on Simple Types (SDO-264)
20Section 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.
21Unfinished 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
22Agenda
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
23JAXB 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
24Specifying 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.HelperPro
viderImpl") - .newInstance()
-
-
25Date/Time Handling (SDO-46)
26Agenda
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
27Expected 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.
28Standard 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
29Summary
- Java EE
- Model Classes
- Metadata Classes
- Runtime Classes
- Error Handling
- Unfinished Items
30(No Transcript)