• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Service Data Objects (SDO)

on

  • 1,666 views

 

Statistics

Views

Total Views
1,666
Views on SlideShare
1,665
Embed Views
1

Actions

Likes
0
Downloads
22
Comments
1

1 Embed 1

https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • thank you zubin its very useful for me , to know about Service data objects
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 50000 feet view
  • 25000 feet
  • Apache Tuscany has a RDB DAS Apache Directory is working on a LDAP DAS There are couple teams at IBM working on other DAS Implementations (e.g IMS team) SCA Partners have their own implementations as well
  • See more later – best practice pattern
  • Open the box and see what we have
  • Pick out gen classes and the fact that the impl implements DataObject
  • Containment Non containment Note use of ID to define unique reference
  • As distinct from generated classes shown before
  • Typed must be available for e.g. deserialization
  • DataObject instance doesn’t have a name or URI!
  • Just in time SDO info, to help with understanding of WSDL message body contents
  • This is an isMany = false example – integrity preserved for isMany = true also, e.g. if one of many children displaced by a List operation
  • Example of creating xml representation including change data
  • Basically, 2 capabilities are read and write … but in terms of SDOs
  • All this adds to our knowledge to date is that the DAS can be accessed via clients directly, or in an SCA environment by the DAS component.
  • Take entity bean and create an SDO session bean facade
  • Ongoing spec efforts

