Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-08-2005
RyanFogarty RyanFogarty is offline
Registered User
 
 
Join Date: Aug 2003
Location: Newport, RI
Posts: 23
AdapterIds and Indirect proxies, and IcePack's Locator service

Hey Ice guys,

I wonder if you could clarify a couple of things I am struggling with?

When I create an adapter that will manage indirect proxies with either:

Code:
communicator->createObjectAdapterWithEndpoints("name",endpoint); // this
communicator->createObjectAdapter("name"); // or this
What I've gathered from posts and the manual is that the Ice runtime goes searching through the config file for a "name.AdapterId" property (and the "name.Endpoints" in the case of the second call). If it finds the AdapterId property it automatically registers the ObjectAdapter with the IcePack Locator service? In addition, if it finds this property the ObjectAdapter will now implictly create indirect proxies.

Are those proxies, always fully specified as an ObjectID@AdapterID proxy type? Assuming this is the case, is it correct that a client call (on this proxy) calls the Locator service and first attempts to find an endpoint with the Object identity in its registry then if this fails attempts to find the endpoint with the Object Adapter identity?

Also, am I reading it correctly that to do this programmatically (and thus avoid having the AdapterId in the config file) that I can call myAdapter->setLocator(communicator->getLocator()) before activating the myAdapter? If this is not the case is there another way to programmatically make an ObjectAdapter add itself to the Locator service?

Regards,
Ryan
Reply With Quote
  #2 (permalink)  
Old 03-09-2005
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,534
Quote:
Originally Posted by RyanFogarty
What I've gathered from posts and the manual is that the Ice runtime goes searching through the config file for a "name.AdapterId" property (and the "name.Endpoints" in the case of the second call). If it finds the AdapterId property it automatically registers the ObjectAdapter with the IcePack Locator service? In addition, if it finds this property the ObjectAdapter will now implictly create indirect proxies.
Correct, the object adapter endpoints will be registered with the Locator service when the object adapter is activated the first time.

Quote:
Originally Posted by RyanFogarty
Are those proxies, always fully specified as an ObjectID@AdapterID proxy type?
Yes.

Quote:
Originally Posted by RyanFogarty
Assuming this is the case, is it correct that a client call (on this proxy) calls the Locator service and first attempts to find an endpoint with the Object identity in its registry then if this fails attempts to find the endpoint with the Object Adapter identity?
No, that's not really correct. When a client invokes on an indirect proxy and there's no underlying connection already established, the Ice runtime will try to resolve the endpoints of the indirect proxy:
  • If the proxy is an "ObjectId@AdapterId" proxy, then the Ice runtime will call the locator service to retrieve the endpoints of the object adapter with the id "AdapterId". If "AdapterId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "AdapterId" is known to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
  • If the proxy is an "ObjectId" proxy, the Ice runtime will call the locator service to retrieve the endpoints associated to the identity "ObjectId". If "ObjectId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "ObjectId" is know to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.

Quote:
Originally Posted by RyanFogarty
Also, am I reading it correctly that to do this programmatically (and thus avoid having the AdapterId in the config file) that I can call myAdapter->setLocator(communicator->getLocator()) before activating the myAdapter? If this is not the case is there another way to programmatically make an ObjectAdapter add itself to the Locator service?
No, calling setLocator on your object adapter will just inform the object adapter that it should use a specific locator to eventually register its endpoints. If you want to set the AdapterId programatically, you need to set the properties before creating the object adapter:

Code:
  Ice::PropertiesPtr properties = communicator->getProperties();
  properties->setProperty("name.AdapterId", "AdapterId");
  properties->setProperty("name.Endpoints", "default");
  Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("name");
Hope this helps!

Benoit.
Reply With Quote
  #3 (permalink)  
Old 03-09-2005
RyanFogarty RyanFogarty is offline
Registered User
 
 
Join Date: Aug 2003
Location: Newport, RI
Posts: 23
Quote:
  • If the proxy is an "ObjectId@AdapterId" proxy, then the Ice runtime will call the locator service to retrieve the endpoints of the object adapter with the id "AdapterId". If "AdapterId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "AdapterId" is known to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
  • If the proxy is an "ObjectId" proxy, the Ice runtime will call the locator service to retrieve the endpoints associated to the identity "ObjectId". If "ObjectId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "ObjectId" is know to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
I see, so the only time an Object Identity is to be used on the Locator service is during a specific call of the form stringToProxy("ObjectId")? Ok that also clarifies why the manual calls this the bootstrap way of doing things.

Quote:
No, calling setLocator on your object adapter will just inform the object adapter that it should use a specific locator to eventually register its endpoints. If you want to set the AdapterId programatically, you need to set the properties before creating the object adapter:
Ahhhh.... very sneaky.

