[Engine-devel] ovirtSDK: ObjectsFactory would bring ability to customize objects

Jaroslav Henner jhenner at redhat.com
Tue Feb 14 16:01:09 UTC 2012


On Tue 14 Feb 2012 03:58:05 PM CET, Itamar Heim wrote:
> On 02/14/2012 02:57 PM, Jaroslav Henner wrote:
>> Greetings.
>>
>> I'm an automation tester in charge of testing SDK, my problem is that I
>> cannot influence the objects that are created without so called "monkey
>> patching" (google that and you will see what it means) the
>> ovirtsdk.infrastructure.brokers.*. I made some comments about this
>> #782891, but I was not so clear there, so I hope this will be better:
>>
>>
>> In [12]: api.datacenters.list()[0]
>> Out[12]: <ovirtsdk.infrastructure.brokers.DataCenter at 0x1a62890>
>>
>> You see that this returns an object that was declared somewhere in SDK.
>> We have AFAIK no good way to say which object should be created.
>>
>> It would be good for us to be able to tell SDK:
>> "
>> My dear SDK, every time you are asked, please don't create and give me
>> ovirtsdk.infrastructure.brokers.DataCenter, but something very similar:
>> our.tests.infrastructure.brokers.DataCenter
>> "
>
> I'm not sure i understand - you want the SDK to return an object from 
> a class it does not know (i.e., the SDK to return an object from your 
> class)?
> how will this look like if the SDK was in another language (say java)?

There would be some interface/abstract/concrete class DefaultFactory. 
This will define some common interface. There would be some setter 
inside SDK which would contain the instance of that DefaultFactory. SDK 
user would be able to set it to his own instance of (descendant) of 
DefaultFactory. From this point on, the objects created by SDK would be 
from the newly set factory -- customized. 
[http://en.wikipedia.org/wiki/Abstract_factory_pattern]




More information about the Devel mailing list