Ice.ObjectAdapter¶
- final class Ice.ObjectAdapter(impl: ObjectAdapter)¶
Bases:
objectAn object adapter is the main server-side Ice API. It has two main purposes: - accept incoming connections from clients and dispatch requests received over these connections (see
activate()); andmaintain servants that handle the requests (see
add(),addDefaultServant()).
An object adapter can dispatch “bidirectional requests”–requests it receives over an outgoing connection instead of a more common incoming connection. It can also dispatch collocated requests (with no connection at all).
- Parameters:
impl (IcePy.ObjectAdapter)
- getName() str¶
Gets the name of this object adapter.
- Returns:
This object adapter’s name.
- Return type:
- getCommunicator() Communicator¶
Gets the communicator that created this object adapter.
- Returns:
This object adapter’s communicator.
- Return type:
- activate() None¶
Starts receiving and dispatching requests received over incoming connections.
Notes
When this object adapter is an indirect object adapter configured with a locator proxy, this function also registers the object adapter’s published endpoints with this locator.
- Return type:
None
- hold() None¶
Stops reading requests from incoming connections. Outstanding dispatches are not affected. The object adapter can be reactivated with
activate().Notes
This function is provided for backward compatibility with older versions of Ice. Don’t use it in new applications.
- Return type:
None
- waitForHold() None¶
Waits until the object adapter is in the holding state (see
hold()) and the dispatch of requests received over incoming connections has completed.Notes
This function is provided for backward compatibility with older versions of Ice. Don’t use it in new applications.
- Return type:
None
- deactivate() None¶
Deactivates this object adapter: stops accepting new connections from clients and closes gracefully all incoming connections created by this object adapter once all outstanding dispatches have completed. If this object adapter is indirect, this function also unregisters the object adapter from the locator (see
activate()).This function does not cancel outstanding dispatches: it lets them execute until completion. A deactivated object adapter cannot be reactivated again; it can only be destroyed.
- Return type:
None
- waitForDeactivate() None¶
Waits until
deactivate()is called on this object adapter and all connections accepted by this object adapter are closed. A connection is closed only after all outstanding dispatches on this connection have completed.- Return type:
None
- isDeactivated() bool¶
Checks whether or not
deactivate()was called on this object adapter.- Returns:
Trueifdeactivate()has been called on this object adapter,Falseotherwise.- Return type:
- destroy() None¶
Destroys this object adapter and cleans up all resources associated with it. Once this function has returned, you can recreate another object adapter with the same name.
- Return type:
None
- add(servant: Object, id: Identity) ObjectPrx¶
Adds a servant to this object adapter’s Active Servant Map (ASM). The ASM is a map {identity, facet} -> servant.
Notes
This function is equivalent to calling
addFacet()with an empty facet.- Parameters:
- Returns:
A proxy for
id, created by this object adapter.- Return type:
- Raises:
AlreadyRegisteredException – If a servant with the same identity is already registered.
- addFacet(servant: Object, id: Identity, facet: str = '') ObjectPrx¶
Adds a servant to this object adapter’s Active Servant Map (ASM), while specifying a facet. The ASM is a map {identity, facet} -> servant.
- Parameters:
- Returns:
A proxy for
idandfacet, created by this object adapter.- Return type:
- Raises:
AlreadyRegisteredException – If a servant with the same identity and facet is already registered.
- addWithUUID(servant: Object) ObjectPrx¶
Adds a servant to this object adapter’s Active Servant Map (ASM), using an automatically generated UUID as its identity.
- addFacetWithUUID(servant: Object, facet: str) ObjectPrx¶
Adds a servant to this object adapter’s Active Servant Map (ASM), using an automatically generated UUID as its identity. Also specifies a facet.
- addDefaultServant(servant: Object, category: str) None¶
Adds a default servant to handle requests for a specific category. When an object adapter dispatches an incoming request, it tries to find a servant for the identity and facet carried by the request in the following order:
The object adapter tries to find a servant for the identity and facet in the Active Servant Map.
If this fails, the object adapter tries to find a default servant for the category component of the identity.
If this fails, the object adapter tries to find a default servant for the empty category, regardless of the category contained in the identity.
If this fails, the object adapter tries to find a servant locator for the category component of the identity. If there is no such servant locator, the object adapter tries to find a servant locator for the empty category. - If a servant locator is found, the object adapter tries to find a servant using this servant locator.
If all the previous steps fail, the object adapter gives up and the caller receives an
ObjectNotExistExceptionor aFacetNotExistException.
- Parameters:
- Raises:
AlreadyRegisteredException – If a default servant with the same category is already registered.
- Return type:
None
- remove(id: Identity) Object¶
Removes a servant from the object adapter’s Active Servant Map.
- Parameters:
id (Identity) – The identity of the Ice object that is implemented by the servant.
- Returns:
The removed servant.
- Return type:
- Raises:
NotRegisteredException – If no servant with the given identity is registered.
- removeFacet(id: Identity, facet: str) Object¶
Removes a servant from the object adapter’s Active Servant Map, while specifying a facet.
- Parameters:
- Returns:
The removed servant.
- Return type:
- Raises:
NotRegisteredException – If no servant with the given identity and facet is registered.
- removeAllFacets(id: Identity) dict[str, Object]¶
Removes all facets with the given identity from the Active Servant Map. This function completely removes the Ice object, including its default facet.
- Parameters:
id (Identity) – The identity of the Ice object to be removed.
- Returns:
A collection containing all the facet names and servants of the removed Ice object.
- Return type:
- Raises:
NotRegisteredException – If no servant with the given identity is registered.
- removeDefaultServant(category: str) Object¶
Removes the default servant for a specific category.
- Parameters:
category (str) – The category of the default servant to remove.
- Returns:
The default servant.
- Return type:
- Raises:
NotRegisteredException – If no default servant is registered for the given category.
- find(id: Identity) Object | None¶
Looks up a servant.
Notes
This function only tries to find the servant in the ASM and among the default servants. It does not attempt to locate a servant using servant locators.
- findFacet(id: Identity, facet: str) Object | None¶
Looks up a servant with an identity and facet.
Notes
This function only tries to find the servant in the ASM and among the default servants. It does not attempt to locate a servant using servant locators.
- findAllFacets(id: Identity) dict[str, Object]¶
Finds all facets for a given identity in the Active Servant Map.
- findByProxy(proxy: ObjectPrx) Object | None¶
Looks up a servant with an identity and a facet. It’s equivalent to calling
findFacet().Notes
This function only tries to find the servant in the ASM and among the default servants. It does not attempt to locate a servant using servant locators.
- addServantLocator(locator: ServantLocator, category: str) None¶
Adds a ServantLocator to this object adapter for a specific category.
- Parameters:
locator (ServantLocator) – The servant locator to add.
category (str) – The category. The empty category means the locator handles all categories.
- Raises:
AlreadyRegisteredException – If a servant locator with the same category is already registered.
- Return type:
None
- removeServantLocator(category: str) ServantLocator¶
Removes a ServantLocator from this object adapter.
- Parameters:
category (str) – The category.
- Returns:
The servant locator.
- Return type:
- Raises:
NotRegisteredException – If no servant locator with the given category is registered.
- findServantLocator(category: str) ServantLocator | None¶
Finds a ServantLocator registered with this object adapter.
- Parameters:
category (str) – The category.
- Returns:
The servant locator, or
Noneif not found.- Return type:
ServantLocator | None
- createProxy(id: Identity) ObjectPrx¶
Creates a proxy from an Ice identity. If this object adapter is configured with an adapter ID, the proxy is an indirect proxy that refers to this adapter ID. If a replica group ID is also defined, the proxy is an indirect proxy that refers to this replica group ID. Otherwise, the proxy is a direct proxy containing this object adapter’s published endpoints.
- setLocator(locator: LocatorPrx) None¶
Sets an Ice locator on this object adapter.
- Parameters:
locator (LocatorPrx) – The locator used by this object adapter.
- Return type:
None
- getLocator() LocatorPrx | None¶
Gets the Ice locator used by this object adapter.
- Returns:
The locator used by this object adapter, or
Noneif no locator is used by this object adapter.- Return type:
LocatorPrx | None
- getEndpoints() tuple[Endpoint, ...]¶
Gets the set of endpoints configured on this object adapter.
Notes
This function remains usable after the object adapter has been deactivated.
- Returns:
The set of endpoints.
- Return type:
tuple[Ice.Endpoint, …]
- getPublishedEndpoints() tuple[Endpoint, ...]¶
Gets the set of endpoints that proxies created by this object adapter will contain.
Notes
This function remains usable after the object adapter has been deactivated.
- Returns:
The set of published endpoints.
- Return type:
tuple[Ice.Endpoint, …]
- setPublishedEndpoints(newEndpoints: tuple[Endpoint, ...] | list[Endpoint]) None¶
Sets the endpoints that proxies created by this object adapter will contain.
- Parameters:
newEndpoints (tuple[Ice.Endpoint, ...] | list[Ice.Endpoint]) – The new set of endpoints that the object adapter will embed in proxies.
- Raises:
RuntimeError – If
newEndpointsis empty or if this adapter is associated with a router.- Return type:
None