|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.method.TcpConnection
public class TcpConnection
Connection is a class that handles request-response communication over a socket.
Requests have asynchronous result. The result can be acquired using one of the three methods: 1) Blocking read AsyncResult.waitForResponse() 2) Poll AsyncResult.getResponse() 3) Listen AsyncResult.setListener()
The socket must be established before Connection is instantiated. Closing connection does not close its Socket. If the socket is closed before connection there an error is thrown. The error is available by placing listener. The proper order to close a connection is to close Connection first and then Socket.
Nested Class Summary | |
---|---|
static interface |
TcpConnection.ConnectionListener
|
static class |
TcpConnection.Exception_
|
static class |
TcpConnection.ExecutionError_
|
static class |
TcpConnection.InvalidMethodError
|
static class |
TcpConnection.Message
|
static class |
TcpConnection.RequestHeader
|
static class |
TcpConnection.ResponseHeader
|
static class |
TcpConnection.ResponseTooLargeError
|
Nested classes/interfaces inherited from interface org.simantics.databoard.method.MethodInterface |
---|
MethodInterface.AsyncRequestStatus, MethodInterface.AsyncResult, MethodInterface.ExecutionError, MethodInterface.InvokeListener, MethodInterface.Method |
Field Summary | |
---|---|
static java.util.concurrent.ExecutorService |
SHARED_EXECUTOR_SERVICE
|
java.util.concurrent.ExecutorService |
writeExecutor
|
Constructor Summary | |
---|---|
TcpConnection(java.net.Socket socket,
MethodInterface methodInterface,
Handshake localData,
Handshake remoteData)
Create a connection to a hand-shaken socket |
Method Summary | |
---|---|
void |
addConnectionListener(TcpConnection.ConnectionListener listener)
|
void |
close()
Close the connection. |
static TcpConnection |
getCurrentConnection()
Get the active connection of current thread |
Interface |
getInterface()
Get method descriptions |
MethodTypeDefinition[] |
getLocalMethodDescriptions()
Get method interface that handles services locally (service requests by peer) |
MethodInterface |
getLocalMethodInterface()
Get method interface that handles services locally (service requests by peer) |
MethodInterface.Method |
getMethod(MethodTypeBinding binding)
Get an access to the implementation of a method. |
MethodInterface.Method |
getMethod(MethodTypeDefinition description)
Get an access to the implementation of a method. |
MethodInterface |
getRemoteMethodInterface()
|
java.net.Socket |
getSocket()
|
static Handshake |
handshake(java.net.Socket socket,
Handshake localData)
Handshake a socket |
void |
removeConnectionListener(TcpConnection.ConnectionListener listener)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.concurrent.ExecutorService SHARED_EXECUTOR_SERVICE
public java.util.concurrent.ExecutorService writeExecutor
Constructor Detail |
---|
public TcpConnection(java.net.Socket socket, MethodInterface methodInterface, Handshake localData, Handshake remoteData) throws java.io.IOException
socket
- methodInterface
- local method handlerlocalData
- remoteData
-
java.io.IOException
Method Detail |
---|
public static Handshake handshake(java.net.Socket socket, Handshake localData) throws java.io.IOException, SerializationException, BindingException
socket
- localData
- local data
java.io.IOException
BindingException
SerializationException
java.lang.RuntimeException
- unexpected error (BindingException or EncodingException)public Interface getInterface()
MethodInterface
getInterface
in interface MethodInterface
public MethodInterface.Method getMethod(MethodTypeBinding binding) throws MethodNotSupportedException
MethodInterface
getMethod
in interface MethodInterface
binding
- binding to use
MethodNotSupportedException
public MethodInterface.Method getMethod(MethodTypeDefinition description) throws MethodNotSupportedException
MethodInterface
getMethod
in interface MethodInterface
description
- method description
MethodNotSupportedException
public java.net.Socket getSocket()
public void addConnectionListener(TcpConnection.ConnectionListener listener)
public void removeConnectionListener(TcpConnection.ConnectionListener listener)
public MethodInterface getLocalMethodInterface()
public MethodTypeDefinition[] getLocalMethodDescriptions()
public MethodInterface getRemoteMethodInterface()
public void close()
public static TcpConnection getCurrentConnection()
null
if current thread does not run connection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |