Archived

This forum has been archived. Please start a new discussion on GitHub.

Getting the ObjectAdapter After It Has Been Created

Is there a way a to get the ObjectAdapter after it has been created via a "communicator().createObjectAdapter()" call?

I am writing the GUI side to an Ice server. I want my GUI classes to be completely decoupled from the main GUI class that creates the ObjectAdapter. Right now, I have to pass in the Adapter object but would prefer a getObjectAdapter( name ) method.

Comments

  • You can get at the adapter that was used to dispatch an operation by looking at the Current object that is passed to the operation. It contains an adapter member that provides access to the adapter. Obviously, to do this, you must be within the context of an executing operation.

    If you need the object adapter outside the context of an executing operation, you will have to pass it around, I'm afraid. That's because the Ice run time cannot know which one of the (possibly many) adapters you need.

    Cheers,

    Michi.
  • I seem to remember that an ObjectAdapter's name is kept in a hash somewhere. It also appears that one cannot init two Object Adapters with the same name. Based on that, couldn't one get the ObjectAdapter based on the name (provided the API was modified)?
  • Yes, Ice keeps track of adapters internally. However, there is currently no findAdapter() operation or some such on the communicator. However, if we were to add such an operation, would that really solve your problem? You then would have to pass the name of the adapter around, instead of the adapter itself, which seems to be little different?

    Cheers,

    Michi.
  • I agree. I will continue to pass the ObjectAdapter in. Thanks.