Home Help Center

How to create private objects when using locators?

JohnBJohnB Member John BasraiOrganization: VeriFoneProject: Trident ✭✭
Hello,

I need to use the global namespace with indirect proxy for most of objects but I also want to create some private objects that use direct proxy. I don't think that's possible because createDirectProxy takes an identity and in order to get an Identity I have have to first `add' the object to an adapter.

ObjectPrx = adapter->add(object, Ice::stringToIdentity("name"));
DirectPrx = adapter->createDirectProxy(ObjectPrx->ice_identity());

I think step one (assuming adapter has a locator) will create an
indrect proxy and register it in the global namespace. Correct?

I'm about to write my own namespace, which doesn't seem to hard, but wanted to make sure there's really a need for it.

Thanks,

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    John,

    Adding an object to an adapter does not automatically register that object with the locator. Rather, the application must explicitly register the object.

    Take care,
    - Mark
  • JohnBJohnB Member John BasraiOrganization: VeriFoneProject: Trident ✭✭
    Ok so I've been scouring the manual and the forums and I can't find out how you do that. Is it something so obvoius that I missed it?

    This thread
    talks about but doesn't say exactly how to do .
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    There are several ways to register an object with the locator:
    • By statically configuring the object in an IcePack deployment descriptor.
    • Using the icepackadmin command "object add ...".
    • Programmatically by calling addObject on the IcePack::Admin object. You can find an example of this in demo/IcePack/hello/HelloI.cpp.
    Take care,
    - Mark
  • JohnBJohnB Member John BasraiOrganization: VeriFoneProject: Trident ✭✭
    [Ok looks like you posted before I could, I look at hello demo]

    Is this The correct way to do it?

    AdminPrx admin = AdminPrxHelper.checkedCast(communicator().stringTo Proxy("IcePack/Admin"));
    ....
    admin.addObject(agent);
  • JohnBJohnB Member John BasraiOrganization: VeriFoneProject: Trident ✭✭
    So it's the <Adapter>.Proxy property that causes it
    to be registered in name space? Here's the config file.

    [email protected]
    Hello.Endpoints=tcp:udp:ssl
    Hello.AdapterId=HelloAdapter
    Ice.Default.Locator=IcePack/Locator:default -p 10006

    So this will register under name "[email protected]"? Maybe I'm confused. I'm expecting a <name>,<object ref> tuple but maybe the Proxy is self contained?

    So in this case the client just does a stringToProxy on this property and run time notices that it's indirect and does the rest. Client (code) doesn't really do a lookup. The client run time does that.

    I found this code in Clinet.cpp of Hello demo.
    const char* proxyProperty = "Hello.Proxy";
        string proxy = properties->getProperty(proxyProperty);
        ...
        Ice::ObjectPrx base = communicator->stringToProxy(proxy);
    
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    JohnB wrote:
    So it's the <Adapter>.Proxy property that causes it to be registered in name space?
    No, the Hello.Proxy property is only used by the client to retrieve the object's proxy from the configuration file. The name of this property has no special significance.

    There is no way to automatically register objects in IcePack's object registry. It has to be done explicitly in one of the ways I mentioned above.

    - Mark
  • JohnBJohnB Member John BasraiOrganization: VeriFoneProject: Trident ✭✭
    I was looking at the wrong sample! I was looking at demo/Ice/hello intead of demo/IcePack/hello.

    I'll have to study the IcePack/hello demo.

    Thanks for you help.
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    JohnB wrote:
    So in this case the client just does a stringToProxy on this property and run time notices that it's indirect and does the rest. Client (code) doesn't really do a lookup. The client run time does that.
    That's correct, the Ice run time handles indirect proxies internally, but the client must be configured with a locator proxy. This means the client code you quoted works equally well for direct and indirect proxies.

    Also, don't be confused by the fact that the client, server and IcePack all use the same configuration file in the demo. Only certain properties in the file are used by each of the components. The public object with the identity "hello" is registered when the descriptors are deployed.

    - Mark
Sign In or Register to comment.