jadex.standalone.transport.niotcpmtp
Class NIOTCPTransport

java.lang.Object
  extended by jadex.standalone.transport.niotcpmtp.NIOTCPTransport
All Implemented Interfaces:
ITransport

public class NIOTCPTransport
extends Object
implements ITransport

The tcp transport for sending messages over tcp/ip connections. Initiates one receiving tcp/ip port under the specified settings and opens outgoing connections for all remote platforms on demand. For the receiving side a separate listener thread is necessary as it must be continuously listened for incoming transmission requests.


Nested Class Summary
protected  class NIOTCPTransport.Cleaner
          Class for cleaning output connections after max keep alive time has been reached.
 
Field Summary
protected  String[] addresses
          The addresses.
protected  CodecFactory codecfac
          The codec factory.
protected  Map connections
          The opened connections for addresses.
protected  IServiceProvider container
          The platform.
protected static int DEFAULT_PORT
          Default port.
protected  ILibraryService libservice
          The library service.
protected  Logger logger
          The logger.
protected static int MAX_CONNECTIONS
          Maximum number of outgoing connections
protected static int MAX_KEEPALIVE
          How long to keep connections alive (5 min).
protected  int port
          The port.
protected static int PROLOG_SIZE
          The prolog size.
static String SCHEMA
          The schema name.
protected  Selector selector
          The selector for fetching new incoming requests.
protected  ServerSocketChannel ssc
          The server socket for receiving messages.
 
Fields inherited from interface jadex.standalone.transport.ITransport
PORT
 
Constructor Summary
NIOTCPTransport(IServiceProvider container, int port)
          Init the transport.
 
Method Summary
protected  jadex.standalone.transport.niotcpmtp.NIOTCPOutputConnection createConnection(String address)
          Create a outgoing connection.
protected  String getAddress(String hostname, int port)
          Get the address of this transport.
 String[] getAddresses()
          Get the adresses of this transport.
protected  jadex.standalone.transport.niotcpmtp.NIOTCPOutputConnection getConnection(String address)
          Get the cached connection.
 String getServiceSchema()
          Returns the prefix of this transport
protected  void removeConnection(String address)
          Remove a cached connection.
 IComponentIdentifier[] sendMessage(Map message, String msgtype, IComponentIdentifier[] receivers)
          Send a message.
 void shutdown()
          Perform cleanup operations (if any).
 void start()
          Start the transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMA

public static final String SCHEMA
The schema name.

See Also:
Constant Field Values

MAX_KEEPALIVE

protected static final int MAX_KEEPALIVE
How long to keep connections alive (5 min).

See Also:
Constant Field Values

PROLOG_SIZE

protected static final int PROLOG_SIZE
The prolog size.

See Also:
Constant Field Values

MAX_CONNECTIONS

protected static final int MAX_CONNECTIONS
Maximum number of outgoing connections

See Also:
Constant Field Values

DEFAULT_PORT

protected static final int DEFAULT_PORT
Default port.

See Also:
Constant Field Values

container

protected IServiceProvider container
The platform.


addresses

protected String[] addresses
The addresses.


port

protected int port
The port.


ssc

protected ServerSocketChannel ssc
The server socket for receiving messages.


selector

protected Selector selector
The selector for fetching new incoming requests.


connections

protected Map connections
The opened connections for addresses. (aid address -> connection).


codecfac

protected CodecFactory codecfac
The codec factory.


logger

protected Logger logger
The logger.


libservice

protected ILibraryService libservice
The library service.

Constructor Detail

NIOTCPTransport

public NIOTCPTransport(IServiceProvider container,
                       int port)
Init the transport.

Parameters:
platform - The platform.
settings - The settings.
Method Detail

start

public void start()
Start the transport.

Specified by:
start in interface ITransport

shutdown

public void shutdown()
Perform cleanup operations (if any).

Specified by:
shutdown in interface ITransport

sendMessage

public IComponentIdentifier[] sendMessage(Map message,
                                          String msgtype,
                                          IComponentIdentifier[] receivers)
Send a message.

Specified by:
sendMessage in interface ITransport
Parameters:
message - The message to send.
Returns:
The component identifiers to which this message could not be delivered.

getServiceSchema

public String getServiceSchema()
Returns the prefix of this transport

Specified by:
getServiceSchema in interface ITransport
Returns:
Transport prefix.

getAddresses

public String[] getAddresses()
Get the adresses of this transport.

Specified by:
getAddresses in interface ITransport
Returns:
An array of strings representing the addresses of this message transport mechanism.

getAddress

protected String getAddress(String hostname,
                            int port)
Get the address of this transport.

Parameters:
hostname - The hostname.
port - The port.
Returns:
::

getConnection

protected jadex.standalone.transport.niotcpmtp.NIOTCPOutputConnection getConnection(String address)
                                                                             throws IOException
Get the cached connection.

Parameters:
address - The address.
Returns:
The cached connection.
Throws:
IOException

removeConnection

protected void removeConnection(String address)
Remove a cached connection.

Parameters:
address - The address.

createConnection

protected jadex.standalone.transport.niotcpmtp.NIOTCPOutputConnection createConnection(String address)
Create a outgoing connection.

Parameters:
address - The connection address.
Returns:
the connection to this address


Copyright © 2010. All Rights Reserved.