[Engine-devel] ovirtSDK: ObjectsFactory would bring ability to customize objects
Itamar Heim
iheim at redhat.com
Wed Feb 15 07:01:26 UTC 2012
On 02/14/2012 06:01 PM, Jaroslav Henner wrote:
> 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]
>
while i understand the benefit this will give you in extending the
classes, It doesn't sounds to me like the classical sdk, which just
gives you the API at OO class level?
More information about the Engine-devel
mailing list