Archived

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

Multiple instances of interfaces.

Hi.

I’m relatively new to ICE and I’d like to know how to do something.
My server application has 4 interfaces. The client application invokes an operation in interfaceA. The operation creates an instance of interfaceB using the CreateObjectAdapterWithEndPoints, adds it to the servers communicator object and activates it. Once activated the operation then creates an instance of the interface and passes it back to the client. The client can then call the operations on interfaceB as normal.

This all works when there’s one single client.
If you add a second client then it all starts going wrong.
At the point where the operation in interfaceA tries to add the second instance of interfaceB to the servers communicator it throws an exception.

I initially tried having a more dynamic port or name when I register the interface but that doesn’t work either.

What is the proper way of creating multiple instances of interfaces?
Source code can be supplied if necessary.

Thanks for any suggestions.
Nick.

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    Hi

    I would first suggest that you read this FAQ regarding when it is necessary to create multiple object adapters.

    I expect that in your case it is not necessary to create a new adapter for each interface, but instead have all the interface instances registered with the same adapter. You can get access to the object adapter within interfaceA's operation call from the adapter member of Ice::Current.
    interfaceAI::operation(..., const Ice::Current& current)
    {
        Ice::ObjectAdapterPtr adapter = current.adapter;
        ...
    }
    

    Dwayne
  • Got it.

    Hi dwayne.
    Thanks, your reply pointed me in the direction and i found out from the documentation that i was ment to be using servants and the way i was doing it was completely wrong. It all works fantasticly now.

    Regards.
    Nick.