Class IntravmTransport
- java.lang.Object
-
- jadex.platform.service.transport.intravm.IntravmTransport
-
- All Implemented Interfaces:
ITransport<IntravmTransport.HandlerHolder>
public class IntravmTransport extends java.lang.Object implements ITransport<IntravmTransport.HandlerHolder>
Message transport for bisimulation (no external threads) based on intra VM passing of message data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
IntravmTransport.HandlerHolder
Holder to distinguish connections.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
Active flag.protected ITransportHandler<IntravmTransport.HandlerHolder>
handler
The transport handler, e.g. for delivering received messages.protected static java.util.Map<java.lang.Integer,IntravmTransport>
ports
The "ports".static int
PRIORITY
Priority of transport.
-
Constructor Summary
Constructors Constructor Description IntravmTransport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeConnection(IntravmTransport.HandlerHolder con)
Perform close operations on a connection.IFuture<IntravmTransport.HandlerHolder>
createConnection(java.lang.String address, IComponentIdentifier target)
Create a connection to a given address.java.lang.String
getProtocolName()
Get the protocol name.void
init(ITransportHandler<IntravmTransport.HandlerHolder> handler)
Initialize the transport.IFuture<java.lang.Integer>
openPort(int port)
Open a server "socket".IFuture<java.lang.Integer>
sendMessage(IntravmTransport.HandlerHolder con, byte[] header, byte[] body)
Send bytes using the given connection.void
shutdown()
Cleanup
-
-
-
Field Detail
-
PRIORITY
public static final int PRIORITY
Priority of transport.- See Also:
- Constant Field Values
-
ports
protected static final java.util.Map<java.lang.Integer,IntravmTransport> ports
The "ports".
-
active
protected volatile boolean active
Active flag.
-
handler
protected ITransportHandler<IntravmTransport.HandlerHolder> handler
The transport handler, e.g. for delivering received messages.
-
-
Method Detail
-
init
public void init(ITransportHandler<IntravmTransport.HandlerHolder> handler)
Initialize the transport. To be called once, before any other method.- Specified by:
init
in interfaceITransport<IntravmTransport.HandlerHolder>
- Parameters:
handler
- The transport handler with callback methods.
-
shutdown
public void shutdown()
Cleanup- Specified by:
shutdown
in interfaceITransport<IntravmTransport.HandlerHolder>
-
getProtocolName
public java.lang.String getProtocolName()
Get the protocol name.- Specified by:
getProtocolName
in interfaceITransport<IntravmTransport.HandlerHolder>
-
openPort
public IFuture<java.lang.Integer> openPort(int port)
Open a server "socket".- Specified by:
openPort
in interfaceITransport<IntravmTransport.HandlerHolder>
- Parameters:
port
- The (positive) port or 0 for any port.- Returns:
- A future holding the actual port, once the server is running.
-
createConnection
public IFuture<IntravmTransport.HandlerHolder> createConnection(java.lang.String address, IComponentIdentifier target)
Create a connection to a given address.- Specified by:
createConnection
in interfaceITransport<IntravmTransport.HandlerHolder>
- Parameters:
address
- The target platform's address.target
- The target identifier to maybe perform authentication of the connection.- Returns:
- A future containing the connection when succeeded.
-
closeConnection
public void closeConnection(IntravmTransport.HandlerHolder con)
Perform close operations on a connection. Potentially cleans up key attachments as well.- Specified by:
closeConnection
in interfaceITransport<IntravmTransport.HandlerHolder>
-
sendMessage
public IFuture<java.lang.Integer> sendMessage(IntravmTransport.HandlerHolder con, byte[] header, byte[] body)
Send bytes using the given connection.- Specified by:
sendMessage
in interfaceITransport<IntravmTransport.HandlerHolder>
- Parameters:
con
- The connection.header
- The message header.body
- The message body.- Returns:
- A future indicating success.
-
-