Results 1 to 15 of 15

Thread: a problem about servant locator

  1. #1
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24

    Question a problem about servant locator

    When dynamiclly creating many proxies, evictor with servant locator is a good idea. but how to pass the parameters to the method ServantLocator::locate(Current , LocalObject) to construct a new servant?

    I find that the method ObjectAdapter::createProxy(Identity) doesn't invoke the locate(..) method, utill the xxHelper::checkCast(ObjectPrx, Context) is called.OR the method xxHelper::checkCast(..) invokes the locate method.

    Using the paramter context in xxHelper::checkCast(ObjectPrx, Context), I passed parameters to ServantLocator::locate(Current , LocalObject) sucessfully, but I don't know whether it is a good idea?
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    It looks like your confusing proxies and servants. These are two distinct objects, the former is used by clients to invoke on an Ice object and the latter is used to implement an Ice object. I recommend you to take a closer look at the Ice architecture section in the manual (section 2.2) for detailed explanations on these terms.

    The servant locator locate() method is called for each invocation on an Ice object. It's supposed to return the servant implementing the Ice object. When you call checkedCast() on a proxy this implicitly invokes ice_isA() on the Ice object, that's why the servant locator locate() method is called in this case.

    I recommend you to take a look at the servant locator documentation in the manual, section 30.6 describes the servant locator interface and section 30.7 "Server Implementation Techniques" shows several implementations of servant locators.

    Benoit.

  3. #3
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    Hi,benoit
    I'm very sorry!
    I mean:
    When dynamiclly creating many servants, evictor with servant locator is a good idea.

    there is no example in the manual to show how to pass paramters to the ServantLocator::locate method.

    my solution:
    ========================
    Using the paramter context in xxHelper::checkCast(ObjectPrx, Context), I passed parameters to ServantLocator::locate(Current , LocalObject) sucessfully
    ========================

    is right or not?
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  4. #4
    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
    What you are doing does not sound like an appropriate use of the Context parameter. This is supposed to be used for "out of band data" -- namely data about the request, such as the Glacier2 routing parameters.

    What parameters do you need to pass to locate?

  5. #5
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    Hi,matthew

    In my project,I need to construct servants dynamically, the servants need a particular parameter to initialize. Although the servants are the same class's instance,they have defferent content.

    My problem is how to pass the parameters to the locate method?
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  6. #6
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    You must use the Ice object's identity for this. If the client provides any information about an Ice object's state other then its identity, you are outside the Ice object model.

  7. #7
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    Hi,marc

    To be efficient,on the server, a servant should be constructed only when the client need.So the client only knows a servant, which can create another servant dynamically.The servant to be created dynamically need get a parameter form the creator--the servant which client knows.

    The class Identity has only two properties:name(string) and category(string), which can't take the parameter I need.
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  8. #8
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Clients must not be the creator of a servants. Clients must not even be aware of the existence of servants in a server. If they are, you are outside the Ice object model.

    A server creates servants for Ice objects. It can create them on demand, using a servant locator. The only information it can use for creating a servant is the object's identity. With the object identity, it can for example look up the Ice object's state in a database, and load such state into a servant.

    Perhaps you are confusing servants with Ice objects. Clients can create Ice objects, but this has nothing to do with servants or servant locators. Clients typically do create Ice objects by calling on other Ice objects, which serve as factory. Servants, on the other hand, are completely transparent to clients, and only matter with respect to how a server implements Ice objects. If a client has knowledge of how servants are used in a server, there is no implementation transparency anymore, which is one of the cornerstones of the Ice object model.

  9. #9
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    Hi,Marc
    thank you very much!
    Clients must not be the creator of a servants. I agree with you.Clients usually get a new proxy by calling the method of another proxy which clients have got. It is corresponding on the server that a servant is created by another servant. Now the servant which is created by another one may want to get some infomation fom it's creator.The information is used for iniaializing the new servant.

    There is an example in the manual in 30.6.5 section.on the server-side,the PhoneBook's search method can create a new servant--PhoneEntry, and on the client-side,it is a proxy creates a new proxy.In this example, the servant PhoneEntry only need a name which can be stored in Identity's name property, that is enough for the servant to initialize. But there may be a situation that to create some servant like PhoneEntry need other information, not only the name.

    Now i encount the situation mentioned above.

    btw: the default servant described in the manual is not thread-safe, right?
    There is an object is shared by the servant. To be thread-safe, a lock is needed.

    can you tell me how to create a new certs?
    The certs in the ice is ecpired.
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  10. #10
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Quote Originally Posted by rwxybh
    can you tell me how to create a new certs?
    The certs in the ice is ecpired.
    Thanks for bringing this to our attention. I've posted an archive containing new certificates in this thread.

    - Mark
    Last edited by mes; 12-31-2005 at 11:44 AM.

  11. #11
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    mes, you are welcome!

    but there is something wrong with the new certs.

    test suites reported that the new certs have expired too!

    *** running tests in .\test\IceSSl\certificateVerification

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx


    error: sslv3 alert certificate expired!
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

  12. #12
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi,

    You're right. In order to run the IceSSL tests successfully, you'll need to update the certificates in the test/IceSSL/certs directory. From the root directory of the Ice distribution, use these commands:

    $ cp certs/cacert.pem test/IceSSL/certs
    $ cp certs/c_rsa1024_priv.pem test/IceSSL/certs/goodKey_1.pem
    $ cp certs/c_rsa1024_pub.pem test/IceSSL/certs/goodCert_1.pem
    $ cp certs/s_rsa1024_priv.pem test/IceSSL/certs/goodKey_2.pem
    $ cp certs/s_rsa1024_pub.pem test/IceSSL/certs/goodCert_2.pem

    - Mark

  13. #13
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    I've posted a new thread that contains new certificate files for both C++ and Java.

    - Mark

  14. #14
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Quote Originally Posted by rwxybh
    The servant to be created dynamically need get a parameter form the creator--the servant which client knows.

    The class Identity has only two properties:name(string) and category(string), which can't take the parameter I need.
    It is physically impossible to access a parameter in locate(). The reason is that the Ice run time cannot unmarshal parameters until after it has located a servant. That is because the servant determines the type of the interface for the request, and the type of the interface determines how to unmarshal the parameters.

    The only information you can access inside locate() is the information delivered as part of the current object. To decide which servant to instantiate, you will typically use the object identity. (In rare cases, you might also use the operation name.)

    I would recommend against using the Context field--it isn't intended for this purpose.

    One option I can think of is that you might be able to use the category field of the object identity to indicate what kind of servant to instantiate. In your server, register a default servant locator and then, inside locate(), look at the category to decide what servant to return from locate().

    Cheers,

    Michi.

  15. #15
    rwxybh is offline Registered User
    Join Date
    Dec 2005
    Posts
    24
    Thanks for your reply,michi!

    thank you,mes!
    Yan Bingheng:a student of Beijing University of Aeronautics & Astronautics
    I'm learning ice now, and will try some projects later!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to pass value into servant locator instance?
    By fabware in forum Help Center
    Replies: 4
    Last Post: 11-09-2009, 08:50 AM
  2. Replies: 5
    Last Post: 10-11-2009, 02:35 AM
  3. Core dump in Python servant locator
    By blair in forum Patches
    Replies: 2
    Last Post: 06-26-2007, 12:29 PM
  4. Servant Locator implementation
    By mwilson in forum Help Center
    Replies: 13
    Last Post: 12-04-2006, 11:29 AM
  5. Question of forwarding ObjectPrx in Servant Locator
    By kongchoy in forum Help Center
    Replies: 6
    Last Post: 02-17-2006, 07:26 PM

Posting Permissions

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