Results 1 to 3 of 3

Thread: About Ice Best Practices:What is the best way to client locating the servant?

  1. #1
    sgsoft's Avatar
    sgsoft is offline Registered User
    Name: Samon Sun
    Organization: Freelance
    Project: Remote RFID Reader
    Join Date
    May 2007
    Location
    Beijing,China
    Posts
    28

    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?

  2. #2
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    I'm afraid there is no absolute answer to this problem. It really depends on your application and deployment environment. What you've done certainly works, but it requires that you modify the configuration files each time the objects move which may or may not be very inconvient.

    A more flexible solution is to use IceGrid and locate these objects as well-known objects -- there are numerous articles in our Newsletter on IceGrid so I recommend reading them for more insights.

  3. #3
    sgsoft's Avatar
    sgsoft is offline Registered User
    Name: Samon Sun
    Organization: Freelance
    Project: Remote RFID Reader
    Join Date
    May 2007
    Location
    Beijing,China
    Posts
    28
    Thanks very much!

    I will read them .
    ------------------------------------------------
    Freelance software developer working on a new device:
    Remote RFID Reader.
    soon after ,the projiect source can be downloaded from:
    http://code.google.com/p/sgsoft-las/
    Wellcome join.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question Regarding Slice Interface "Best practices"
    By MMOInteractive in forum Help Center
    Replies: 1
    Last Post: 11-02-2010, 01:16 PM
  2. Best practices for junit?
    By philion in forum Help Center
    Replies: 1
    Last Post: 09-23-2010, 02:52 AM
  3. Replies: 6
    Last Post: 05-15-2008, 08:49 AM
  4. Replies: 1
    Last Post: 04-23-2008, 06:38 PM
  5. Replies: 2
    Last Post: 06-23-2007, 07:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •