Archived

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

IceBoxService, Servant and Communicator question

Hi,

I am using IceBox service to register my servant posting code below:

public class IceBoxService extends Ice.LocalObjectImpl implements
<pre>
IceBox.Service {

private Ice.ObjectAdapter adapter;

public void start(String s, Communicator communicator, String[] strings) {

this.adapter = communicator.createObjectAdapter(s);
Ice.Object object = new FCASearchI();
adapter.add(object, Ice.Util.stringToIdentity("SimpleFCASearch"));
adapter.activate();
}

public void stop() {
adapter.deactivate();
}
}

}
</pre>

My servant FCASearchI needs to lookup with other services, what is the best/recommended way to lookup those? Is it okay to create an new communicator in the servant for the purposes of lookup? Will that interfere with SharedCommunicator instance if all the services in an IceBox share a single communicator?

Thanks in advance,
--Venkat.

Comments

  • mes
    mes California
    Hi Venkat,

    Creating a communicator is expensive, therefore we recommend that you avoid it unless absolutely necessary. Marc discussed this issue recently here.

    My suggestion is to pass the communicator to the servant's constructor. The servant can then use it in the constructor, or save it to use later.

    Take care,
    - Mark
  • Hi Mark,

    Thanks for your suggestion. The other thread you pointed also clearly explains the differences.

    --Venkat.