|
Inheritance/Objekt Identity/Locator
I am confused about how to properly assign object identities for derived classes in Ice. Consider this slice - definition:
-----------
interface CDocumentVersion {
...
};
interface CInvoiceDocumentVersion extends CDocumentVersion {
...
};
sequence<CDocumentVersion*> CDocumentVersionSequence;
interface CDocument {
// the returned sequence can contain plain CDocumentVersion
// proxies as well CInvoiceDocumentVersion proxies
CDocumentVersionSequence selectDocumentVersions();
};
-----------
The idea here is a general framework providing documents and document versions and an extension for the special case of invoices. This extension should be possible without changing the code or interfaces for the general framework.
CDocument::selectDocumentVersions() creates the object identites for the selected and returned document versions. However, CDocument is not aware if a document version is actually just a CDOcumentVersion or indeed a CInvoiceDocumentVersion. Therefore it will just create object identities of category "CDocumentVersion". Hence if a use locators, the CDocumentVersion - Locator will be used, resulting in the incarnation of a CDOcumentVersion servant for something that is actually a CInvoiceDocumentVersion and has to use the specialised code of the derived class!
Also I wonder: what if another interface returns a CInvoiceDocumentVersion and does know about the specialised character of the object, so that it creates an object identity of category "CInvoiceDocumentVersion". The result is that 2 different object identities (once with category "CDocumentVersion", once with category "CInvoiceDocumentVersion", but both with the same name) identify the same object. This would mean that comparing the object identies is no longer identical with comparing the actual objects!
I'm not sure if this is a conceptual problem of the way how Ice implements object identies or an imminent problem / misunderstanding of mine concerning inheritance. But since I couldn't find hints in the Ice documentation how to properly handle inheritance for interfaces on implementation level I would be most grateful for some help.
|