| By Kelvin Goodson, Geoffrey Winn | Article Rating: |
|
| April 10, 2007 03:00 PM EDT | Reads: |
21,604 |
Monitoring Change
A major capability of SDO is
being able to provide a summary of the changes made to a data graph. In
SDO 1 this behaviour was the responsibility of a special class, the
DataGraph. In SDO 2 you can get this behaviour through the DataObject
interface by including a property of the ChangeSummaryType in your type
definitions. This new feature offers flexibility in choosing the scope
of change monitoring. For example, you might want to monitor the
changes to the body of a Web Services message without monitoring its
containing envelope. Here we'll focus on the new style of achieving
this result. For this we must return to the original XML Schema for the
medical test and add an element to the "Test" type.
<complexType name="Test">
<sequence>
<element name="referrals" type="people:PersonSet" />
<element name="patients" type="people:PersonSet" />
<element name="relatives" type="people:PersonSet" />
<element name="changes" type="sdo:ChangeSummaryType" />
</sequence>
</complexType>
The SDO specification defines the rules about the definition of types that include ChangeSummaryType properties. It also defines rules about assembling a data graph that includes data objects of such a type. These rules are in place to avoid the possibility of a graph having multiple change summaries describing overlapping areas of the graph.
Once you have a data object containing a change summary property you can access the change summary using the getChangeSummary() method (on any data object within the scope of the change summary). You can then use this change summary object to alter the logging state or query the changes that have occurred.
Imagine that we had been using the above type definition throughout our example and immediately after creating the test instance DataObject we turned on change monitoring as follows:
DataObject test = DataFactory.INSTANCE.create("www.example.org/MedicalTest", "Test");
test.getChangeSummary().beginLogging();
test.set("referrals", referrals);
Having done this, at any subsequent point in the program we can make use of the interface to the ChangeSummary object to examine the alterations in state that have occurred since the change monitoring was started.
As an example, imagine a data entry panel for adding and editing patient data. The ChangeSummary's undoChanges() method can be used to roll back all the changes made since logging began, and could therefore be used to underpin a "cancel" operation in the data entry panel. Knowing that the changes made to a graph opens up many other possibilities, for example, the above data entry panel could highlight all the changes made as the data is updated, or it could provide for a "commit" phase, where the operator is given an opportunity to review the changes before committing them. It would also be possible to use the change summary information to reduce inter-process communication by serializing and transmitting only the changed objects between the application layers.
Creating Types Programatically
In Part 1 of this
article we first adoped an Apache Tuscany implementation-specific
approach to creating types programmatically so we could introduce the
concept of types and then we relied on the XML Schema-to-SDO Type
conversion to do the bulk of our type system creation. The reason for
starting with the non-standard Tuscany approach to building types was
that the official method requires knowledge of SDO so we have a
"chicken and egg" situation where you need types to build data objects
and you need to understand how to build data objects to create your own
types. We are now equipped to revisit type creation and do it the
official way.
SDO has a TypeHelper interface that can be passed descriptions of the desired types and will produce those types and make them available for lookup later. The format for description of the types is a graph of data objects. There are two TypeHelper methods that let you define types; in the first you can submit a data graph describing a single type to the type helper, while the second lets you submit a list of data graphs to be processed all together and thereby generate a list of types. This is more than just a convenience and we'll explain later why there's a compelling reason for using this second option.
In preparing the description of our types we'll be building a number of similar data objects into data graphs so we'll create a little helper method to create a basic description:
private DataObject createTypeDescription(
String uri, String name) {
DataObject typeDesc = dataFactory.create(
"commonj.sdo", "Type");
typeDesc.set("name", name);
typeDesc.set("uri", uri);
return typeDesc;
}
We now have enough understanding of the SDO API to know that this method builds a little one-node data graph with a root data object of the "Type" type with two properties, name and uri, having been set to the values supplied to the method. The "Type" type is built into the SDO runtime and is there specifically to build type descriptions. Note that this data object isn't itself a type, just a description of a type.
The first step in creating our type system programatically is:
DataObject personTypeDesc = createTypeDescription(
"www.example.org/people", "Person");
List typeDeclarations = new ArrayList();
typeDeclarations.add(personTypeDesc);
Published April 10, 2007 Reads 21,604
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Kelvin Goodson
Kelvin Goodson is based at IBM Hursley in the UK as part of the Open Source SOA team. He is a committer to the Apache Tuscany incubator project, and works primarily on development of the Tuscany Java implementation of SDO. He gained a Ph.D. in image analysis and artificial intelligence in 1988, and has previously worked in the areas of medical imaging, weather forecasting and messaging middleware.
More Stories By Geoffrey Winn
Geoff Winn is based at IBM Hursley in the UK, as part of the Open Source SOA team. He is a member of the SDO specification group and currently works on development of the Apache Tuscany C++ implementation of SDO. He has degrees in Mathematics and Computation, and has previously worked in the areas messaging and brokering middleware.
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?






































