org.eclipse.ecf.datashare
Class AbstractShare

java.lang.Object
  extended by org.eclipse.ecf.datashare.AbstractShare
Direct Known Subclasses:
DocShare

public abstract class AbstractShare
extends java.lang.Object

Abstract class for sharing data using IChannel. Subclasses should be created as desired to share objects of different types.


Field Summary
protected  IChannelContainerAdapter adapter
           
protected  IChannel channel
           
 
Constructor Summary
AbstractShare(IChannelContainerAdapter adapter)
           
AbstractShare(IChannelContainerAdapter adapter, ID channelID)
           
AbstractShare(IChannelContainerAdapter adapter, ID channelID, java.util.Map options)
           
 
Method Summary
 void dispose()
           
 IChannel getChannel()
           
protected  void handleChannelEvent(IChannelEvent event)
          Handle reception of an IChannelEvent.
protected  void handleConnectEvent(IChannelConnectEvent cce)
           
protected  void handleDisconnectEvent(IChannelDisconnectEvent cde)
           
protected abstract  void handleMessage(ID fromContainerID, byte[] data)
          Receive message for this channel.
 boolean isDisposed()
           
 void sendMessage(ID toID, byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

protected IChannel channel

adapter

protected IChannelContainerAdapter adapter
Constructor Detail

AbstractShare

public AbstractShare(IChannelContainerAdapter adapter)
              throws ECFException
Throws:
ECFException

AbstractShare

public AbstractShare(IChannelContainerAdapter adapter,
                     ID channelID)
              throws ECFException
Throws:
ECFException

AbstractShare

public AbstractShare(IChannelContainerAdapter adapter,
                     ID channelID,
                     java.util.Map options)
              throws ECFException
Throws:
ECFException
Method Detail

handleChannelEvent

protected void handleChannelEvent(IChannelEvent event)
Handle reception of an IChannelEvent.

Parameters:
event - the IChannelEvent received. This implementation detects instances of IChannelMessageEvent and calls handleMessage(ID, byte[]) if found. All other channel events are ignored. Subclasses may override to detect and respond to other channel events as desired.

handleDisconnectEvent

protected void handleDisconnectEvent(IChannelDisconnectEvent cde)
Parameters:
cde -

handleConnectEvent

protected void handleConnectEvent(IChannelConnectEvent cce)
Parameters:
cce -

handleMessage

protected abstract void handleMessage(ID fromContainerID,
                                      byte[] data)
Receive message for this channel. This method will be called asynchronously by an arbitrary thread when data to the associated channel is received.

Parameters:
fromContainerID - the ID of the sender container. Will not be null.
data - the data received on the channel. Will not be null.

sendMessage

public void sendMessage(ID toID,
                        byte[] data)
                 throws ECFException
Throws:
ECFException

getChannel

public IChannel getChannel()

isDisposed

public boolean isDisposed()

dispose

public void dispose()