Ice.ServantLocator¶
- class Ice.ServantLocator¶
Bases:
ABCA servant locator is called by an object adapter to locate a servant that is not found in its active servant map.
- abstractmethod deactivate(category: str)¶
Called when the object adapter in which this servant locator is installed is destroyed.
- Parameters:
category (str) – Indicates for which category the servant locator is being deactivated.
- abstractmethod finished(current: Current, servant: Object, cookie: object | None)¶
Called by the object adapter after a request has been made.
This operation is only called if locate was called prior to the request and returned a non-null servant. This operation can be used for cleanup purposes after a request.
The finished method can throw any user exception. If it does, that exception is marshaled back to the client. If the Slice definition for the corresponding operation includes that user exception, the client receives that user exception; otherwise, the client receives UnknownUserException. If both the operation and finished throw an exception, the exception thrown by finished is marshaled back to the client.
- Parameters:
- Raises:
UserException – The implementation can raise a UserException and the runtime will marshal it as the result of the invocation.
- abstractmethod locate(current: Current) tuple[Object | None, object | None]¶
Called before a request is dispatched if a servant cannot be found in the object adapter’s active servant map.
Note that the object adapter does not automatically insert the returned servant into its active servant map. This must be done by the servant locator implementation, if desired. The locate method can throw any user exception. If it does, that exception is marshaled back to the client. If the Slice definition for the corresponding operation includes that user exception, the client receives that user exception; otherwise, the client receives UnknownUserException.
If locate throws any exception, the Ice runtime does not call finished. If you call locate from your own code, you must also call finished when you have finished using the servant, provided that locate returned a non-null servant.
- Parameters:
current (Current) – Information about the current operation for which a servant is required.
- Returns:
- A tuple containing the following:
- retvalObject or None
The located servant, or None if no suitable servant has been found.
- cookieobject | None
A “cookie” that will be passed to finished.
- Return type:
- Raises:
UserException – The implementation can raise a UserException and the runtime will marshal it as the result of the invocation.