Board index » delphi » Object creation inside RemoteDatamodule

Object creation inside RemoteDatamodule

Okay, this might sound crazy, but here it goes...

I have a remote data module and a client dataset. On my server, I have
instantiated a MyServer object. What I want to do is to be able to create a
UserInformation object of, let's say TUserInfo type. This will be a full
object with methods, properties and the rest.

The idea is that, on successful login, a TUserInformation object (which I
created as an Automation Object on another unit) is instantiated, and the
MyServer.TheUserInformation property is set to a TUserInformation (which is
an automation object on another unit), and the Get_UserInformation function
is setting the Item to the object. I made UserInformation property in the
MyServer on the .TLB to be of type IProvider (I decided to use IProvider
because publicized queries in the remotedatamodule use this, and then the
Get_Query1 only has a Result := Query1).

My problem is that when I try the above (which compiles fine), and I want to
call any method or property (say,
ClientDataSet.AppServer.UserInformation.UserName, for instance) from the
client, I get a catasthropic failure. I am already able to call custom
methods and properties I set up on the Datamodule, but I need to have the
properties that reflect my other objects.

I want to instantiate this (and later other) objects inside the
RemoteDatamodule so they can be called, and I can develop very easy to use
(from the client) Business objects. Does anybody have any advice? Again, I
want this objects to be created dynamically, so the COM property is empty if
the object is not there, but its methods are available if the object is
there.

So the idea is:

    Object MyServer (RemoteDataModule)
        procedure Method1(param, param : WideString);
        function Method2(Param:Integer) : Integer;
        property Property1 : WideString read only;
        property UserName : IProvider; (this becomes a TUserInformation)
        property anotheobject : IProvider;

    Object UserName
        property UserName : WideString;
        property FullName : WideString;
        property whatever;
        Method whatever;

    Object AnotherObject
        Method1... blah blah

    Object AnotherObject

Thank you for your help,

David Martinez

 

Re:Object creation inside RemoteDatamodule


It seems to me that what you are trying to do is in effect pass an object in
its entirety to a remote client.
The mindtwist  you make is this:
This object you want to pass references pointers ( to variables and methods)
that only exist on the server side.
The client is thus trying to reference pointers in its own memoryspace that
aren't really there at all.
(The VTABLE entries for the object are only valid on the server, not on the
client)
What you need to do is write a broker object, that retrieves the information
and passes it .
(in effect write an interface that is able to pass the information with
getters and/or setters).

Quote
David Martinez wrote in message <6a9dgr$98...@ha2.rdc1.sfba.home.com>...
>Okay, this might sound crazy, but here it goes...

>I have a remote data module and a client dataset. On my server, I have
>instantiated a MyServer object. What I want to do is to be able to create a
>UserInformation object of, let's say TUserInfo type. This will be a full
>object with methods, properties and the rest.

Re:Object creation inside RemoteDatamodule


Thank you for your fast response.

Yes, I understand how the memory works, and I also understand that, unless I
pass streams (for LoadFromStream/SaveToStream) and encapsulate carefully,
it is possible to be trying to reference nonexistant memory. But the real
question is, how do I create the new interface inside of an existent
interface? Using the wizard for OLE automation object makes me go through
the process of creating the object from the client machine. What I want to
do is make that object a "sub-object" of the remote data module, sort of in
the same way Word and Excel can come up with things like:

var
  AppWordVariant : OleVariant;
  AppDocVariant : OleVariant;
begin

  AppWordVariant := CreateOleObject('Word.Application');
  AppDocVariant   := AppWordVariant.CurrentDocument;

  AppDocVariant.SelectAll;
  AppDocVariant.Print;

  AppWordVariant.OpenAnotherDocument.....

end;

A comprehensive server like this makes things much easier for the Client
programmer. There must be a way in which I can create the IProvider the way
the client would expect it and then set it as the "Get" property of the
Datamodule. Any Ideas? I'll keep trying to do it from here.

Thanks!

- David

Quote
Thaddy de Koning wrote in message <6a9lgb$g0...@news.Leiden.NL.net>...
>It seems to me that what you are trying to do is in effect pass an object
in
>its entirety to a remote client.
>The mindtwist  you make is this:
>This object you want to pass references pointers ( to variables and
methods)
>that only exist on the server side.
>The client is thus trying to reference pointers in its own memoryspace that
>aren't really there at all.
>(The VTABLE entries for the object are only valid on the server, not on the
>client)
>What you need to do is write a broker object, that retrieves the
information
>and passes it .
>(in effect write an interface that is able to pass the information with
>getters and/or setters).
>>I have a remote data module and a client dataset. On my server, I have
>>instantiated a MyServer object. What I want to do is to be able to create
a
>>UserInformation object of, let's say TUserInfo type. This will be a full
>>object with methods, properties and the rest.

Other Threads