tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham_Ste...@emc.com
Subject RE: SDO Newbie question
Date Tue, 04 Nov 2008 23:29:51 GMT
Hi Frank:
Thanks for the quick response.  My problem was that I was doing a new on
the generated factory, not using the singleton pattern implemented by
.INSTANCE.

sgg 

-----Original Message-----
From: Frank Budinsky [mailto:frankb@ca.ibm.com] 
Sent: Tuesday, November 04, 2008 4:47 PM
To: user@tuscany.apache.org
Subject: Re: SDO Newbie question

You can take a look at SimpleStaticTestCase in the tools-test project
for 
a simple example:

https://svn.apache.org/repos/asf/tuscany/java/sdo/tools-test/src/test/ja
va/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java

The first thing that you need to do is make sure the metadata is 
registered. Your generated factory class has a register method that you 
need to call:

    scope = SDOUtil.createHelperContext();
    SimpleFactory.INSTANCE.register(scope);

Once you've registered the metada, you can load an instance using the 
standard SDO load API: XMLHelper.load().

    XMLDocument xml = scope.getXMLHelper().load(source, null, null);
    assertTrue("Root element is not an instance of the generated class",

xml
        .getRootObject() instanceof Quote);

I hope this helps.

Frank.


Graham_Steveg@emc.com wrote on 11/04/2008 04:11:24 PM:

> Hi guys:
> Quick question about using the classes generated by XSD2JavaGenerator.
> 
> I have used this tool to generate a set of Java interfaces and impl
> classes corresponding to an XSD.  All seems fine.
> 
> What I am missing is the pattern that guides me how to deserialize an
> XML document (from the file system or any other XMLReader) into a
graph
> of Java instances of the type(s) generated from my XSD by the
> XSD2JavaGenerator.
> 
> The factory method generated did not have any method that looked like
> "readFromXML(XMLReader foo)" or any equivalent deserialization
> mechanism.
> 
> Any help, sample code snippets etc. would be appreciated.
> 
> sgg



Mime
View raw message