Difference between revisions of "ECF Connection Creation and Management"

From Eclipsepedia

Jump to: navigation, search
m (Connection creation)
 
(4 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
==Connection creation==
 
==Connection creation==
  
IContainer instances are created via instances of [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/core/IContainerFactory.html IConnectionFactory].
+
IContainer instances are created via instances of [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/core/IContainerFactory.html IContainerFactory].
  
IConnectionFactory instances can be accessed as an OSGi service, or statically:
+
IContainerFactory instances can be accessed as an OSGi service, or statically:
  
 
<pre>
 
<pre>
Line 71: Line 71:
  
 
<pre>
 
<pre>
IContainerManager containerManager = (IContainerManager) containerManagerServiceTracker.getService();
+
IContainerManager containerManager =  
 +
(IContainerManager) containerManagerServiceTracker.getService();
  
 
IContainer [] containers = containerManager.getAllContainers();
 
IContainer [] containers = containerManager.getAllContainers();
Line 94: Line 95:
  
 
[http://help.eclipse.org/ganymede/index.jsp ECF docs in Eclipse help]
 
[http://help.eclipse.org/ganymede/index.jsp ECF docs in Eclipse help]
 +
 +
 +
{{ECF}}
 +
[[Category:Eclipse Communication Framework]]
 +
[[Category:EclipseRT]]
 +
[[Category:Draft Documentation]]

Latest revision as of 12:36, 22 October 2010

Contents

[edit] Introduction

ECF's core API provides support for connection management...i.e. connection creation, connect, disconnect, entry point access to protocol-specific capabilities, platform-wide connection management, etc.

In ECF, connections are represented as implementations of the IContainer interface.

[edit] Connection creation

IContainer instances are created via instances of IContainerFactory.

IContainerFactory instances can be accessed as an OSGi service, or statically:

IContainerFactory factory = ContainerFactory.getDefault();

or

IContainerFactory factory = (IContainerFactory) factoryServiceTracker.getService();

where factoryServiceTracker is a ServiceTracker that has been setup to get the org.eclipse.ecf.core.IContainerFactory service. Once a factory is available, IContainer instances can then be created:

IContainer container = factory.createContainer("ecf.xmpp.smack");

There are a number of createContainer methods on the IContainerFactory, to support a variety of cases for creating/configuring IContainer instances.

[edit] Connection

Once an IContainer instance has be created, it may be used to first create a target ID (address), and then connect to it:

// Create targetID
ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(),"fliwatuet@ecf.eclipse.org");
// Connect
container.connect(targetID,null);

If the connect call completes successfully, the container is then connected.

[edit] Container Adapters

Either before or after the connection, the client may wish to get an adapter from the IContainer in order to communicate in specific ways supported by the implementation.

IDatashareContainerAdapter datashare = (IDatashareContainerAdapter) container.getAdapter(IDatashareContainerAdapter.class);
if (datashare != null) { 
...use 
} else {
...this provider does not implement this adapter
}

[edit] Container Listeners and Events

IContainers also expose an event notification API: IContainerListener.

container.addListener(new IContainerListener() {
    public void handleEvent(IContainerEvent event) {
        if (event instanceof IContainerConnectEvent) {
         ... do stuff upon connection
        }
    }
});

[edit] Existing Connection Management

There is a container manager OSGi service

IContainerManager containerManager = 
(IContainerManager) containerManagerServiceTracker.getService();

IContainer [] containers = containerManager.getAllContainers();
... use existing containers

[edit] Providers

ECF provider implementations are defined by two extension points:

org.eclipse.ecf.containerFactory

org.eclipse.ecf.namespace

The containerFactory extension point allows providers to define/setup their own container factory instances, and the namespace extension point allows providers to define their own namespaces (for defining ID types). See example usage on the extension point docs given above.

[edit] Reference

Core API - bundle docs

Core API - test code]

ECF docs in Eclipse help


Eclipse Communication Framework
API
API DocumentationJavadocProvidersECF/Bot Framework
Development
Development GuidelinesIntegrators Guide