Thanks a bunch,
Ryan
Reply With Quote
  #4 (permalink)  
Old 10-13-2005
claykunz claykunz is offline
Registered User
 
Name: Clay Kunz
Organization: MIT
Project: robotics
 
Join Date: Jul 2005
Location: Cambridge, MA
Posts: 12
Question Can you set the adapter id via setProperty after the communicator is initialized?

I had the same question about setting up an adapter to register itself with IcePack, without needing an entry in the properties file. The solution mentioned below grabs the PropertiesPtr from the communicator, adds the adapter info (id and endpoints) to the properties object, then asks the communicator to create the adapter. Sounds good so far.

Except that in section 27.8.2 of the manual, it says that you can't be guaranteed that any properties set after the communicator has been initialized will be noticed by the communicator. It then suggests that I get the properties before the communicator is initialied (using getDefaultProperties) and then initializing the communicator with them. That's quite a bit clunkier than the solution suggested in this thread, and I'd rather do it the way suggested.

actually, what I'd rather do is call a non-existent function:

communicator->createObjectAdapterWithEverything(name, id, endpoints)
__________________
Clay Kunz

MIT/WHOI Joint Program
(Using ICE for IPC on autonomous underwater vehicles)
Reply With Quote
  #5 (permalink)  
Old 10-13-2005
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: 971
Hi Clay,

It is perfectly acceptable to set the AdapterId property just prior to calling createObjectAdapter (or createObjectAdapterWithEndpoints). The text you mentioned in section 27.8.2 is really referring to properties that the communicator checks once during initialization (such as tracing, plugins, etc.) and never checks again.

Take care,
- Mark
Reply With Quote
  #6 (permalink)  
Old 10-19-2005
borax00 borax00 is offline
Registered User
 
Name: Alex Brooks
Organization: Australian Centre for Field Robotics
Project: Orca Robotics (http://orca-robotics.sf.net)
 
Join Date: Oct 2005
Posts: 49
Re: Can you set the adapter id via setProperty after the communicator is initialized?

Hi Mark,

I have a similar problem to Clay's. I'd like to programatically set the location of IcePack before registering an adapter. I read Section 27.8.2 of the manual, but I can't do what is suggested there (the getDefaultProperties trick) because I'm trying to write an IceBox service and therefore can't write any code that will be executed before the communicator is initialized.

I understood from your post that I could just set the properties I need despite what it says in Section 27.8.2 of the manual, but it doesn't seem to work.

My code looks like this:

// set property
Ice::PropertiesPtr properties = communicator->getProperties();
properties->setProperty( "Ice.Default.Locator", "<location>" )

// [ ... ]

// create the adapter
adapter = communicator->createObjectAdapter(adapterName);

But the property doesn't seem to get read, and the adapter doesn't register with IcePack. Any ideas what's happening?

Thanks in advance.
__________________
Alex Brooks
Australian Centre for Field Robotics
University of Sydney
www.cas.edu.au
project: orca-robotics.sf.net
Reply With Quote
  #7 (permalink)  
Old 10-19-2005
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,534
The Ice.Default.Locator property is a communicator property. The communicator reads it when it's initialized to set its default locator proxy. You can get this proxy using the Ice::Communicator::getDefaultLocator() method. And you can also set it explicitly with the Ice::Communicator::setDefaultLocator() method.

If you want your object adapter to use another locator than the communicator default locator proxy, you have the following option:
  • Set the <name>.Locator property (where <name> if the name of your object adapter) before creating the object adapter.
  • Change the object adapter locator after its creation with the Ice::ObjectAdapter::setLocator() method.

Benoit.
Reply With Quote
  #8 (permalink)  
Old 10-19-2005
borax00 borax00 is offline
Registered User
 
Name: Alex Brooks
Organization: Australian Centre for Field Robotics
Project: Orca Robotics (http://orca-robotics.sf.net)
 
Join Date: Oct 2005
Posts: 49
Benoit,

Thanks, this did the trick!

I implemented the first option (setting the <name>.Locator property).

For some reason this wouldn't work until I also set Ice.Default.Locator to the same value. Not sure why.
__________________
Alex Brooks
Australian Centre for Field Robotics
University of Sydney
www.cas.edu.au
project: orca-robotics.sf.net
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
indirect reference to use Plugin Greenhippo Help Center 8 12-11-2006 10:16 PM
indirect proxy and ObjectNotExistException rc_hz Comments 6 12-06-2006 08:14 AM
how to get endpoints from an indirect proxy? n2503v Help Center 2 01-24-2006 02:56 AM
Forcing reevalutation of an indirect proxy Nis Baggesen Help Center 1 12-29-2005 01:33 PM
Indirect Binding Jennie Help Center 2 11-05-2004 03:19 PM


All times are GMT -4. The time now is 06:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.