You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Philipp Schöpf <ph...@gmx.de> on 2006/09/08 13:15:29 UTC

Instantiate static SDOs with DataFactory

Hi all,

sorry for asking, but I am not quite sure how to instantiate a generated static SDO with the DataFactory class. I have something like this:

- Person.xsd which contains the declaration of a person type
- generated interfaces, factory and impl with the XSD2JavaGenerator
- PersonFactory.INSTANCE.createPerson() works just fine
- but when I call the more abstract DataFactory.INSTANCE.create(Person.class) I get an:

Exception in thread "main" java.lang.IllegalArgumentException
at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.java:60)
at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.java:50)

Do I have to call something before to register my Person type or is the DataFactory only suiteable for dynamic SDOs?

Thanks for the clarification,

Philipp

Re: Instantiate static SDOs with DataFactory

Posted by kelvin goodson <ke...@gmail.com>.
Sorry,  and to tie up the loose ends ---  the default
DataFactory.INSTANCEmakes use of the default
TypeHelper.INSTANCE,  so (barring classloader issues implied by the JavaDoc)
tying that together you now have the default DataFactory being able to find
and use your generated types.

On 08/09/06, kelvin goodson <ke...@gmail.com> wrote:
>
> Philip,
> I think what you need is the Tuscany specific call to ...
>
> SDOUtil.registerStaticTypes(PersonFactory.class)
>
> The JavaDoc says ....
>
> "Register and initialize the SDO types supported by the specified
> generated factory class. This function must be called before instances of
> the generated types can be created/used. The registered types will be
> visible in all TypeHelper's created in the same classLoader scope as the
> call to this function."
> Regards, Kelvin.
>
>
>
> On 08/09/06, Philipp Schöpf <ph...@gmx.de> wrote:
> >
> > Hi all,
> >
> > sorry for asking, but I am not quite sure how to instantiate a generated
> > static SDO with the DataFactory class. I have something like this:
> >
> > - Person.xsd which contains the declaration of a person type
> > - generated interfaces, factory and impl with the XSD2JavaGenerator
> > - PersonFactory.INSTANCE.createPerson() works just fine
> > - but when I call the more abstract DataFactory.INSTANCE.create(
> > Person.class) I get an:
> >
> > Exception in thread "main" java.lang.IllegalArgumentException
> > at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> > DataFactoryImpl.java:60)
> > at org.apache.tuscany.sdo.helper.DataFactoryImpl.create (
> > DataFactoryImpl.java:50)
> >
> > Do I have to call something before to register my Person type or is the
> > DataFactory only suiteable for dynamic SDOs?
> >
> > Thanks for the clarification,
> >
> > Philipp
> >
> >
>
>
> --
> Best Regards
> Kelvin Goodson
>



-- 
Best Regards
Kelvin Goodson

Re: Instantiate static SDOs with DataFactory

Posted by kelvin goodson <ke...@gmail.com>.
Philip,
I think what you need is the Tuscany specific call to ...

SDOUtil.registerStaticTypes(PersonFactory.class)

The JavaDoc says ....

"Register and initialize the SDO types supported by the specified generated
factory class. This function must be called before instances of the
generated types can be created/used. The registered types will be visible in
all TypeHelper's created in the same classLoader scope as the call to this
function."
Regards, Kelvin.


On 08/09/06, Philipp Schöpf <ph...@gmx.de> wrote:
>
> Hi all,
>
> sorry for asking, but I am not quite sure how to instantiate a generated
> static SDO with the DataFactory class. I have something like this:
>
> - Person.xsd which contains the declaration of a person type
> - generated interfaces, factory and impl with the XSD2JavaGenerator
> - PersonFactory.INSTANCE.createPerson() works just fine
> - but when I call the more abstract DataFactory.INSTANCE.create(
> Person.class) I get an:
>
> Exception in thread "main" java.lang.IllegalArgumentException
> at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:60)
> at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:50)
>
> Do I have to call something before to register my Person type or is the
> DataFactory only suiteable for dynamic SDOs?
>
> Thanks for the clarification,
>
> Philipp
>
>


-- 
Best Regards
Kelvin Goodson