Ice Reference Documentation
<<< Previous | Slice Documentation | Next >>>

# `Ice::ServantLocator`

## Overview

    local interface ServantLocator

The servant locator, which is called by the object adapter to locate a servant that is not found in its active servant map.

### Derived Classes and Interfaces

::Freeze::Evictor

### Used By

`ObjectAdapter::addServantLocator`, `ObjectAdapter::findServantLocator`

### See Also

`ObjectAdapter`, `ObjectAdapter::addServantLocator`, `ObjectAdapter::findServantLocator`

### Operation Index

`locate`

  Called by the object adapter before a request is made when a servant cannot be found in the object adapter's active servant map.

`finished`

  Called by the object adapter after a request has been made.

`deactivate`

  Called when the object adapter in which this servant locator is installed is deactivated.

## `locate`

    Object locate(Current curr,
        out LocalObject cookie);

Called by the object adapter before a request is made when 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 this is desired.

| If you call `locate` from your own code, you must also call `finished` when you have finished using the servant, provided that a non-null servant was returned. Otherwise you will get undefined behavior if you use Servant Locators such as the `::Freeze::Evictor`.

### Parameters

`curr`

  Information about the current operation for which a servant is required.

`cookie`

  A "cookie" that will be passed to `finished`.

### Return Value

The located servant, or null if no suitable servant has been found.

### See Also

`ObjectAdapter`, `Current`, `finished`

## `finished`

    void finished(Current curr,
        Object servant,
        LocalObject cookie);

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.

### Parameters

`curr`

  Information about the current operation call for which a servant was located by `locate`.

`servant`

  The servant that was returned by `locate`.

`cookie`

  The cookie that was returned by `locate`.

### See Also

`ObjectAdapter`, `Current`, `locate`

## `deactivate`

    void deactivate(string category);

Called when the object adapter in which this servant locator is installed is deactivated.

### Parameters

`category`

  Indicates for which category the servant locator is being deactivated.

### See Also

`ObjectAdapter::deactivate`, `Communicator::shutdown`, `Communicator::destroy`

<<< Previous | Home | Next >>>
`Ice::SecurityException` | Up | `Ice::ServerNotFoundException`