Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/SDO/Introduction to SDO (ELUG)"

m
m
Line 1: Line 1:
Information pending
 
<!--
 
  
 
This section introduces concepts of Service Data Objects (SDO) and provides general information on it.
 
This section introduces concepts of Service Data Objects (SDO) and provides general information on it.
Line 7: Line 5:
 
==What Is SDO?==
 
==What Is SDO?==
  
SDO is designed to be a unified view of data, much like the POJO is in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.
+
SDO is designed to be a unified view of data, similarly to POJO is in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.
  
 
You can use SDO to develop data-oriented applications. SDO includes an architecture and API.
 
You can use SDO to develop data-oriented applications. SDO includes an architecture and API.
Line 17: Line 15:
 
* [[#Disconnected Object|Disconnected Object]]  
 
* [[#Disconnected Object|Disconnected Object]]  
  
For more information, see ...
+
For more information, see (information pending).
  
  
  
 
===Dynamic Object Model===
 
===Dynamic Object Model===
 +
SDO metadata is represented as <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/Type.html Type]</tt> and <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/Property.html <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/Type.html Type]</tt>]</tt> objects. A <tt>Type</tt> is comparable to a Java class, and a <tt>Property</tt> - to a Java field. You define this metadata at run time either programmatically or from an XML schema, as follows:
  
SDO metadata is represented as Type and Property objects. A Type is comparable to a Java class, and a property to a Java field. This metadata is defined at run time either programmatically or from an XML schema, as follows:
+
  Type customerType = TypeHelper.INSTANCE.getType(“urn:example”, “customer”);
 
+
  Type customerType = TypeHelper.INSTANCE.getType(“urn:example”, “customer”);
+
 
  Property firstNameProperty = customerType.getProperty(“first-name”);
 
  Property firstNameProperty = customerType.getProperty(“first-name”);
 
   
 
   
 
  Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);
 
  Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);
 
   
 
   
Data is represented as instances of Types called DataObjects, these correspond to objects in Java.    DataObjects have many generic accessors that can be used to manipulate the data.
+
Data is represented as instances of <tt>Type</tt> called <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/DataObject.html DataObject]</tt>. The <tt>DataObject</tt> in SDO corresponds to a Java <tt>Object</tt> and have many generic accessors that you can use to manipulate the data, as the following example shows:
 
   
 
   
 
  DataObject customerDO = DataFactory.INSTANCE.create(customerType);
 
  DataObject customerDO = DataFactory.INSTANCE.create(customerType);
Line 37: Line 34:
 
  DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
 
  DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
 
  addressDO.set(“street”, “123 Any Street”);
 
  addressDO.set(“street”, “123 Any Street”);
 +
  
 
===Typed Object Model===
 
===Typed Object Model===
 
+
SDO as a dynamic object model is useful in certain frameworks based on the fact that dynamic models let you add metadata without requiring a redeployment of the application. However, in some cases a strongly typed model is required that allows for code completion in an IDE. You can perform a code generation step to produce typed interfaces complete with bean-style accessors, as the following example shows:
SDO as dynamic object models is useful in certain frameworks (dynamic models allow metadata to be added without requiring a redeployment of the application), but in other situations a strongly typed model is required (typed models allow for code completion in an IDE). A code generation step can be performed to produce typed interfaces complete with bean style accessors.
+
  
 
  Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
 
  Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
Line 47: Line 44:
  
 
===XML Representation===
 
===XML Representation===
 
+
SDO has a built-in support for handling XML. You can introspect the SDO metadata to determine the corresponding XML representation, as the following example shows:
SDO has built in support for handling XML. The SDO metadata can be introspected to determine what the corresponding XML representation is.
+
  
 
  XSDHelper.INSTANCE.isMixed(customerType);
 
  XSDHelper.INSTANCE.isMixed(customerType);
 
  XSDHelper.INSTANCE.isElement(firstNameProperty);
 
  XSDHelper.INSTANCE.isElement(firstNameProperty);
  
The DataObjects themselves can then be converted to and from XML.
+
You can then convert the <tt>DataObject</tt> instances to and from XML, as follows:
  
 
  XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);
 
  XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);
