org.eclipse.net4j.connector
Interface IConnector

All Superinterfaces:
IContainer<IChannel>, INotifier
All Known Subinterfaces:
IHTTPConnector, IHTTPConnector, IJVMConnector, InternalConnector, ITCPConnector

public interface IConnector
extends IContainer<IChannel>

One endpoint of a physical connection of arbitrary nature between two communicating parties. A IConnector encapsulates the process of establishing and closing such connections and has a ConnectorLocation of CLIENT or SERVER with respect to this process. Once a connection is established either party can use its connector to open multiple IChannels to asynchronously exchange IBuffers.

This interface is not intended to be implemented by clients. Providers of connectors for new physical connection types have to implement org.eclipse.internal.net4j.connector.InternalConnector.

Class Diagram:

Sequence Diagram: Communication Process


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
INotifier.Introspection
 
Method Summary
 boolean connect(long timeout)
          Synchronous connect.
 void connectAsync()
          Asynchronous connect.
 ConnectorException disconnect()
           
 IChannel[] getChannels()
          Returns an array of currently open channels.
 ConnectorLocation getLocation()
          Indicates which role this connector has played during the establishment of the physical connection.
 IRegistry<IFactoryKey,IFactory> getProtocolFactoryRegistry()
          Returns the factory registry used by this connector to lookup factories that can create IProtocols for newly opened IChannels.
 java.util.List<IElementProcessor> getProtocolPostProcessors()
          Returns the post processors used by this connector to modify protocols created for new channels.
 ConnectorState getState()
          Returns the current state of this onnector.
 java.lang.String getURL()
           
 java.lang.String getUserID()
          Returns the userID of this connector.
 boolean isClient()
          Same as getLocation() == ConnectorLocation.CLIENT.
 boolean isConnected()
          Same as getState() == ConnectorState.CONNECTED.
 boolean isServer()
          Same as getLocation() == ConnectorLocation.SERVER.
 IChannel openChannel()
          Synchronous request to open a new IChannel with an undefined channel protocol.
 IChannel openChannel(IProtocol protocol)
          Synchronous request to open a new IChannel with the given channel protocol .
 IChannel openChannel(java.lang.String protocolID, java.lang.Object infraStructure)
          Synchronous request to open a new IChannel with a channel protocol defined by a given protocol identifier.
 boolean waitForConnection(long timeout)
          Blocks until isConnected() == true or the given timeout expired.
 
Methods inherited from interface org.eclipse.net4j.util.container.IContainer
getElements, isEmpty
 
Methods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, removeListener
 

Method Detail

getURL

java.lang.String getURL()

getLocation

ConnectorLocation getLocation()
Indicates which role this connector has played during the establishment of the physical connection.


isClient

boolean isClient()
Same as getLocation() == ConnectorLocation.CLIENT.


isServer

boolean isServer()
Same as getLocation() == ConnectorLocation.SERVER.


getUserID

java.lang.String getUserID()
Returns the userID of this connector.


getProtocolFactoryRegistry

IRegistry<IFactoryKey,IFactory> getProtocolFactoryRegistry()
Returns the factory registry used by this connector to lookup factories that can create IProtocols for newly opened IChannels.

Automatic protocol creation only happens if isServer() returns true.


getProtocolPostProcessors

java.util.List<IElementProcessor> getProtocolPostProcessors()
Returns the post processors used by this connector to modify protocols created for new channels.


getState

ConnectorState getState()
Returns the current state of this onnector.


isConnected

boolean isConnected()
Same as getState() == ConnectorState.CONNECTED.


connectAsync

void connectAsync()
                  throws ConnectorException
Asynchronous connect. May leave this IConnector in a state where isConnected() == false .

Throws:
ConnectorException

waitForConnection

boolean waitForConnection(long timeout)
                          throws ConnectorException
Blocks until isConnected() == true or the given timeout expired.

Throws:
ConnectorException

connect

boolean connect(long timeout)
                throws ConnectorException
Synchronous connect. Blocks until isConnected() == true or the given timeout expired.

Throws:
ConnectorException

disconnect

ConnectorException disconnect()

getChannels

IChannel[] getChannels()
Returns an array of currently open channels. Note that the resulting array does not contain null values. Generally the channelIndex of a channel can not be used as an index into this array.


openChannel

IChannel openChannel()
                     throws ConnectorException
Synchronous request to open a new IChannel with an undefined channel protocol. Since the peer connector can't lookup a protocol factory without a protocol identifier the IBufferHandler of the peer IChannel can only be provided by externally provided channel lifecycle listeners.

Throws:
ConnectorException
See Also:
openChannel(String, Object), openChannel(IProtocol)

openChannel

IChannel openChannel(java.lang.String protocolID,
                     java.lang.Object infraStructure)
                     throws ConnectorException
Synchronous request to open a new IChannel with a channel protocol defined by a given protocol identifier. The peer connector will lookup a protocol factory with the protocol identifier, create a IBufferHandler and inject it into the peer IChannel.

Throws:
ConnectorException
See Also:
openChannel(), openChannel(IProtocol)

openChannel

IChannel openChannel(IProtocol protocol)
                     throws ConnectorException
Synchronous request to open a new IChannel with the given channel protocol . The peer connector will lookup a protocol factory with the protocol identifier, create a IBufferHandler and inject it into the peer channel.

Throws:
ConnectorException
See Also:
openChannel(), openChannel(String, Object)

Copyright (c) 2004 - 2008 Eike Stepper, Germany.
All Rights Reserved.