Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Tying variables to remote objects

by simon.proctor (Vicar)
on Dec 19, 2001 at 16:04 UTC ( [id://133099]=note: print w/replies, xml ) Need Help??


in reply to Tying variables to remote objects

I would suggest you consider something along the lines of a proxy object. You tie yourself to the proxy object and write the appropriate access methods to initiate the SOAP requests.

The fetch and store commands would be the most likely candidiates for the actual SOAP requests. You would then provide additional logic for doing the useful stuff (like each(), keys() etc) which would operate on the data locally once it had been fetched.

Suggest you look at the man page for tie or get the Advanced Perl Programming book. Either way - it should be a straightforward task. I would recommend that you build a comms object to actually initiate the SOAP comms and either inherit from it or use some form of aggregate relationship.

You should have no problem doing either with tie.

Hope that helps

Replies are listed 'Best First'.
Re: Re: Tying variables to remote objects
by bmccoy (Beadle) on Dec 19, 2001 at 19:20 UTC
    Cool idea! I don't see a reason why it can't be done. I've had some ideas of tying variables to CORBA objects. It would certainly make the CORBA interfaces much simpler, and would really give stuff like EJB a run for it's money.

    I think this concept could not only be used for SOAP or CORBA but also for POE. You'd need to do some serious planning and design to get this to work, but I'm sure it's feasible.

    -- Brett

    Go not to the Elves for counsel, for they will say both no and yes

      Oooo, This does raise some interesting options. Not long ago I was writing a CORBA system with Perl on the server and a Java client. Of course there are hashes all over on the server since the API is in Perl, but hashes aren't a basic type in Java, and they sure aren't in OMG IDL. My simple solution was to map hashes to multidimensional arrays in IDL, but then the client has to do a lot of nitpicking array handling (esp. since it's Java :P )

      A better idea might be a general IDL interface defining a set of hash functions. But on the server side it wouldn't work to tie the hash to the 'CORBAHash' b/c the tied hashes are just proxy objects, and the remote reference used by the client will necessarily point to the instance of CORBAHash, not the tied hash. So, on the server side, the CORBAHash would have to be a wrapper class around the hash with the data you want.

      What would be nice is to reverse the tie(), so that you could tie an instance of a class to a populated data structure, as in:

      tie($corba_hash, %$hash); return $corba_hash; # return to the client
      But then you might as well just pass the hash into the constructor of the remote implementation class. So, I think what you'd want is:
      bless($hash, 'CORBAHash'); $ORB->activate($hash); # register object with the ORB return $hash; # return to the client
      If the client were in Perl, you'd want to be able to say:
      tie(%hash, 'CORBAHash');
      To make this work I think you'd have to write the TIEHASH method to call a remote factory method, since the whole point is to tie the hash to a remote object. The factory method produces a remote object reference with the hash interface, and then it's just a matter of the local Perl interpreter to link the hash reference to the remote reference.

      Update: I'm using the COPE language binding for Perl.

        I'll ask the obvious question: How are you implementing CORBA servers in Perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-25 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found