public class NIOTCPTransport extends java.lang.Object implements ITransport
Modifier and Type | Field and Description |
---|---|
protected static java.util.Map<java.lang.String,java.net.InetAddress> |
addresscache
Cache for internet addresses to avoid slow lookup.
|
protected java.lang.String[] |
addresses
The addresses.
|
protected jadex.bridge.IInternalAccess |
component
The platform.
|
static long |
DEADSPAN
The time span for which a failed connection is not retried.
|
protected static int |
DEFAULT_PORT
Default port.
|
protected java.util.logging.Logger |
logger
The logger.
|
protected static int |
MAX_KEEPALIVE
How long to keep connections alive (5 min).
|
protected int |
port
The port.
|
static java.lang.String[] |
SCHEMAS
The schema name.
|
protected SelectorThread |
selectorthread
The selector thread.
|
protected boolean |
shutdown
Flag indicating that the transport was shut down.
|
protected java.nio.channels.ServerSocketChannel |
ssc
The server socket for receiving messages.
|
Constructor and Description |
---|
NIOTCPTransport(jadex.bridge.IInternalAccess component,
int port,
java.util.logging.Logger logger)
Init the transport.
|
Modifier and Type | Method and Description |
---|---|
protected static java.net.InetAddress |
getAddress(java.lang.String hostname) |
protected java.lang.String |
getAddress(java.lang.String schema,
java.lang.String hostname,
int port)
Get the address of this transport.
|
java.lang.String[] |
getAddresses()
Get the addresses of this transport.
|
java.lang.String[] |
getServiceSchemas()
Returns the prefix of this transport
|
boolean |
isApplicable(java.lang.String address)
Test if a transport is applicable for the target address.
|
boolean |
isNonFunctionalSatisfied(java.util.Map<java.lang.String,java.lang.Object> nonfunc,
java.lang.String address)
Test if a transport satisfies the non-functional requirements.
|
protected java.net.InetSocketAddress |
parseAddress(java.lang.String address)
Parse an address.
|
void |
sendMessage(java.lang.String address,
ISendTask task)
Send a message to the given address.
|
jadex.commons.future.IFuture<java.lang.Void> |
shutdown()
Perform cleanup operations (if any).
|
jadex.commons.future.IFuture<java.lang.Void> |
start()
Start the transport.
|
public static final java.lang.String[] SCHEMAS
protected static final int MAX_KEEPALIVE
public static final long DEADSPAN
protected static final int DEFAULT_PORT
protected jadex.bridge.IInternalAccess component
protected java.lang.String[] addresses
protected int port
protected java.nio.channels.ServerSocketChannel ssc
protected java.util.logging.Logger logger
protected SelectorThread selectorthread
protected boolean shutdown
protected static java.util.Map<java.lang.String,java.net.InetAddress> addresscache
public NIOTCPTransport(jadex.bridge.IInternalAccess component, int port, java.util.logging.Logger logger)
platform
- The platform.settings
- The settings.public jadex.commons.future.IFuture<java.lang.Void> start()
start
in interface ITransport
public jadex.commons.future.IFuture<java.lang.Void> shutdown()
shutdown
in interface ITransport
public boolean isApplicable(java.lang.String address)
isApplicable
in interface ITransport
public boolean isNonFunctionalSatisfied(java.util.Map<java.lang.String,java.lang.Object> nonfunc, java.lang.String address)
isNonFunctionalSatisfied
in interface ITransport
nonfunc
- The non-functional requirements (name, value).address
- The transport address.public void sendMessage(java.lang.String address, ISendTask task)
sendMessage
in interface ITransport
address
- The address to send to.task
- A task representing the message to send.public java.lang.String[] getServiceSchemas()
getServiceSchemas
in interface ITransport
public java.lang.String[] getAddresses()
getAddresses
in interface ITransport
protected java.lang.String getAddress(java.lang.String schema, java.lang.String hostname, int port)
hostname
- The hostname.port
- The port.protected java.net.InetSocketAddress parseAddress(java.lang.String address)
address
- The address string.protected static java.net.InetAddress getAddress(java.lang.String hostname)