Hello there,

let me rephrase my third question (about subclassing) from my original post 
in the context of the following response in another thread:

>From: Frank Budinsky [mailto:[email protected]] 
>Sent: Tuesday, October 05, 2010 4:31 PM
>To: [email protected]
>Subject: Re: [SDO] Samples for notification feature / register ?
>
[snip]
>Factory.register() is used to define types with static implementation classes. 
>Load from XSD is used for dynamic SDO types.
>
>Frank

So how do I make the factory produce objects of a subclass of the generated 
class,
for some specific type? Would it be enough to subclass the factory and override 
the 
create(typenumber) method to return the subclass?

I guess not, because initializeMetaData() calls initializeType() with the 
instance class 
as its second argument. Unfortunately, the instance class literal is hard-coded 
in the 
generated coding and not obtained from a non-final method. So it seems I am 
still forced 
to manually change some generated coding when subclassing a generated data 
object. Is that 
correct? 

-- Sebastian

> -----Original Message-----
> From: Millies, Sebastian
> Sent: Tuesday, October 05, 2010 1:54 PM
> To: '[email protected]'
> Subject: Extending generated SDO implementation classes
> 
> Hello there,
> 
> I have three questions about this topic, one regarding the up-to-
> dateness of
> the SDO FAQ, one regarding the XSD2JavaGenerator, and one regarding the
> use
> of factories for extensions to generated classes.
> 
> The SDO FAQ still states:
> 
> "2) I cannot (yet) simply subclass a generated SDO class, this may be
> addressed in TUSCANY-513"
> 
> while TUSCANY-513 has been resolved in 2007 for Java-SDO-1.0, and
> Tuscany 1.6 presumably includes
> Java-SDO-1.1.
> 
> In the generated code, extensibility behaviour is the default, as the
> base class for generated
> SDOs, DataObjectBase, extends ExtensibleDataObjectImpl. However, the
> generator option
> "-noExtensibility" which is mentioned in TUSCANY-513 is not accepted by
> the generator.
> 
> So here are the first two questions:
> a) How can I (or someone else) update the FAQ
> b) has the generator ever been updated with that option?
> 
> Among the generated classes, there is a factory class with a create
> method, e. g.:
>   public DataObject create(int typeNumber)
>   {
>     switch (typeNumber)
>     {
>       case TYPE1: return (DataObject)createType1();
>       case TYPE2: return (DataObject)createType2(); // (*)
>       default:
>         return super.create(typeNumber);
>     }
>   }
> 
> Here is the third question:
> Now, when I extend the generated implementation class of type 2, and
> want to use that
> subclass everywhere instead of the generated class, can I simply edit
> the factory? e. g.
> replace line (*) with
>      case TYPE2: return createSubclassOfType2();
> where createSubclassOfType2() is not a generated method but defined by
> me?
> 
> -- Sebastian
> 
> 
> 

Reply via email to