Line 59: Line 55:
  
 
===Disconnected Object===
 
===Disconnected Object===
 
+
SDO was designed to represent disconnected data in a Service Component Architecture (SCA) environment. You can do so by using the <tt>[[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/DataObject.html ChangeSummary]]</tt> that tracks changes made to data objects over time. Note that this applies to <tt>DataObject</tt> instances that have a <tt>ChangeSummary</tt> property. Consider the following example:
SDO was designed to represent disconnected data in a SCA (Service Component Architecture) environment. The main mechanism for accomplishing this goal is the ChangeSummary which tracks changes made to data objects over time (for DataObjects that have a ChangeSummary property).
+
  
 
  List changed = customerDO.getChangeSummary().getChangedDataObjects();
 
  List changed = customerDO.getChangeSummary().getChangedDataObjects();
  
EclipseLink is focussed on separating data from its messaging or persisted representations. Now with SDO support this data can be a POJO or a DataObject. This allows you to work with data in both Java EE and SCA environments.
+
EclipseLink is focussed on separating data from its messaging or persisted representations. With SDO support this data can be a POJO or a DataObject, which allows you to work with data in both Java EE and SCA environments.
-->
+
 
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
 
[[Category: Release 1.1]]
 
[[Category: Release 1.1]]
 
[[Category: SDO]]
 
[[Category: SDO]]

Revision as of 14:46, 23 April 2009

This section introduces concepts of Service Data Objects (SDO) and provides general information on it.


What Is SDO?

SDO is designed to be a unified view of data, similarly to POJO is in Java EE. There are several programming languages (of which Java is one) that support the SDO specification.

You can use SDO to develop data-oriented applications. SDO includes an architecture and API.

The following are possible expressions of SDO:

For more information, see (information pending).


Dynamic Object Model

SDO metadata is represented as Type and <tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.ecore.sdo.doc/references/javadoc/commonj/sdo/Type.html Type]</tt> objects. A Type is comparable to a Java class, and a Property - to a Java field. You define this metadata at run time either programmatically or from an XML schema, as follows:

Type customerType = TypeHelper.INSTANCE.getType(“urn:example”, “customer”);
Property firstNameProperty = customerType.getProperty(“first-name”);

Type addressType = TypeHelper.INSTANCE.getType(“urn:example”, “address”);

Data is represented as instances of Type called DataObject. The DataObject in SDO corresponds to a Java Object and have many generic accessors that you can use to manipulate the data, as the following example shows:

DataObject customerDO = DataFactory.INSTANCE.create(customerType);
customerDO.setString(firstNameProperty, “Jane”);
 
DataObject addressDO = DataFactory.INSTANCE.create(“urn:example”, address);
addressDO.set(“street”, “123 Any Street”);


Typed Object Model

SDO as a dynamic object model is useful in certain frameworks based on the fact that dynamic models let you add metadata without requiring a redeployment of the application. However, in some cases a strongly typed model is required that allows for code completion in an IDE. You can perform a code generation step to produce typed interfaces complete with bean-style accessors, as the following example shows:

Customer customerDO = (Customer) DataFactory.INSTANCE.create(customerType);
CustomerDO.setFirstName(“Jane”);


XML Representation

SDO has a built-in support for handling XML. You can introspect the SDO metadata to determine the corresponding XML representation, as the following example shows:

XSDHelper.INSTANCE.isMixed(customerType);
XSDHelper.INSTANCE.isElement(firstNameProperty);

You can then convert the DataObject instances to and from XML, as follows:

XMLHelper.INSTANCE.save(customerDO, “urn:example”, “customer”, System.out);


Disconnected Object

SDO was designed to represent disconnected data in a Service Component Architecture (SCA) environment. You can do so by using the [ChangeSummary] that tracks changes made to data objects over time. Note that this applies to DataObject instances that have a ChangeSummary property. Consider the following example:

List changed = customerDO.getChangeSummary().getChangedDataObjects();

EclipseLink is focussed on separating data from its messaging or persisted representations. With SDO support this data can be a POJO or a DataObject, which allows you to work with data in both Java EE and SCA environments.