Creating an Object Adapter

ObjectAdapter Local Interface

An object adapter is an instance of the local interface ObjectAdapter.

Slice
module Ice
{
    local interface ObjectAdapter
    {
        string getName();
        Communicator getCommunicator();

        // ...
    }
}


The ObjectAdapter operations behave as follows:

  • The getName operation returns the name of the adapter as passed to one of the communicator operations createObjectAdaptercreateObjectAdapterWithEndpoints, or createObjectAdapterWithRouter.
  • The getCommunicator operation returns the communicator that was used to create the adapter.

Note that there are other operations in the ObjectAdapter interface; we will explore these throughout the remainder of this discussion.

Object Adapter Factory Operations

 You create an object adapter by calling one of several operations on Communicator:

module Ice
{
    local interface Communicator
    {
        ObjectAdapter createObjectAdapter(string name);
        ObjectAdapter createObjectAdapterWithEndpoints(string name, string endpoints);
        ObjectAdapter createObjectAdapterWithRouter(string name, Router* rtr);

        // ...
    }
}


These Communicator operations behave as follows:

  • createObjectAdapter creates a new object adapter associated with this communicator. Each object adapter is associated with zero or more transport endpointsTypically, an object adapter has a single transport endpoint.

    An object adapter can also offer multiple endpoints. If so, these endpoints each lead to the same set of objects and represent alternative means of accessing these objects. This is useful, for example, if a server is behind a firewall but must offer access to its objects to both internal and external clients; by binding the adapter to both the internal and external interfaces, the objects implemented in the server can be accessed via either interface.

    An object adapter can also have no endpoint at all. In that case, the adapter can only be reached via collocated invocations originating from the same communicator as is used by the adapter.

    An application normally needs to configure an object adapter with endpoints or a router. Calling createObjectAdapter with a non-empty value for name means the new object adapter will check the communicator's configuration for properties, using its name as prefix, including:

 createObjectAdapter raises an exception if neither is defined and name is not empty.

  Passing an empty value for name to createObjectAdapter creates a nameless object adapter that can only be used for collocated invocations or callbacks over bidirectional connections

  • createObjectAdapterWithEndpoints allows you to specify the object adapter's endpoints directly, overriding any setting for name.Endpoints. Typically, you should use createObjectAdapter in preference to createObjectAdapterWithEndpoints. Doing so keeps transport-specific information, such as host names and port numbers, out of the source code and allows you to reconfigure the application by changing a property (and so avoid recompilation when a transport endpoint needs to be changed).

  • createObjectAdapterWithRouter accepts a router proxy and overrides name.RoutercreateObjectAdapterWithRouter creates a routed object adapter that allows clients to receive callbacks from servers that are behind a router.

See Also