Service Data Objects (SDO) Service Data Objects (SDO) Presentation Transcript

  • Service Data Objects (SDO): Handling Data Consistently in a SOA Environment Kelvin Goodson, IBM UK – kelvin_goodson@uk.ibm.com SW Engineer Open Source SOA, Apache Tuscany © 2008 IBM Corporation
  • SDO 2.1 Spec Introduction
  • What are Service Data Objects?
    • Service Data Objects (SDO) provide:
      • Uniform access to data from heterogeneous sources
        • XML, RDB, EJB, LDAP, SOAP etc...
      • Has both static (strongly typed) and dynamic programming models
      • Disconnected “data graph” capable of tracking changes
      • Meta-data for easy introspection of data types
      • Relationship integrity enforcement
      • Language neutral APIs with implementations in Java, C++ and PHP
  • SDO for COBOL
  • Instance and Model
  • How do I store and retrieve SDOs ?
    • XML Documents
      • SDO specification describes serialisation to and de-serialisation from XML documents.
    • SDO specification discusses a Data Access Service (DAS)
      • DAS is a mediator between data sources and SDO applications
      • Apache Tuscany currently implements an RDB DAS, and some work done on an LDAP DAS
  • Combining SDO and DAS Change Summary Data Graph DataObject : EJB : Invoice EJB : Customer JDBC XPath / XQuery Local XML / HTTP CCI / Proprietary Data Access Service RDB XML DB Web service JCA SDO Client
  • Combining SDO with SCA
    • SCA is the component model
    • Components may be wired together
    • SDO DataObjects are data passed between and manipulated by Components
    • DAS is a SCA component with a special implementation type (implementation:das)
    Component Account Service Component Component Account DataService Component Service Account Service Reference StockQuote Service Composite AccountComposite Web Server .Net Web Service SCA SCA SCA SDO SDO SDO RDB
  • SDO Components and Key Features
    • Generated data API: POJO beans
    • Dynamic data API: DataObject
    • Change summary API: ChangeSummary
    • Introspection API: Type and Property
    • Sequence API where instance order is preserved
    • Relationship Integrity
    • XML and XSD Integration
      • XPath Navigation through Graphs of Data
    • XML-based serialization for transferring data sets on the wire
      • Can conform to pre-defined XML Schema
      • Can generate XML Schema
  • The Strongly Typed SDOs also Implement the Dynamic API
  • Static (Generated) Data API
    • POJO interfaces/classes
    • Strong-typed accessors
      • public interface Person {
      • String getName();
      • void setName(String name);
      • Address getAddress();
      • void setAddress(Address address);
      • }
      • Person p = (Person) dataFactory.create(Person.class);
      • p.setName("John");
      • Address a = (Address) dataFactory.create(Address.class);
      • p.setAddress(a);
    <complexType name=&quot;Person&quot;> <attribute name=&quot;name&quot; type=&quot;string&quot;/> <element name=“address&quot; type=“Address&quot;/> </complexType> <complexType name=“Address”> …
  • Dynamic Data API (commonj.sdo.DataObject)
    • The Dynamic SDO API provides a reflective way to introspect and manipulate data
      • Recall: Static SDO can be cast to DataObject
        • Customer c = CustomerFactory.createCustomer();
        • ((DataObject)c).setString(&quot;name&quot;, &quot;John&quot;); // Set name
    <complexType name=&quot;Person&quot;> <attribute name=&quot;name&quot; type=&quot;string&quot;/> <element name=“address&quot; type=“Address&quot;/> </complexType> <complexType name=“Address”> …
  • Example 1 – Accessing DataObjects // use SDO API to find the employee, at index 1 in the list. List departments = company.getList(&quot; departments &quot;); DataObject department = (DataObject) departments.get(0); List employees = department.getList(&quot; employees &quot;); DataObject employeeFromList = (DataObject) employees.get(1); DataObject employee = company.getDataObject (&quot; departments[1]/employees[2] &quot;); // Get an employee using an SDO xpath expression DataObject employee = company.getDataObject (“ departments[number=123]/employees[SN=0002] ”);
  • Example 2 – Updating DataObjects // create a new employee DataObject newEmployee = department.createDataObject(&quot; employees &quot;); newEmployee.set(&quot; name &quot;, &quot; Al Smith &quot;); newEmployee.set(&quot; SN &quot;, &quot; 0004 &quot;); newEmployee.setBoolean(&quot; manager &quot;, true ); // Set employeeOfTheMonth company.set(&quot; employeeOfTheMonth &quot;, newEmployee); company.setString(“ companyName &quot;, &quot; ACME &quot;); <company name=&quot;ACME&quot; employeeOfTheMonth=&quot;0004&quot;> <departments name=&quot;Advanced Technologies&quot; location=&quot;NY&quot; number=&quot;123&quot;> <employees name=&quot;John Jones&quot; SN=&quot;0001&quot;/> <employees name=&quot;Jane Doe&quot; SN=&quot;0003&quot;/> <employees name=&quot;Al Smith&quot; SN=&quot;0004&quot; manager=&quot;true&quot;/> </departments> </company>
  • SDO Meta-Model
    • SDO provides a simple, universal meta-model
      • Used across JavaBeans, XML, or any data source
      • Useful for tools and IDE’s (Model in MVC)
    • Meta-data Classes
      • Type
        • Has name, URI, instance class, and properties
      • Property
        • Has name, type, default value, etc.
        • DataObject obj = …;
        • Type type = obj.getType();
        • Collection c = type.getProperties();
        • Iterator i = c.iterator();
        • while (i.hasNext()) {
        • Property prop = (Property) i.next();
        • System.out.println(prop.getName());
        • }
    Element Attribute Field Property Type Class Type XSD Java SDO
  • Type System Scopes
    • HelperContext
      • Agent of scoping for Types
      • provides access to
        • TypeHelper
        • DataFactory
        • XSDHelper
        • XMLHelper
        • EqualityHelper
        • CopyHelper
        • DataHelper
      • HelperProvider.getDefaultContext()
      • Application can create new HelperContexts
  • XML/XSD integration
    • Key interfaces: XMLHelper and XSDHelper
    • Direct correspondence between XML and DataObjects
      • commonj.sdo.XMLHelper
        • Load and save DataObjects to XML streams
    • XSD mapping to and from SDO
      • commonj.sdo.XSDHelper
        • Get XML Schema specific information:
          • isElement, isMixed, local name, appinfo
      • Define Types and Properties from XSDs
        • Annotations or XSLT for mapping control
      • Generate XSDs from Types and Properties
  • Create SDO types from an XML schema
    • XSD model can be directly used to define SDO types
    • XSDHelper xsdHelper = …;
    • TypeHelper typeHelper = …;
    • // Populate the SDO types from the XSD
    • URL url = XMLSample.class.getResource(“/ stockquote.xsd ”);
    • InputStream inputStream = url.openStream();
    • xsdHelper.define(inputStream, url.toString());
    • inputStream.close();
    • // Look up the SDO Type
    • Type type = typeHelper.getType(“ http://stock ”, “ Quote ”);
    • // Get the XSD namespace URI for a SDO type
    • String ns = xsdHelper.getNamespaceURI(type);
  • Registering Type-System for SDO Runtime
    • Register types dynamically from XSD
    • Register types statically (strongly typed)
    Instance is still of type Employee -> Data Object instantiation: DataObject employee = dataFactory.create(NAMESPACE, “Employee”); -> Data Object instantiation: Employee empl = (Employee)dataFactory.create(Employee.class); Or DataObject empl = dataFactory.create(NAMESPACE, “Employee”);
  • CreateCompany Example
  • SDO API for Programatic Type Creation
    • Uses DataObject API
    • Build data graph describig Typs system – then compile
    • Type TypeHelper.define(DataObject)
    • List<Type> TypeHelper.define(List<DataObject>)
      • Permits circular references in metadata (Properties of Type as yet not “defined”)
    DataObject cType = scope.getDataFactory().create(&quot;commonj.sdo&quot;, &quot;Type&quot;); cType.set(&quot;uri&quot;, &quot;http://example.com/customer&quot;); cType.set(&quot;name&quot;, &quot;Customer&quot;); Type intType = typeHelper().getType(&quot;commonj.sdo&quot;, &quot;Int&quot;); DataObject cNumProperty = customerType.createDataObject(&quot;property&quot;); cNumProperty.set(&quot;name&quot;, &quot;custNum&quot;); cNumProperty.set(&quot;type&quot;, intType); …… Type registeredType = typeHelper.define(cType);
  • Load/Save XML documents
    • XMLHelper can load SDO from XML or save SDO to XML
    • DataObject quote = …;
    • XMLHelper xmlHelper = …;
    • ByteArrayOutputStream baos = new ByteArrayOutputStream();
    • // Save the data object as an XML document
    • xmlHelper.save(quote, &quot;http://www.example.com/simple&quot;, &quot;stockQuote&quot;, baos);
    • byte[] xml = baos.toByteArray();
    • // Load the XML bytes as an XMLDocument
    • XMLDocument document = xmlHelper.load(new ByteArrayInputStream(xml));
    • // Get the root DataObject
    • quote = document.getRootObject();
  • XML / SDO Mapping XML <purchaseOrder orderDate=&quot; 1999-10-20 &quot;> <shipTo country=&quot; US &quot;> <name> Alice Smith </name> <street> 123 Maple Street </street> <city> Mill Valley </city> <state> PA </state> <zip> 90952 </zip> </shipTo> ... </purchaseOrder> country= US name= Alice Smith street= 123 Maple Street city= Mill Valley state= PA zip= 90952 Values Properties orderDate= 1999-10-20 shipTo SDO PurchaseOrder Type USAddress Type
  • Use SDO to invoke a Web Service
    • Load the SOAP Envelope model from the XSD
    • // Create the helperContext
    • HelperContext helperContext = SDOUtil.createHelperContext();
    • // Load the soap envelope XSD
    • XSDHelper xsdHelper = helperContext.getXSDHelper();
    • URL xsd = SoapEnvelope.class.getClassLoader().getResource(&quot;soap-envelope.xsd&quot;);
    • InputStream xsdStream = xsd.openStream();
    • xsdHelper.define(xsdStream, null);
    • xsdStream.close();
    • // Load the WSDL model
    • URL wsdl = SoapEnvelope.class.getClassLoader().getResource(&quot;stockquote.wsdl&quot;);
    • InputStream wsdlStream = wsdl.openStream();
    • xsdHelper.define(wsdlStream, null);
    • wsdlStream.close();
  • Open Types
    • SDO “Open” Types
      • Type.isOpen()
      • Presence of <xsd:any/> implies Type.isOpen() = true
      • TypeHelper.defineOpenContentProperty(String, DataObject);
      • TypeHelper.getOpenContentProperty(“namespace”, “name”);
      • XSDHelper.getGlobalProperty(“namespace”, “name”)
    Property p = typeHelper.getOpenContentProperty( “ myExtraInfoUri”, “usefulData”); DataObject usefulExtraInfo = dataFactory.create(p.getType); … openDataObject.getList(p).add(usefulExtraInfo); assert usefulExtraInfo.getInstanceProperties().size() == usefulExtraInfo.getType().getProperties().size() +1;
  • Create and populate the SOAP message
    • Construct the SOAP Envelope as a DataObject
    • DataFactory dataFactory = helperContext.getDataFactory();
    • DataObject envelope = dataFactory.create(&quot;http://www.w3.org/2003/05/soap-envelope&quot;, &quot;Envelope&quot;);
    • DataObject header = envelope.createDataObject(&quot;Header&quot;);
    • DataObject body = envelope.createDataObject(&quot;Body&quot;);
    • Property prop = xsdHelper.getGlobalProperty(&quot;http://example.com/stockquote.xsd&quot;, &quot;getLastTradePrice&quot;, true); // is element
    • DataObject request = dataFactory.create(prop.getType());
    • request.setString(&quot;tickerSymbol&quot;, &quot;IBM&quot;);
    • body.getList(prop).add( request );
  • Producing the XML for the SOAP message
    • StringWriter writer = new StringWriter();
    • XMLHelper xmlHelper = helperContext.getXMLHelper();
    • XMLDocument doc = xmlHelper.createDocument(envelope, &quot;http://www.w3.org/2003/05/soap-envelope&quot;, &quot;Envelope&quot;) ;
    • xmlHelper.save(doc, writer, null) ;
    • // We can write to an HTTP output stream to invoke the Web Service
      • <?xml version=&quot;1.0&quot; encoding=&quot;ASCII&quot;?>
      • <tns:Envelope xmlns=&quot;http://ns1&quot; xmlns:tns=&quot;http://www.w3.org/2003/05/soap-envelope&quot;
      • xmlns:xsd1=&quot;http://example.com/stockquote.xsd&quot;>
      • <tns:Header>
      • <myHeader>001</myHeader>
      • </tns:Header>
      • <tns:Body>
      • <xsd1:getLastTradePrice>
      • <tickerSymbol>IBM</tickerSymbol>
      • </xsd1:getLastTradePrice>
      • </tns:Body>
      • </tns:Envelope>
  • Relationship Integrity
    • Containment
      • By default Properties represent containment relationships
    DataObject root = … DataObject originalChild = root.getDataObject(“child1”); DataObject parent = originalChild.getContainer(); assert parent == root; DataObject newChild = dataFactory.create(ChildType.class); root.set(“child1”, newChild); assert originalChild.getContainer() == null; assert newChild.getContainer() == root
  • Other Relationships
    • Non-containment
      • Properties can be made to represent Non-containment relationships
        • xsd:ID and xsd:IDREF in Schema translate to non-containment
      • Without non-containment all data graphs would be single rooted hierarchies
    • Opposite
      • Bidirectional relationships (other than parent-child)
      • Requires non-containment (Property type = xsd:ID, xsd:IDREFS or anyURI)
      • sdo:oppositePropertyType required
  • Sequenced Types
    • Type.isSequenced() for instance ordered DataObjects
    • Triggered by
      • xsd:mixed=“true”
      • repeating choice
      • sdo:sequenced=“true”
    • DataObjet.getSequence()
      • Iterate over Lists of Property Value pairs
      • Sequence.getProperty(int), Sequence.getValue(int)
  • Sequenced Example
  • Tracking changes for disconnected data
    • Service data is often disconnected from the source in SOA
    • Service data can be changed in the flow of business processes
    • // Create an empty data graph and add a root object, an instance of type Quote
    • DataGraph dataGraph = SDOUtil.createDataGraph();
    • DataObject quote = dataGraph.createRootObject(&quot;http://www.example.com/simple&quot;, &quot;Quote&quot;);
    • // Begin logging changes: usually DAS responsibility
    • ChangeSummary changeSummary = dataGraph.getChangeSummary();
    • changeSummary.beginLogging();
    • // Modify the data graph: client code
    • quote.setString(&quot;symbol&quot;, &quot;fbnt&quot;);
    • quote.setDouble(&quot;change1&quot;, 1000);
    • changeSummary.endLogging(); // DAS code
    • ByteArrayOutputStream baos = new ByteArrayOutputStream();
    • // Serialize with change summary data
    • SDOUtil.saveDataGraph(dataGraph, baos, null);
  • Data Access Services - DAS
    • Data Access Services (DAS) provides the data access solution with two fundamental capabilities:
      • Results of a data source query execution returned as a graph of Data Objects
      • Graph modifications reflected back to data source as a series of Creates/Updates/Deletes
    SDO Client Change Summary Data Graph DataObject : EJB : Invoice EJB : JDBC XPath / XQuery XML / HTTP CCI / Proprietary Data Access Service RDB XML DB Web service JCA
  • DAS High Level Architecture SCA component with DAS impl. type
  • Apply changes back to the data store
    • Change-aware DAS can retrieve the data and update the data by applying the delta
    • DAS das = DAS.FACTORY.createDAS(getConnection());
    • // Read customer
    • Command select = das.createCommand(&quot;Select * from CUSTOMER&quot;);
    • // ChangeSummary is enabled by DAS
    • DataObject root = select.executeQuery();
    • DataObject customer = (DataObject) root.get(&quot;CUSTOMER[1]&quot;);
    • // Modify customer
    • customer.set(&quot;LASTNAME&quot;, &quot;Pavick&quot;);
    • // Build apply changes command
    • das.applyChanges(root);
  • DAS example
  • SDO Implementations
    • Open Source implementations of in context of SDO
      • The Tuscany project (incubating at Apache) for SCA, SDO and DAS
      • The Eclipse SOA Tools Platform Project
      • The SOA for PHP project
    • Commercial SDO Implementations
      • XIC from Xcalia
      • HydraSDO from Rogue Wave Software
      • FireStorm/SDO from CodeFutures Software
      • AquaLogic Data Services Platform 2.0 from BEA
      • Virtual XML Garden from IBM
      • IBM WebSphere Process Server V6.0.x
      • IBM WebSphere Application Server V6.1
      • IBM WebSphere Application Server V6.1 Feature Pack for SOA (beta)
      • SAP NetWeaver Application Server, Java(TM) EE 5 Edition
  • WID has a “Bo-Editor” to define XSD/SDO
  • WAS v6 EJB – RSA Tooling
  • WAS v6 JDBC DAS – RSA Tooling
  • WAS v6 JDBC DAS – RSA Tooling
  • Summary
    • Unified data access to heterogeneous data sources
      • Unified programming model for business data
      • DAS layers to take care of different data sources and format conversions on the edges
    • Unified support for both static and dynamic data APIs
      • Generated POJO interfaces/classes for strongly-typed APIs
      • Dynamic APIs: DataObject/Type/Property
      • Static SDOs can be mixed with Dynamic SDOs
    • Support for disconnected programming models
      • ChangeSummary to track changes
      • Change-aware DAS update
      • DAS specification mentioned in the SDO 3 objectives document
    • Multiple language support
      • Java
      • C++
      • PHP
  • Ready to try?
    • Finalised specs -- OSOA collaboration
      • http:// www.osoa.org
    • Articles etc.
      • http://www.osoa.org/display/Main/SDO+Resources
      • http://java.sys-con.com/read/313547.htm
      • http://java.sys-con.com/read/358059.htm
      • http://incubator.apache.org/tuscany/das-overview.html
    • Open Source
      • Apache Tuscany Project
        • http:// incubator.apache.org/tuscany
      • PHP & PECL
        • http:// www.php.net /
        • http:// pecl.php.net /package/SCA_SDO