eclipse communication framework
an eclipse technology subproject New and Noteworthy 0.6.2 Stable Release Return to ECF download page Return to ECF communication resources page New and Noteworthy for 0.4.0 New and Noteworthy for 0.5.2 New and Noteworthy for 0.5.4 New and Noteworthy for 0.6.0 |
|
|
|
ECF API Additions and Changes |
|
Revised Datashare API |
The revised datashare API org.eclipse.ecf.datashare allows clients to create channels for distributing arbitrary data. Here's some example code showing the creation of a channel and use to distribute some test data: // Create container IContainer container = ContainerFactory.getDefault().createContainer( CHANNEL_CONTAINER); // Connect container container.connect(serverID, null); // Get IChannelContainer adapter IChannelContainer channelContainer = (IChannelContainer) container .getAdapter(IChannelContainer.class); // Create channel listener IChannelListener listener = new IChannelListener() { public void handleChannelEvent(IChannelEvent event) { System.out.println("handleChannelEvent(evt=" + event + ")"); } }; // Create channel named "mychannel" IChannel channel = channelContainer.createChannel(IDFactory.getDefault().createStringID("channel1"), listener, new HashMap()); // Send data on channel for (int i = 0; i < 10; i++) { channel.sendMessage("hello".getBytes()); Thread.sleep(200); }See the javadocs for the org.eclipse.ecf.datashare package , and the org.eclipse.ecf.datashare.events package. |
New Fileshare API |
The new Fileshare API provides clients with a mechanism for asynchronously sending and retrieving files. Here's some example code that sends a file to all of the other connected participants within the given IContainer instance: // Create container IContainer container = ContainerFactory.getDefault().createContainer( FILESHARE_CONTAINER); // Connect container container.connect(serverID, null); // Get fileshare adapter IFileShareContainer fileshareContainer = (IFileShareContainer) container .getAdapter(IFileShareContainer.class); // Create fileshare listener IFileShareListener listener = new IFileShareListener() { public void handleFileShareEvent(IFileShareEvent event) { System.out.println("handleChannelEvent(" + event + ")"); } }; // Create ID for new fileshare instance ID fileshareID = IDFactory.getDefault().createGUID(); // Create ID to specify remote file name...in this case make remote name same as local name ID remoteFileID = IDFactory.getDefault().createID( fileshareContainer.getFileNamespace(), filename); // Create fileshare instance in container IFileShare fileshare = fileshareContainer.createSender(fileshareID, new FileInputStream(filename), remoteFileID, listener, new HashMap()); // Start sending asynchronously...this actualy sends the local file 'filename' // to all in container fileshare.start();Here is example code that asynchronously retrieves a file from a web server: // Create container IContainer container = ContainerFactory.getDefault().createContainer( FILESHARE_CONTAINER); // Connect container container.connect(serverID, null); // Get fileshare adapter IFileShareContainer fileshareContainer = (IFileShareContainer) container .getAdapter(IFileShareContainer.class); // Create fileshare listener IFileShareListener listener = new IFileShareListener() { public void handleFileShareEvent(IFileShareEvent event) { // Note...here is where the retrieved file contents // Should be saved...when IFileShareRetrieveData events are received System.out.println("handleChannelEvent(" + event + ")"); } }; // Create ID for new fileshare instance ID fileshareID = IDFactory.getDefault().createGUID(); // Create ID for the remote file...e.g. fileurl = 'http://www.eclipse.org/index.html' ID fileID = IDFactory.getDefault().createID( fileshareContainer.getFileNamespace(), fileurl); // Create fileshare instance in container IFileShare fileshare = fileshareContainer.createRetriever(fileshareID, fileID, listener, new HashMap()); // Start receiving asynchronously...this actualy retrieves the remote file // 'filename' fileshare.start(); |
New example RobotApplication added to example clients |
The org.eclipse.ecf.example.clients plugin has a new XMPP-based 'robot' in the RobotApplication class. |