|
About Ice Best Practices:What is the best way to client locating the servant?
have a question about client locating the servant.
My type sysstem has two servants,which are independent to each other.
for instance,at server side:
FooI Servant:
public class FooI:FooDisp_
{
....//no any api will return BarI proxy
}
BarI Servant:
public class BarI:BarDisp_
{
...//no any api will return FooI proxy
}
Server Application:
public class Server:Ice.Application
{
public override int run(string[] args)
{
Ice.ObjectAdapter adapter=new ....
adapter.add(new FooI(),communicator().stringToIdentity("Foo"));
adapter.add(new FooI(),communicator().stringToIdentity("Bar"));
adapter.activate();
communicator().waitForShutdown();
return 0;
}
public static void Main(string[] args)
{
Server app = new Server();
int status = app.main(args, "config.server");
if (status != 0)
{
System.Environment.Exit(status);
}
}
}
At the client,maybe I need to add below lines to client.config file:
Server.Foo=Foo:tcp -h 127.0.0.1 -p 12345:udp -h 127.0.0.1 -p 12345
Server.Bar=Bar:tcp -h 127.0.0.1 -p 12345:udp -h 127.0.0.1 -p 12345
And write below code:
FooPrx fooPrx = FooPrxHelper.
checkedCast(communicator().propertyToProxy("Server .Foo"));
......//do someting
BarPrx barPrx = BarPrxHelper.
checkedCast(communicator().propertyToProxy("Server .Bar"));
......//do someting
Above steps can work well,but I fell there are some smell in these code.
How can I do better?
What is the best way to client locating the servant?
|