Eclipse Communication Framework (ECF)

ECF Containers

ECF introduces the concept of a communications container. ECF containers represent access to a protocol-specific communications context. For connection-oriented communications, an ECF container loosely corresponds to the traditional notion of a communications session, but the more general container concept is also useful for capturing context even if the communications are non connection-oriented.

ECF containers can represent both point-to-point communications (e.g. client/server) or publish-and-subscribe (group) communications. Container instances can provide access to synchronous communications only, asynchronous communications only, or both together. This flexibility allows many communications applications to be constructed out of one or more containers...each of which provides access to some specific communications context and some protocol for communicating within that context.

Instance Creation

Container instance creation is done via ECF-provided factory APIs. For example, here's code to create and IContainer instance:
       IContainer container = ContainerFactory.getDefault().createContainer("containertype");
       
Once constructed, IContainer instances may be used in the manner appropriate for the given application. When no longer required the IContainer.dispose() method should be called to release any resources associated with the container instance upon construction.

Container Connection/Disconnection

The IContainer interface exposes two key methods: connect(ID targetID, IConnectContect connectContext) and disconnect(). As is obvious, these two methods allow container implementations to initiate communication with remote services, either server-based or group-based communications.

Notice the first parameter to the connect method...targetID. TargetID is of type ID. The targetID parameter identifies the target server or group for the connect operation. It is of type ID so that the to allow the target communications service to be of many kinds...e.g. client-server or peer-to-peer. For example, for http communication the targetID would consist of the URL specifying a particular file at a particular path on a particular server...e.g: http://www.eclipse.org/ecf. For some other communications protocol the ID provided would be different...e.g: sip:someone@example.com;transport=tcp. All such targets for connect may be represented via an instance of the ID interface.

Example Container Creation and Connection Code

Here's an example code snippet that shows the creation and connection of an ECF container:
       // make container instance
       IContainer cont = ContainerFactory.getDefault().createContainer("ecf.generic.client");
       // make targetID
       ID targetID = IDFactory.getDefault().createID(cont.getConnectNamespace(),"ecftcp://ecf1.osuosl.org:3282/server");
       // then connect to targetID
       cont.connect(targetID,null);
       

Container Extensibility through Adapters

In order to support run-time extensibility, the IContainer interface inherits from org.eclipse.core.runtime.IAdaptable. This interface exposes the 'getAdapter(Class intf)' method. In the case of IContainer instances, this allows clients to query the container at runtime about it's exposed interfaces, and get access to those interfaces if available. So, for example, perhaps we're interested in creating an instant messaging application and wish to use the capabilities exposed by the IPresenceContainer interface. To do this, we simply query the IContainer instance at runtime to see if it provides access to IPresenceContainer capabilities:
       IPresenceContainer pc = (IPresenceContainer) cont.getAdapter(IPresenceContainer.class);
       if (pc != null) {
           // The container DOES expose IPresenceContainer capabilities, so we can use them!
       } else {
           // The container does NOT expose IPresenceContainer capabilities...we're out of luck
       }
       
Among other positive characteristics, this adapter mechanism provides a consistent-yet-simple way for a wide variety of container types to be defined and used without the need to update the ECF IContainer abstractions.

UNDER CONSTRUCTION - 9/9/05