Ice.ObjectAdapter¶
- final class Ice.ObjectAdapter(impl: ObjectAdapter)¶
Bases:
objectThe object adapter provides an up-call interface from the Ice runtime to the implementation of Ice objects.
The object adapter is responsible for receiving requests from endpoints, and for mapping between servants, identities, and proxies.
- Parameters:
impl (IcePy.ObjectAdapter)
- activate() None¶
Activate all endpoints that belong to this object adapter.
After activation, the object adapter can dispatch requests received through its endpoints.
- Return type:
None
- add(servant: Object, id: Identity) ObjectPrx¶
Add a servant to this object adapter’s Active Servant Map.
Note that one servant can implement several Ice objects by registering the servant with multiple identities. Adding a servant with an identity that is already in the map throws AlreadyRegisteredException.
- addDefaultServant(servant: Object, category: str) None¶
Add a default servant to handle requests for a specific category.
Adding a default servant for a category for which a default servant is already registered throws AlreadyRegisteredException. To dispatch operation calls on servants, the object adapter tries to find a servant for a given Ice object identity and facet in the following order:
The object adapter tries to find a servant for the identity and facet in the Active Servant Map.
If no servant has been found in the Active Servant Map, the object adapter tries to find a default servant for the category component of the identity.
If no servant has been found by any of the preceding steps, the object adapter tries to find a default servant for an empty category, regardless of the category contained in the identity.
If no servant has been found by any of the preceding steps, the object adapter gives up and the caller receives ObjectNotExistException or FacetNotExistException.
- addFacet(servant: Object, id: Identity, facet: str = '') ObjectPrx¶
Add a servant with a facet to this object adapter’s Active Servant Map.
Calling add(servant, id) is equivalent to calling addFacet with an empty facet.
- Parameters:
- Returns:
A proxy that matches the given identity, facet, and this object adapter.
- Return type:
- addFacetWithUUID(servant: Object, facet: str) ObjectPrx¶
Add a servant with a facet to this object adapter’s Active Servant Map, using an automatically generated UUID as its identity.
Calling addWithUUID(servant) is equivalent to calling addFacetWithUUID with an empty facet.
- addServantLocator(locator: ServantLocator, category: str) None¶
Add a Servant Locator to this object adapter.
Adding a servant locator for a category for which a servant locator is already registered throws AlreadyRegisteredException. To dispatch operation calls on servants, the object adapter tries to find a servant for a given Ice object identity and facet in the following order:
The object adapter tries to find a servant for the identity and facet in the Active Servant Map.
If no servant has been found in the Active Servant Map, the object adapter tries to find a servant locator for the category component of the identity. If a locator is found, the object adapter tries to find a servant using this locator.
If no servant has been found by any of the preceding steps, the object adapter tries to find a locator for an empty category, regardless of the category contained in the identity. If a locator is found, the object adapter tries to find a servant using this locator.
If no servant has been found by any of the preceding steps, the object adapter gives up and the caller receives ObjectNotExistException or FacetNotExistException.
Only one locator for the empty category can be installed.
- Parameters:
locator (ServantLocator) – The locator to add.
category (str) – The category for which the Servant Locator can locate servants, or an empty string if the Servant Locator does not belong to any specific category.
- Return type:
None
- addWithUUID(servant: Object) ObjectPrx¶
Add a servant to this object adapter’s Active Servant Map, using an automatically generated UUID as its identity.
Note that the generated UUID identity can be accessed using the proxy’s ice_getIdentity operation.
- createDirectProxy(id: Identity) ObjectPrx¶
Create a direct proxy for the object with the given identity.
The returned proxy contains this object adapter’s published endpoints.
- createIndirectProxy(id: Identity) ObjectPrx¶
Create an indirect proxy for the object with the given identity.
If this object adapter is configured with an adapter ID, the return value refers to the adapter ID. Otherwise, the return value contains only the object identity.
- createProxy(id: Identity) ObjectPrx¶
Create a proxy for the object with the given identity.
If this object adapter is configured with an adapter ID, the return value is an indirect proxy that refers to the adapter ID. If a replica group ID is also defined, the return value is an indirect proxy that refers to the replica group ID. Otherwise, if no adapter ID is defined, the return value is a direct proxy containing this object adapter’s published endpoints.
- deactivate() None¶
Deactivates this object adapter: stop accepting new connections from clients and close gracefully all incoming connections created by this object adapter once all outstanding dispatches have completed.
If this object adapter is indirect, this method also unregisters the object adapter from the Locator. This method does not cancel outstanding dispatches–it lets them execute until completion. A new incoming request on an existing connection will be accepted and can delay the closure of the connection. A deactivated object adapter cannot be reactivated again; it can only be destroyed.
- Return type:
None
- destroy() None¶
Destroys this object adapter and cleans up all resources held by this object adapter.
Once this method has returned, it is possible to create another object adapter with the same name.
- Return type:
None
- find(id: Identity) Object | None¶
Look up a servant in this object adapter’s Active Servant Map by the identity of the Ice object it implements.
This operation only tries to look up a servant in the Active Servant Map. It does not attempt to find a servant by using any installed ServantLocator.
- findAllFacets(id: Identity) dict[str, Object]¶
Find all facets with the given identity in the Active Servant Map.
- findByProxy(proxy: ObjectPrx) Object | None¶
Look up a servant in this object adapter’s Active Servant Map, given a proxy.
This operation only tries to look up a servant in the Active Servant Map. It does not attempt to find a servant by using any installed ServantLocator.
- findFacet(id: Identity, facet: str) Object | None¶
Look up a servant in this object adapter’s Active Servant Map by the identity and facet of the Ice object it implements.
Calling find(id) is equivalent to calling findFacet with an empty facet.
- Parameters:
- Returns:
The servant that implements the Ice object with the given identity and facet, or None if no such servant has been found.
- Return type:
Object | None
- findServantLocator(category: str) ServantLocator | None¶
Find a Servant Locator installed with this object adapter.
- Parameters:
category (str) – The category for which the Servant Locator can locate servants, or an empty string if the Servant Locator does not belong to any specific category.
- Returns:
The Servant Locator, or None if no Servant Locator was found for the given category.
- Return type:
ServantLocator | None
- getCommunicator() Communicator¶
Get the communicator this object adapter belongs to.
- Returns:
The communicator this object adapter belongs to.
- Return type:
- getEndpoints() tuple[Endpoint, ...]¶
Get the set of endpoints configured with this object adapter.
- Returns:
The set of endpoints.
- Return type:
tuple[IcePy.Endpoint, …]
- getLocator() LocatorPrx | None¶
Get the Ice locator used by this object adapter.
- Returns:
The locator used by this object adapter, or None if no locator is used by this object adapter.
- Return type:
LocatorPrx | None
- getName() str¶
Get the name of this object adapter.
- Returns:
The name of this object adapter.
- Return type:
- getPublishedEndpoints() tuple[Endpoint, ...]¶
Get the set of endpoints that proxies created by this object adapter will contain.
- Returns:
The set of published endpoints.
- Return type:
tuple[IcePy.Endpoint, …]
- hold() None¶
Temporarily hold receiving and dispatching requests.
The object adapter can be reactivated with the activate operation. Holding is not immediate; i.e., after hold returns, the object adapter might still be active for some time. You can use waitForHold to wait until holding is complete.
- Return type:
None
- isDeactivated() bool¶
Checks if this object adapter has been deactivated.
- Returns:
True if deactivate has been called on this object adapter; otherwise, False.
- Return type:
- remove(id: Identity) Object¶
Remove a servant (that is, the default facet) from the object adapter’s Active Servant Map.
Removing an identity that is not in the map throws NotRegisteredException.
- removeAllFacets(id: Identity) dict[str, Object]¶
Remove all facets with the given identity from the Active Servant Map.
The operation completely removes the Ice object, including its default facet. Removing an identity that is not in the map throws NotRegisteredException.
- removeDefaultServant(category: str) Object¶
Remove the default servant for a specific category.
Attempting to remove a default servant for a category that is not registered throws NotRegisteredException.
- removeFacet(id: Identity, facet: str) Object¶
Remove a servant with a facet from the object adapter’s Active Servant Map.
Calling remove(id) is equivalent to calling removeFacet with an empty facet.
- removeServantLocator(category: str) ServantLocator¶
Remove a Servant Locator from this object adapter.
- Parameters:
category (str) – The category for which the Servant Locator can locate servants, or an empty string if the Servant Locator does not belong to any specific category.
- Returns:
The Servant Locator.
- Return type:
- Raises:
NotRegisteredException – If no Servant Locator was found for the given category.
- setLocator(locator: LocatorPrx) None¶
Set an Ice locator for this object adapter.
By doing so, the object adapter will register itself with the locator registry when it is activated for the first time. Furthermore, the proxies created by this object adapter will contain the adapter identifier instead of its endpoints. The adapter identifier must be configured using the AdapterId property.
- Parameters:
locator (LocatorPrx) – The locator used by this object adapter.
- Return type:
None
- setPublishedEndpoints(newEndpoints: tuple[Endpoint, ...] | list[Endpoint]) None¶
Set the endpoints that proxies created by this object adapter will contain.