org.fossilec.odettej.transport
Interface Transport

All Known Implementing Classes:
MoreDataBitTransport, TCPTransport

public interface Transport

This interface provides a protocol independent network transport layer required by Odette FTP peer entities to with each via the underlying OSI model Network Service provider.

Author:
Rafael Marins

Method Summary
 boolean connect(NetworkAddress address)
          Setup a network connection with another Odette FTP peer entity.
 boolean connect(java.lang.String address)
          Setup a connection with another Odette FTP peer entity.
 void disconnect()
          Terminate the ongoing connection.
 java.lang.String getLocalAddress()
          Returns local address used to fulfill Odette FTP session variables.
 java.lang.String getRemoteAddress()
          Returns remote address used to fulfill Odette FTP session variables.
 boolean isConnected()
          Tells whether the underlying network protocol is connected.
 int receive(java.nio.ByteBuffer dst)
          Receive a sequence of bytes from the underlying transport implementation of network protocol.
 int send(java.nio.ByteBuffer src)
          Send a sequence of bytes through this transport implementation, of the underlying network protocol, from the given buffer.
 int send(java.nio.ByteBuffer[] srcs)
          Sent a sequence of bytes through this transport implementation, of the underlying network protocol, from a subsequence of the given buffers.
 

Method Detail

connect

boolean connect(NetworkAddress address)
                throws OdetteFTPException
Setup a network connection with another Odette FTP peer entity.

Parameters:
address - A protocol specific NetworkAddress implementation with the network location of the target entity.
Returns:
true when connection is established with success
Throws:
ConnectionException - If the transport instance is already connected.
AddressException - For unresolved or unsupported address types
OdetteFTPException - Thrown by unexpected exception

connect

boolean connect(java.lang.String address)
                throws OdetteFTPException
Setup a connection with another Odette FTP peer entity.

Parameters:
address - A String representation of the network location of the target entity of the underlying transport protocol. The value is parsed by the corresponding NetworkAddress implementation of that protocol.
Returns:
true when connection is established with success
Throws:
ConnectionException - If the transport instance is already connected.
AddressException - For unresolved or unsupported address types.
OdetteFTPException - Thrown for unexpected failures

disconnect

void disconnect()
                throws OdetteFTPException
Terminate the ongoing connection. Once the connection is ended, it's not avaiable for further communication activity.

Throws:
OdetteFTPException

getLocalAddress

java.lang.String getLocalAddress()
                                 throws OdetteFTPException
Returns local address used to fulfill Odette FTP session variables. On the Initiator side, it compose the "odette.calling-address " property. The Responder Odette FTP entity use this method to fill the "odette.called-address" property.

Returns:
String representing the local address of the underlying network protocol, as expected by session variables.
Throws:
OdetteFTPException

getRemoteAddress

java.lang.String getRemoteAddress()
                                  throws OdetteFTPException
Returns remote address used to fulfill Odette FTP session variables. On the Initiator side, it's used in the "odette.called-address ". The Responder Odette FTP entity use this method to fill the "odette.calling-address" property.

Returns:
String representing the remote address of the underlying network protocol, as expected by session variables.
Throws:
OdetteFTPException

isConnected

boolean isConnected()
                    throws OdetteFTPException
Tells whether the underlying network protocol is connected.

Returns:
true if this transport implementation is connected.
Throws:
OdetteFTPException

receive

int receive(java.nio.ByteBuffer dst)
            throws OdetteFTPException
Receive a sequence of bytes from the underlying transport implementation of network protocol.

An attempt is made to receive up to r bytes from the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining(), at the moment this method is invoked.

Parameters:
dst - The buffer into which bytes are to be transferred
Returns:
The number of bytes received, possibly zero, or -1 if the channel has reached end-of-stream
Throws:
NotConnectedException - Transport not yet connected
OdetteFTPException - Thrown by unexpected exception

send

int send(java.nio.ByteBuffer src)
         throws OdetteFTPException
Send a sequence of bytes through this transport implementation, of the underlying network protocol, from the given buffer.

An attempt is made to send up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining(), at the moment this method is invoked.

Parameters:
src - The buffer from which bytes are to be retrieved
Returns:
The number of bytes sent, possibly zero
Throws:
NotConnectedException - Transport not yet connected
OdetteFTPException - Thrown by unexpected exception

send

int send(java.nio.ByteBuffer[] srcs)
         throws OdetteFTPException
Sent a sequence of bytes through this transport implementation, of the underlying network protocol, from a subsequence of the given buffers.

Parameters:
srcs - The sequence of buffers from which bytes are to be retrieved
Returns:
The number of overall bytes sent, possibly zero
Throws:
OdetteFTPException


Copyright © 2005 ObjectWeb Consortium. All Rights Reserved.