Package org.eclipse.ecf.remoteservice

## Class AbstractRSAContainer

- java.lang.Object
- - org.eclipse.ecf.core.AbstractContainer
  - - org.eclipse.ecf.remoteservice.AbstractRSAContainer

All Implemented Interfaces:
  `org.eclipse.core.runtime.IAdaptable`, `IContainer`, `IIdentifiable`

    public abstract class AbstractRSAContainer
    extends AbstractContainer

Abstract container that is intended for use by RSA distribution providers. Subclasses may extend and override to create custom container adapter types. By default, an instance of RSARemoteServiceContainerAdapter is created by this class upon construction.

Since:
  8.9

### Constructor Summary

Constructors
`AbstractRSAContainer​(ID id)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `connect​(ID targetID, IConnectContext connectContext)` Connect to a target remote process or process group.
`protected RSARemoteServiceContainerAdapter` `createContainerAdapter()`
`void` `disconnect()` Disconnect.
`void` `dispose()` Dispose this IContainer instance.
`protected abstract Map<String,​Object>` `exportRemoteService​(RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration registration)` Export an endpoint specified by the RSARemoteServiceRegistration.
`Object` `getAdapter​(Class serviceType)` This specialization of IAdaptable.getAdapter() returns additional services supported by this container.
`ID` `getConnectedID()` Get the target ID that this container instance has connected to.
`Namespace` `getConnectNamespace()` Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls to `IContainer.connect(ID, IConnectContext)`.
`ID` `getID()` Return the ID for this 'identifiable' object.
`protected abstract void` `unexportRemoteService​(RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration registration)` Unregister the endpoint for the given RSARemoteServiceRegistration.

### Methods inherited from class org.eclipse.ecf.core.AbstractContainer

`addListener, fireContainerEvent, getPasswordFromConnectContext, removeListener`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractRSAContainer

    public AbstractRSAContainer​(ID id)

### Method Detail

#### exportRemoteService

    protected abstract Map<String,​Object> exportRemoteService​(RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration registration)

Export an endpoint specified by the RSARemoteServiceRegistration. Subclasses must implement to respond to a remote service export. This method will be called by the ECF RemoteServiceAdmin.exportService when this container should handle the export.

Parameters:
  `registration` - the RSARemoteServiceRegistration that is being registered. Will not be `null`.
Returns:
  Map of extra properties to add to the RSA EndpointDescription. Any properties in the returned map will override or add to the endpoint description. For example, if one of the properties in the returned Map is a String value for the key 'ecf.endpoint.id', then the value from the map will override this property in the endpoint description. The result may be `null`, in which case no properties will be overridden or added.

#### unexportRemoteService

    protected abstract void unexportRemoteService​(RSARemoteServiceContainerAdapter.RSARemoteServiceRegistration registration)

Unregister the endpoint for the given RSARemoteServiceRegistration. Subclasses must implement to respond to a remote service export. This method will be called when a remote service is unregistered, or unexported.

Parameters:
  `registration` - the registration identifying the remote service to unregister. Will not be `null`.

#### createContainerAdapter

    protected RSARemoteServiceContainerAdapter createContainerAdapter()

#### connect

    public void connect​(ID targetID,
                        IConnectContext connectContext)
                 throws ContainerConnectException

Description copied from interface: `IContainer`
Connect to a target remote process or process group. The target identified by the first parameter (targetID) is connected the implementation class. If authentication information is required, the required information is given via via the second parameter (connectContext). Callers note that depending upon the provider implementation this method may block. It is suggested that callers use a separate thread to call this method. This method provides an implementation independent way for container implementations to connect, authenticate, and communicate with a remote service or group of services. Providers are responsible for implementing this operation in a way appropriate to the given remote service (or group) via expected protocol.

Parameters:
  `targetID` - the ID of the remote server or group to connect to. See `IContainer.getConnectNamespace()` for a explanation of the constraints upon this parameter.
  `connectContext` - any required context to allow this container to authenticate. May be `null` if underlying provider does not have any authentication requirements for connection.
Throws:
  `ContainerConnectException` - thrown if communication cannot be established with remote service. Causes can include network connection failure, authentication failure, server error, or if container is already connected.

#### getConnectedID

    public ID getConnectedID()

Description copied from interface: `IContainer`
Get the target ID that this container instance has connected to. Returns null if not connected.

Returns:
  ID of the target we are connected to. Returns `null` if container not connected.

#### getConnectNamespace

    public Namespace getConnectNamespace()

Description copied from interface: `IContainer`
Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls to `IContainer.connect(ID, IConnectContext)`. If this method returns `null`, then it means that `null` is expected as a valid parameter in subsequent calls to `IContainer.connect(ID, IConnectContext)`. If this method returns a non-`null` Namespace, then the `targetID` parameter in `IContainer.connect(ID, IConnectContext)` must be non-`null` instance created of the returned Namespace.

Returns:
  Namespace the namespace associated with subsequent calls to `IContainer.connect(ID, IConnectContext)`. If `null`, then the `targetID` instances passed to `IContainer.connect(ID, IConnectContext)` may be `null`. If not `null`, then `targetID` instances passed to `IContainer.connect(ID, IConnectContext)` must be instances of the returned Namespace.

#### disconnect

    public void disconnect()

Description copied from interface: `IContainer`
Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return `null`.

#### getID

    public ID getID()

Description copied from interface: `IIdentifiable`
Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May return `null`.

Returns:
  the ID for this identifiable object. May return `null`.

#### dispose

    public void dispose()

Description copied from interface: `IContainer`
Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.

Specified by:
  `dispose` in interface `IContainer`
Overrides:
  `dispose` in class `AbstractContainer`

#### getAdapter

    public Object getAdapter​(Class serviceType)

Description copied from interface: `IContainer`
This specialization of IAdaptable.getAdapter() returns additional services supported by this container. A container that supports additional services over and above the methods on `IContainer` should return them using this method. It is recommended that clients use this method rather than instanceof checks and downcasts to find out about the capabilities of a specific container.

Typically, after obtaining an IContainer, a client would use this method as a means to obtain a more meaningful interface to the container. This interface may or may not extend IContainer. For example, a client could use the following code to obtain an instance of ISharedObjectContainer:

     IContainer newContainer = ContainerFactory.createContainer(type);
     ISharedObjectContainer soContainer = (ISharedObjectContainer) newContainer
                    .getAdapter(ISharedObjectContainer.class);
     if (soContainer == null)
            throw new ContainerCreateException(message);

Implementations of this method should delegate to `IAdapterManager.loadAdapter()` if the service cannot be provided directly to ensure extensibility by third-party plug-ins.

Specified by:
  `getAdapter` in interface `org.eclipse.core.runtime.IAdaptable`
Specified by:
  `getAdapter` in interface `IContainer`
Overrides:
  `getAdapter` in class `AbstractContainer`
Parameters:
  `serviceType` - the service type to look up
Returns:
  the service instance castable to the given class, or `null` if this container does not support the given service