jadex.standalone.transport.tcpmtp
Class TCPTransport

java.lang.Object
  extended by jadex.standalone.transport.tcpmtp.TCPTransport
All Implemented Interfaces:
ITransport

public class TCPTransport
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 TCPTransport.Cleaner
          Class for cleaning output connections after max keep alive time has been reached.
 
Field Summary
protected  String[] addresses
          The addresses.
protected  boolean async
          Should be received asynchronously?
static String ASYNCHRONOUS
          Constant for asynchronous setting.
protected static int BUFFER_SIZE
          2MB as message buffer
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 output connections alive (5 min).
protected  int port
          The port.
static String PORT
          The receiving port.
protected static int PROLOG_SIZE
          The prolog size.
static String SCHEMA
          The schema name.
protected  ServerSocket serversocket
          The server socket for receiving messages.
 
Constructor Summary
TCPTransport(IServiceProvider container, int port)
          Init the transport.
TCPTransport(IServiceProvider container, int port, boolean async)
          Init the transport.
 
Method Summary
protected  jadex.standalone.transport.tcpmtp.TCPOutputConnection createConnection(String address)
          Create a outgoing connection.
protected  void deliverMessages(TCPInputConnection con)
          Deliver messages to local message service for disptaching to the components.
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.tcpmtp.TCPOutputConnection getConnection(String address)
          Get the connection.
 String getServiceSchema()
          Returns the prefix of this transport
protected  void removeConnection(String address)
          Remove a cached connection.
 IComponentIdentifier[] sendMessage(Map msg, String type, 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

ASYNCHRONOUS

public static final String ASYNCHRONOUS
Constant for asynchronous setting.

See Also:
Constant Field Values

PORT

public static final String PORT
The receiving port.

See Also:
Constant Field Values

MAX_KEEPALIVE

protected static final int MAX_KEEPALIVE
How long to keep output 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

BUFFER_SIZE

protected static final int BUFFER_SIZE
2MB as message buffer

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.


serversocket

protected ServerSocket serversocket
The server socket for receiving messages.


connections

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


async

protected boolean async
Should be received asynchronously? One thread for receiving is unavoidable. Async defines if the receival should be done on a new thread always or on the one receiver thread.


codecfac

protected CodecFactory codecfac
The codec factory.


logger

protected Logger logger
The logger.


libservice

protected ILibraryService libservice
The library service.

Constructor Detail

TCPTransport

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

Parameters:
platform - The platform.
settings - The settings.

TCPTransport

public TCPTransport(IServiceProvider container,
                    int port,
                    boolean async)
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 msg,
                                          String type,
                                          IComponentIdentifier[] receivers)
Send a message.

Specified by:
sendMessage in interface ITransport
Parameters:
message - The message to send. (todo: On which thread this should be done?)
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.tcpmtp.TCPOutputConnection getConnection(String address)
Get the connection.

Parameters:
address -
Returns:
a connection of this type

createConnection

protected jadex.standalone.transport.tcpmtp.TCPOutputConnection createConnection(String address)
Create a outgoing connection.

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

removeConnection

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

Parameters:
address - The address.

deliverMessages

protected void deliverMessages(TCPInputConnection con)
Deliver messages to local message service for disptaching to the components.

Parameters:
con - The connection.


Copyright © 2010. All Rights Reserved.