Dear Wiki user, You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.
The following page has been changed by KelvinGoodson: http://wiki.apache.org/ws/Tuscany/SDOJavaOverview The comment on the change is: Framework of document complete, but some updates to be made and images/links to ------------------------------------------------------------------------------ === Tuscany Build Environment Setup === SDO 2 is a subproject of the Tuscany project. If you check out and build the whole Tuscany Java project, you will have also built the SDO 2 subproject. If you want to work with the SDO 2 project, without the rest of Tuscany, skip to the next section. + TBD - link to the definitive instructions @@ -277, +278 @@ </xsd:complexType> }}} + === Generator Patterns === + + The DataObject interface generation pattern is as described in the SDO specification (see Java Interface Specification section). The SDO specification does not define a factory pattern for efficient construction of static SDOs, which is however provided by the Tuscany implementation. The generated SDO Factory interface conforms to the following pattern: + + {{{ + public interface <prefix>Factory { + <Type1> create<Type1>(); + <Type2> create<Type2>(); + ... + <prefix>Factory INSTANCE = <default_factory_impl>; + } + }}} + + A generated factory corresponds to an SDO Type namespace uri (see commonj.sdo.Type.getURI) with one create() method for each SDO Type in the namespace. The <prefix> of the factory name is derived from the uri. An instance of the factory is available using the INSTANCE field in the interface. + + Using the static factory, a DataObject might be created as follows: + + {{{ + Quote aQuote = StockFactory.INSTANCE.createQuote(); + ... // do something with aQuote + }}} + The generated implementation of each create() method simply constructs an instance of the corresponding type like this: + {{{ + public Quote createQuote() { + QuoteImpl quote = new QuoteImpl(); + return quote; + } + }}} + In addition to these generated type-specific create<Type>() methods, the generated factory implementation class also includes a generated reflective create() method that, given an SDO Type, efficiently dispatches to the correct type-specific create() method. The reflective create() method is called by the implementation of the SDO commonj.sdo.helper.DataFactory interface. + + == Test/Example Programs == + + The SDO project does not include any proper sample programs at this time (any volunteers?) but it does include a number of JUnit test cases, some of which serves as good examples of how to use SDO APIs to perform various tasks. + + The following tests are particularly good SDO examples included in the sdo.impl project: + + * SimpleDynamicTestCase â This program uses the SDO XSDHelper.define() method to register a simple XML Schema based model (simple.xsd). It then instantiates a DataObject instance (type Quote), initializes several of its properties, and then serializes the instance to an XML stream. + + * MixedTypeTestCase â This program shows how to uses the Sequence API to create an XML instance which mixes arbitrary text within the DataObjectâs XML structure. It uses the XML schema complexType (MixedQuote) in mixed.xsd to define the SDO model. + + * OpenTypeTestCase â Uses an XML Schema complexType with a wildcard (xsd:any) to illustrate how to work with and manipulate an SDO open type. The type OpenQuote in open.xsd is used for this example. + + * SimpleCopyTestCase â Uses the SDO CopyHelper to create shallow and deep copies of the simple Quote model from SimpleDyanmicTest. + + * SimpleEqualityTestCase â Uses the SDO EqualityHelper to perform deep and shallow equality checks. + + * ChangeSummaryTestCase â Creates a data graph with an instance of type Quote (in simple.xsd) as the root object. It then turns on change logging and makes a number of changes to the graph. Finally, it turns off change logging and serializes the data graph. + + * XSDHelperTestCase â This program shows how the XSDHelper.define() method can be called multiple times with the same schema. The second (and subsequent) call simply returns the previously defined list of types. + + The following is in the sdo.tools project: + + * SimpleStaticTestCase â This test performs the same function as SimpleDynamicTestCase, above, only using a generated version of the simple.xsd model. The generated model has been pre-generated (with default options) in the directory src/test/resources, but it can be regenerated using the JavaGenerator, possibly with different generator options (e.g., -noInterfaces or âsparsePattern), if desired. +