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 classIntravmTransport.HandlerHolderHolder to distinguish connections.
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveActive flag.protected ITransportHandler<IntravmTransport.HandlerHolder>handlerThe transport handler, e.g. for delivering received messages.protected static java.util.Map<java.lang.Integer,IntravmTransport>portsThe "ports".static intPRIORITYPriority of transport.
-
Constructor Summary
Constructors Constructor Description IntravmTransport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection(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.StringgetProtocolName()Get the protocol name.voidinit(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.voidshutdown()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:
initin interfaceITransport<IntravmTransport.HandlerHolder>- Parameters:
handler- The transport handler with callback methods.
-
shutdown
public void shutdown()
Cleanup- Specified by:
shutdownin interfaceITransport<IntravmTransport.HandlerHolder>
-
getProtocolName
public java.lang.String getProtocolName()
Get the protocol name.- Specified by:
getProtocolNamein interfaceITransport<IntravmTransport.HandlerHolder>
-
openPort
public IFuture<java.lang.Integer> openPort(int port)
Open a server "socket".- Specified by:
openPortin 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:
createConnectionin 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:
closeConnectionin 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:
sendMessagein interfaceITransport<IntravmTransport.HandlerHolder>- Parameters:
con- The connection.header- The message header.body- The message body.- Returns:
- A future indicating success.
-
-