Interface IContainer

All Superinterfaces:
org.eclipse.core.runtime.IAdaptable, IIdentifiable
All Known Subinterfaces:
IChatRoomContainer, IReliableContainer, ISharedObjectContainer
All Known Implementing Classes:
AbstractClientContainer, AbstractContainer, AbstractDiscoveryContainerAdapter, BaseContainer, ClientSOContainer, CompositeDiscoveryContainer, DatashareContainer, DnsSdDiscoveryAdvertiser, DnsSdDiscoveryContainerAdapter, DnsSdDiscoveryLocator, GenericServerContainer, JMDNSDiscoveryContainer, JSLPDiscoveryContainer, RemoteServiceContainer, RestClientContainer, RpcClientContainer, ServerSOContainer, SingletonDiscoveryContainer, SOContainer, TCPClientSOContainer, TCPServerSOContainer, XMPPContainer, XMPPSContainer, ZooDiscoveryContainer

public interface IContainer
extends org.eclipse.core.runtime.IAdaptable, IIdentifiable

Contract for ECF communications container

IContainer instances are used by clients to define a context for communications.

The typical life cycle of an ECF communications container is:

  1. Create an IContainer instance via a ContainerFactory
  2. Optional: Setup client-specific protocol adapters for communicating via specific protocols
  3. Connect the container to a remote process or group
  4. Engage in communication via protocol adapters
  5. Disconnect
For example, to create and connect an ECF "generic client":
 // Create container instance via factory
 IContainer container = ContainerFactory.getDefault().createContainer(
 // Get presence protocol adapter
 IPresenceContainerAdapter presence = (IPresenceContainerAdapter) container
 // ... setup presence listeners and local input here using presence
 // Connect
 container.connect(target, targetConnectContext);
 // Engage in appropriate communications here using protocol adapter(s)
 // Manage protocol adapters as needed when finished
 // Disconnect

Method Summary
 void addListener(IContainerListener listener)
          Add listener to IContainer.
 void connect(ID targetID, IConnectContext connectContext)
          Connect to a target remote process or process group.
 void disconnect()
 void dispose()
          Dispose this IContainer instance.
 java.lang.Object getAdapter(java.lang.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 connect(ID, IConnectContext).
 void removeListener(IContainerListener listener)
          Remove listener from IContainer.
Methods inherited from interface org.eclipse.ecf.core.identity.IIdentifiable

Method Detail


void connect(ID targetID,
             IConnectContext connectContext)
             throws ContainerConnectException
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.

targetID - the ID of the remote server or group to connect to. See 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.
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.


ID getConnectedID()
Get the target ID that this container instance has connected to. Returns null if not connected.

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


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

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


void disconnect()
Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return null.


java.lang.Object getAdapter(java.lang.Class serviceType)
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
 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
serviceType - the service type to look up
the service instance castable to the given class, or null if this container does not support the given service


void dispose()
Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.


void addListener(IContainerListener listener)
Add listener to IContainer. The listener's handleEvent method will be synchronously called when container methods are called. Minimally, the events delivered to the listener are as follows
container action Event
connect start IContainerConnectingEvent
connect complete IContainerConnectedEvent
disconnect start IContainerDisconnectingEvent
disconnect complete IContainerDisconnectedEvent

listener - the IContainerListener to add


void removeListener(IContainerListener listener)
Remove listener from IContainer.

listener - the IContainerListener to remove