This forum has been archived. Please start a new discussion on GitHub.

A beginner's problem!! About remote object sharing.

HI, I have a problem about remote database connection.
interface ResultSet
bool next();
interface CommonDB
  bool connect(string user, string passwd, string host, string dbname);
ResultSet* query(string sql);
**other OP();

My problem is :
If I design as above, all client that use CommonDBPrx will share an CommonDB servant instance.
  Is there a way to design one client one CommonDB servant?
  And the ResultSet servant is created dynamically, how does a client destroy the transient servant object. Because each query operation will create a ResultSet servant object with a UUID. How to destroy it?


  • marc
    marc Florida
    You are looking for session management. Have a look at Glacier2, which can do session management for you. There was also an article about session management with Glacier2 in the first issue of our newsletter:

    As for ResultSet, why not simply pass the ResultSet to the client by value?
  • Because the ResultSet has a lot of member data, such as recordmeta which describe the fields metadata, record array and others.

    Can I use "Freeze" to destroy the dynamic ResultSet servant object created by CommonDB servant?
  • benoit
    benoit Rennes, France
    No, Freeze won't help here. You need to add a destroy() method to the ResultSet interface. The client will invoke this method to destroy the result set object and its associated resources.

    You will also need to destroy the result set object if the session associated to the client is destroyed (in case the client crashed and didn't explicitly called destroy on the result set.)

    Hope this helps!

  • But how can I destroy the ResultSet object in the destroy() method?
  • benoit
    benoit Rennes, France
    Like any other Ice objects: you unregister the servant from the object adapter, i.e.:
    ResultI::destroy(const Ice::Current& current)

    Please let me know if i misunderstood your question.