Archived
This forum has been archived. Please start a new discussion on GitHub.
How to create private objects when using locators?
in Help Center
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,
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,
0
Comments
-
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,
- Mark0 -
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.
- Mark0 -
So it's the <Adapter>.Proxy property that causes it
to be registered in name space? Here's the config file.
Hello.Proxy=hello@HelloAdapter
Hello.Endpoints=tcp:udp:ssl
Hello.AdapterId=HelloAdapter
Ice.Default.Locator=IcePack/Locator:default -p 10006
So this will register under name "hello@HelloAdapter"? 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);
0 -
JohnB wrote:So it's the <Adapter>.Proxy property that causes it to be registered in name space?
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.
- Mark0 -
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.0 -
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.
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.
- Mark0