org.eclipse.ecf.provider.datashare.nio
Class NIODatashareContainer

java.lang.Object
  extended by org.eclipse.ecf.provider.datashare.nio.NIODatashareContainer
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IAbstractChannelContainerAdapter, IChannelContainerAdapter

public abstract class NIODatashareContainer
extends java.lang.Object
implements IChannelContainerAdapter

A datashare channel container implementation that creates channels that uses NIO for sending and receiving messages.

The channel container facilitates communication at a socket-level to a corresponding NIOChannel. When a request has been received from a remote peer to establish a channel connection, the request can be honoured via calling the enqueue(SocketAddress) method with the remote peer's corresponding socket address as the parameter.

Subclasses must implement the following:

Note: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Constructor Summary
NIODatashareContainer(IContainer container)
          Instantiates a new datashare container that will connect to remote clients using NIO functionality.
 
Method Summary
 void addListener(IChannelContainerListener listener)
          Add listener for IChannelContainerAdapter events.
 IChannel createChannel(IChannelConfig newChannelConfig)
          Create a new channel within this container
 IChannel createChannel(ID channelId, IChannelListener listener, java.util.Map properties)
          Create a new channel within this container
protected abstract  NIOChannel createNIOChannel(IChannelConfig newChannelConfig)
          Creates a new NIO-capable channel within this container.
protected abstract  NIOChannel createNIOChannel(ID channelId, IChannelListener listener, java.util.Map properties)
          Creates a new NIO-capable channel within this container.
 void enqueue(java.net.SocketAddress address)
          Enqueues the specified address to be connected to.
 java.lang.Object getAdapter(java.lang.Class adapter)
           
 IChannel getChannel(ID channelId)
          Get IChannel with given channelID.
protected abstract  void log(org.eclipse.core.runtime.IStatus status)
           
 boolean removeChannel(ID channelId)
          Remove channel with given ID.
 void removeListener(IChannelContainerListener listener)
          Remove listener for IChannelContainerAdapter events
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.ecf.datashare.IAbstractChannelContainerAdapter
getChannelNamespace
 

Constructor Detail

NIODatashareContainer

public NIODatashareContainer(IContainer container)
Instantiates a new datashare container that will connect to remote clients using NIO functionality.

Parameters:
container - the parent container of this datashare container, must not be null
Method Detail

log

protected abstract void log(org.eclipse.core.runtime.IStatus status)

enqueue

public void enqueue(java.net.SocketAddress address)
Enqueues the specified address to be connected to. This should be invoked after a request has been received from a remote user.

Parameters:
address - the address to connect to, cannot be null
See Also:
NIOChannel.sendRequest(ID)

createNIOChannel

protected abstract NIOChannel createNIOChannel(ID channelId,
                                               IChannelListener listener,
                                               java.util.Map properties)
                                        throws ECFException
Creates a new NIO-capable channel within this container.

Parameters:
channelId - the ID of the channel, must not be null
listener - the listener for receiving notifications pertaining to the created channel, may be null if no listener needs to be notified
properties - a map of properties to provide to this channel, may be null
Returns:
the created NIOChannel instance
Throws:
ECFException - if an error occurred while creating the channel
See Also:
createChannel(ID, IChannelListener, Map)

createNIOChannel

protected abstract NIOChannel createNIOChannel(IChannelConfig newChannelConfig)
                                        throws ECFException
Creates a new NIO-capable channel within this container.

Parameters:
newChannelConfig - the configuration for the newly created channel, must not be null
Returns:
the created NIOChannel instance
Throws:
ECFException - if an error occurred while creating the channel
See Also:
createChannel(IChannelConfig)

createChannel

public final IChannel createChannel(ID channelId,
                                    IChannelListener listener,
                                    java.util.Map properties)
                             throws ECFException
Description copied from interface: IChannelContainerAdapter
Create a new channel within this container

Specified by:
createChannel in interface IChannelContainerAdapter
Parameters:
channelId - the ID of the new channel. Must not be null.
listener - a listener for receiving messages from remotes for this channel. May be null if no listener is to be notified.
properties - a Map of properties to provide to the channel. May be null.
Returns:
IChannel the new IChannel instance
Throws:
ECFException - if some problem creating IChannel instance

createChannel

public final IChannel createChannel(IChannelConfig newChannelConfig)
                             throws ECFException
Description copied from interface: IChannelContainerAdapter
Create a new channel within this container

Specified by:
createChannel in interface IChannelContainerAdapter
Parameters:
newChannelConfig - the configuration for the newly created channel. Must not be null.
Returns:
IChannel the new IChannel instance. Will not be null.
Throws:
ECFException - if some problem creating IChannel instance

addListener

public void addListener(IChannelContainerListener listener)
Description copied from interface: IAbstractChannelContainerAdapter
Add listener for IChannelContainerAdapter events.

Specified by:
addListener in interface IAbstractChannelContainerAdapter
Parameters:
listener - to be added. Must not be null.

getChannel

public IChannel getChannel(ID channelId)
Description copied from interface: IAbstractChannelContainerAdapter
Get IChannel with given channelID.

Specified by:
getChannel in interface IAbstractChannelContainerAdapter
Parameters:
channelId - the ID of the channel to get. Must not be null.
Returns:
IChannel of channel within container with given ID. Returns null if channel not found.

removeChannel

public boolean removeChannel(ID channelId)
Description copied from interface: IAbstractChannelContainerAdapter
Remove channel with given ID. If the channel is found in the container, the enclosing container will call IAbstractChannel.dispose() to dispose the channel before returning from this method.

Specified by:
removeChannel in interface IAbstractChannelContainerAdapter
Parameters:
channelId - the ID of the channel to remove within this container. Must not be null.
Returns:
true if channel found and Removed. False if channel not found within container.

removeListener

public void removeListener(IChannelContainerListener listener)
Description copied from interface: IAbstractChannelContainerAdapter
Remove listener for IChannelContainerAdapter events

Specified by:
removeListener in interface IAbstractChannelContainerAdapter
Parameters:
listener - to be removed. Must not be null.

getAdapter

public java.lang.Object getAdapter(java.lang.Class adapter)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object