I am maintaining a very old Delphi app that was developed with the old DCOM based DataSnap. It is now ported to Delphi 2010. There is a server TRemoteDataModule implmenting a custom ISomeServerStuff interface and also containing a large number of TDataSetProviders.
On the client side there is a TDataModule with a TConnectionBroker, a TDCOMConnection and a large number of TClientDataset-s connected to the server TDatasetProviders by names. In addition to that, the code is littered with calls like:
connectionBroker.AppServer.SomeServerCall(someParams)
I am now atempting to reuse the functionality implemented by compiling both server and client code in a single separate executable, while keeping the original solution working.
To that end I have put a TLocalConnection on server TRemoteDataModule and am connecting the client connectionnBroker to this TLocalConnection. For the TClientDataSets this works without problems. However for the calls connectionBroker.AppServer.SomeServerCall(someParams) EOleSysError: Not implemented is raised
Having looked at the TLocalConnection sources I now understand why that is - TLocalConnection makes no attempt to support anything else but the dataset providers.
I have a workaround: I can access the TRemoteDataModule's methods by passing around the ISomeServerStuff reference which is now in-process anyways.
However this means I have to revisit and change all the call-sites connectionBroker.AppServer.SomeServerCall() and change them to support both old OLEVariant IDispatch based style and new direct ISomeServerStuff calls.
Ideally I would like to keep existing code as is and find a way to compose an OLEVariant that would suppport both IAppServer via TLocalConnection and ISomeServerStuff that I have a reference to. I think I understand that I'd need a IDispatch version of ISomeServerStuff for that but am stuck as what I'd need to do to aggregate such a construct.
So what I am trying to achieve :
var myLocalAppServer: OLEVariant := Agregate(TLocalConnection.AppServer, ISomeServerStuff)
TLocalConnection.SetAppServer(myLocalAppServer)
Alternatively, as RemoteDataModule implicitly supports IAppServer I could do something like this:
TLocalConnection.SetAppServer(ISomeServerStuff as OLEVariant)
Can this be done at all ? Or is there another/better way to approach this ?