|
The Meta-Environment API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttoolbus.communication.AbstractConnectionHandler
toolbus.adapter.ToolConnectionHandler
public class ToolConnectionHandler
This class handles the opening and closing of the tool's connection with the ToolBus and provides access to the multiplexers that are handling network I/O.
Field Summary | |
---|---|
private static int |
HANDSHAKEBUFFERSIZE
|
private SocketReadWriteMultiplexer |
socketReadWriteMultiplexer
|
Constructor Summary | |
---|---|
ToolConnectionHandler(ToolBridge toolBridge,
java.net.InetAddress host,
int port)
Constructor. |
Method Summary | |
---|---|
void |
closeConnection(java.nio.channels.SocketChannel socketChannel)
Closes the connection associated with the given socket channel. |
IReadMultiplexer |
getReadMultiplexer()
Returns a reference to the read multiplexer. |
IWriteMultiplexer |
getWriteMultiplexer()
Returns a reference to the write multiplexer. |
private aterm.ATerm |
readTermFromChannel(aterm.pure.PureFactory factory,
java.nio.channels.SocketChannel socketChannel,
java.nio.ByteBuffer byteBuffer)
Reads a term from the given channel, using the given buffer. |
void |
run()
Starts the multiplexer. |
private void |
shakeHands(java.nio.channels.SocketChannel socketChannel,
ToolBridge toolBridge)
Negotiates with the ToolBus (about some stuff) and checks if the tool adheres to the expected interface. |
private void |
writeTermToChannel(aterm.ATerm aTerm,
java.nio.channels.SocketChannel socketChannel,
java.nio.ByteBuffer byteBuffer)
Transmits the term to the given socket channel, using the given buffer. |
Methods inherited from class toolbus.communication.AbstractConnectionHandler |
---|
closeDueToDisconnect, closeDueToException |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int HANDSHAKEBUFFERSIZE
private final SocketReadWriteMultiplexer socketReadWriteMultiplexer
Constructor Detail |
---|
public ToolConnectionHandler(ToolBridge toolBridge, java.net.InetAddress host, int port)
toolBridge
- The tool bridge that requested the starting of this tool connection.host
- The adress where the ToolBus is running.port
- The port the ToolBus is running on.Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
Runnable.run()
public IReadMultiplexer getReadMultiplexer()
AbstractConnectionHandler
getReadMultiplexer
in class AbstractConnectionHandler
AbstractConnectionHandler.getReadMultiplexer()
public IWriteMultiplexer getWriteMultiplexer()
AbstractConnectionHandler
getWriteMultiplexer
in class AbstractConnectionHandler
AbstractConnectionHandler.getWriteMultiplexer()
private void shakeHands(java.nio.channels.SocketChannel socketChannel, ToolBridge toolBridge) throws java.io.IOException
socketChannel
- The socket channel that we need to use to perform the handshake.toolBridge
- The tool bridge that provides access to the tool.
java.io.IOException
- Thrown when something goes wrong with the connection during the handshake.private void writeTermToChannel(aterm.ATerm aTerm, java.nio.channels.SocketChannel socketChannel, java.nio.ByteBuffer byteBuffer) throws java.io.IOException
aTerm
- The term to write.socketChannel
- The channel to write to.byteBuffer
- The buffer to use.
java.io.IOException
- Thrown when something goes wrong while writing to the channel.private aterm.ATerm readTermFromChannel(aterm.pure.PureFactory factory, java.nio.channels.SocketChannel socketChannel, java.nio.ByteBuffer byteBuffer) throws java.io.IOException
factory
- The factory to use for parsing the term.socketChannel
- The channel to read from.byteBuffer
- The buffer to use.
java.io.IOException
- Thrown when something goes wrong while reading the term from the channel.public void closeConnection(java.nio.channels.SocketChannel socketChannel)
AbstractConnectionHandler
closeConnection
in class AbstractConnectionHandler
socketChannel
- The socket channel, who's associated socket should be closed.AbstractConnectionHandler.closeConnection(SocketChannel)
|
The Meta-Environment API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |